live2d-widgets
Version:
Live2D widget for web pages
5 lines • 209 kB
JavaScript
/*!
* Live2D Widget
* https://github.com/stevenjoezhang/live2d-widget
*/
import{l as t}from"../waifu-tips.js";class e{constructor(t=0){t<1?(this._ptr=[],this._capacity=0,this._size=0):(this._ptr=new Array(t),this._capacity=t,this._size=0)}at(t){return this._ptr[t]}set(t,e){this._ptr[t]=e}get(t=0){const e=new Array;for(let i=t;i<this._size;i++)e.push(this._ptr[i]);return e}pushBack(t){this._size>=this._capacity&&this.prepareCapacity(0==this._capacity?e.DefaultSize:2*this._capacity),this._ptr[this._size++]=t}clear(){this._ptr.length=0,this._size=0}getSize(){return this._size}assign(t,e){this._size<t&&this.prepareCapacity(t);for(let i=0;i<t;i++)this._ptr[i]=e;this._size=t}resize(t,e=null){this.updateSize(t,e,!0)}updateSize(t,e=null,i=!0){if(this._size<t)if(this.prepareCapacity(t),i)for(let i=this._size;i<t;i++)this._ptr[i]="function"==typeof e?JSON.parse(JSON.stringify(new e)):e;else for(let i=this._size;i<t;i++)this._ptr[i]=e;else{const e=this._size-t;this._ptr.splice(this._size-e,e)}this._size=t}insert(t,e,i){let s=t._index;const r=e._index,a=i._index,n=a-r;this.prepareCapacity(this._size+n);const o=this._size-s;if(o>0)for(let t=0;t<o;t++)this._ptr.splice(s+t,0,null);for(let t=r;t<a;t++,s++)this._ptr[s]=e._vector._ptr[t];this._size=this._size+n}remove(t){return!(t<0||this._size<=t)&&(this._ptr.splice(t,1),--this._size,!0)}erase(t){const e=t._index;if(e<0||this._size<=e)return t;this._ptr.splice(e,1),--this._size;return new i(this,e)}prepareCapacity(t){t>this._capacity&&(0==this._capacity?(this._ptr=new Array(t),this._capacity=t):(this._ptr.length=t,this._capacity=t))}begin(){return 0==this._size?this.end():new i(this,0)}end(){return new i(this,this._size)}getOffset(t){const i=new e;return i._ptr=this.get(t),i._size=this.get(t).length,i._capacity=this.get(t).length,i}}e.DefaultSize=10;let i=class t{constructor(t,e){this._vector=null!=t?t:null,this._index=null!=e?e:0}set(t){return this._index=t._index,this._vector=t._vector,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new t(this._vector,this._index++)}decrement(){return new t(this._vector,this._index--)}ptr(){return this._vector._ptr[this._index]}substitution(t){return this._index=t._index,this._vector=t._vector,this}notEqual(t){return this._index!=t._index||this._vector!=t._vector}};var s,r,a,n,o,l,h,u;!function(t){t.csmVector=e,t.iterator=i}(s||(s={}));class g{append(t,e){return this.s+=void 0!==e?t.substr(0,e):t,this}expansion(t,e){for(let i=0;i<t;i++)this.append(e);return this}getBytes(){return encodeURIComponent(this.s).replace(/%../g,"x").length}getLength(){return this.s.length}isLess(t){return this.s<t.s}isGreat(t){return this.s>t.s}isEqual(t){return this.s==t}isEmpty(){return 0==this.s.length}constructor(t){this.s=t}}(r||(r={})).csmString=g;class d{static createIdInternal(t){return new d(t)}getString(){return this._id}isEqual(t){return"string"==typeof t?this._id.isEqual(t):t instanceof g?this._id.isEqual(t.s):t instanceof d&&this._id.isEqual(t._id.s)}isNotEqual(t){return"string"==typeof t?!this._id.isEqual(t):t instanceof g?!this._id.isEqual(t.s):t instanceof d&&!this._id.isEqual(t._id.s)}constructor(t){this._id="string"!=typeof t?t:new g(t)}}(a||(a={})).CubismId=d;class _{constructor(){this._ids=new e}release(){for(let t=0;t<this._ids.getSize();++t)this._ids.set(t,void 0);this._ids=null}registerIds(t){for(let e=0;e<t.length;e++)this.registerId(t[e])}registerId(t){let e=null;return"string"!=typeof t?this.registerId(t.s):(null!=(e=this.findId(t))||(e=d.createIdInternal(t),this._ids.pushBack(e)),e)}getId(t){return this.registerId(t)}isExist(t){return"string"==typeof t?null!=this.findId(t):this.isExist(t.s)}findId(t){for(let e=0;e<this._ids.getSize();++e)if(this._ids.at(e).getString().isEqual(t))return this._ids.at(e);return null}}(n||(n={})).CubismIdManager=_;class c{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const s=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);for(let i=0;i<4;++i)for(let r=0;r<4;++r)for(let a=0;a<4;++a)s[r+4*i]+=t[a+4*i]*e[r+4*a];for(let t=0;t<16;++t)i[t]=s[t]}loadIdentity(){const 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 e=0;e<16;++e)this._tr[e]=t[e]}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,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);c.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);c.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){c.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new c;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}(o||(o={})).CubismMatrix44=c;class m{constructor(t,e,i,s){this.x=t,this.y=e,this.width=i,this.height=s}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(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,e){this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e}}(l||(l={})).csmRect=m;class p{static create(){return null}static delete(t){}initialize(t){this._model=t}drawModel(){null!=this.getModel()&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,s){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),s<0?s=0:s>1&&(s=1),this._modelColor.r=t,this._modelColor.g=e,this._modelColor.b=i,this._modelColor.a=s}getModelColor(){return JSON.parse(JSON.stringify(this._modelColor))}getModelColorWithOpacity(t){const e=this.getModelColor();return e.a*=t,this.isPremultipliedAlpha()&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new f,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new c,this._mvpMatrix4x4.loadIdentity()}}!function(t){t[t.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",t[t.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",t[t.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative"}(h||(h={}));class f{constructor(t=1,e=1,i=1,s=1){this.r=t,this.g=e,this.b=i,this.a=s}}class y{constructor(t,e){this._clippingIdList=t,this._clippingIdCount=e,this._allClippedDrawRect=new m,this._layoutBounds=new m,this._clippedDrawableIndexList=[],this._matrixForMask=new c,this._matrixForDraw=new c,this._bufferIndex=0}release(){null!=this._layoutBounds&&(this._layoutBounds=null),null!=this._allClippedDrawRect&&(this._allClippedDrawRect=null),null!=this._clippedDrawableIndexList&&(this._clippedDrawableIndexList=null)}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}}!function(t){t.CubismBlendMode=h,t.CubismRenderer=p,t.CubismTextureColor=f}(u||(u={}));const S=(t,e,i)=>{((t,e,i)=>{P.print(t,"[CSM]"+e,i)})(t,e+"\n",i)},C=t=>{console.assert(t)};let x,M,v,b;x=(t,...e)=>{S(K.LogLevel_Debug,"[D]"+t,e)},M=(t,...e)=>{S(K.LogLevel_Info,"[I]"+t,e)},v=(t,...e)=>{S(K.LogLevel_Warning,"[W]"+t,e)},b=(t,...e)=>{S(K.LogLevel_Error,"[E]"+t,e)};class P{static print(t,e,i){if(t<$.getLoggingLevel())return;const s=$.coreLogFunction;if(!s)return;s(e.replace(/\{(\d+)\}/g,((t,e)=>i[e])))}static dumpBytes(t,e,i){for(let s=0;s<i;s++)s%16==0&&s>0?this.print(t,"\n"):s%8==0&&s>0&&this.print(t," "),this.print(t,"{0} ",[255&e[s]]);this.print(t,"\n")}constructor(){}}var B,w;(B||(B={})).CubismDebug=P;class F{constructor(t,e){this.first=null==t?null:t,this.second=null==e?null:e}}class I{constructor(t){null!=t?t<1?(this._keyValues=[],this._dummyValue=null,this._size=0):(this._keyValues=new Array(t),this._size=t):(this._keyValues=[],this._dummyValue=null,this._size=0)}release(){this.clear()}appendKey(t){let e=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){e=i;break}-1==e?(this.prepareCapacity(this._size+1,!1),this._keyValues[this._size]=new F(t),this._size+=1):v("The key `{0}` is already append.",t)}getValue(t){let e=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){e=i;break}return e>=0?this._keyValues[e].second:(this.appendKey(t),this._keyValues[this._size-1].second)}setValue(t,e){let i=-1;for(let e=0;e<this._size;e++)if(this._keyValues[e].first==t){i=e;break}i>=0?this._keyValues[i].second=e:(this.appendKey(t),this._keyValues[this._size-1].second=e)}isExist(t){for(let e=0;e<this._size;e++)if(this._keyValues[e].first==t)return!0;return!1}clear(){this._keyValues=void 0,this._keyValues=null,this._keyValues=[],this._size=0}getSize(){return this._size}prepareCapacity(t,e){t>this._keyValues.length&&(0==this._keyValues.length?(!e&&t<I.DefaultSize&&(t=I.DefaultSize),this._keyValues.length=t):(!e&&t<2*this._keyValues.length&&(t=2*this._keyValues.length),this._keyValues.length=t))}begin(){return new V(this,0)}end(){return new V(this,this._size)}erase(t){const e=t._index;if(e<0||this._size<=e)return t;this._keyValues.splice(e,1),--this._size;return new V(this,e)}dumpAsInt(){for(let t=0;t<this._size;t++)x("{0} ,",this._keyValues[t]),x("\n")}}I.DefaultSize=10;class V{constructor(t,e){this._map=null!=t?t:new I,this._index=null!=e?e:0}set(t){return this._index=t._index,this._map=t._map,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new V(this._map,this._index++)}decrement(){const t=new V(this._map,this._index);return this._map=t._map,this._index=t._index,this}ptr(){return this._map._keyValues[this._index]}notEqual(t){return this._index!=t._index||this._map!=t._map}}!function(t){t.csmMap=I,t.csmPair=F,t.iterator=V}(w||(w={}));class E{static parseJsonObject(t,e){return Object.keys(t).forEach((i=>{if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.put(i,new A(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.put(i,new O(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.put(i,new D(s))}else t[i]instanceof Array?e.put(i,E.parseJsonArray(t[i])):t[i]instanceof Object?e.put(i,E.parseJsonObject(t[i],new U)):null==t[i]?e.put(i,new N):e.put(i,t[i])})),e}static parseJsonArray(t){const e=new z;return Object.keys(t).forEach((i=>{if("number"==typeof Number(i))if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.add(new A(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.add(new O(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.add(new D(s))}else t[i]instanceof Array?e.add(this.parseJsonArray(t[i])):t[i]instanceof Object?e.add(this.parseJsonObject(t[i],new U)):null==t[i]?e.add(new N):e.add(t[i]);else if(t[i]instanceof Array)e.add(this.parseJsonArray(t[i]));else if(t[i]instanceof Object)e.add(this.parseJsonObject(t[i],new U));else if(null==t[i])e.add(new N);else{const s=Array(t[i]);for(let t=0;t<s.length;t++)e.add(s[t])}})),e}}const R="Error: type mismatch";let T=class t{constructor(){}getRawString(t,e){return this.getString(t,e)}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 e){return t}getMap(t){return t}getValueByIndex(e){return t.errorValue.setErrorNotForClientCall(R)}getValueByString(e){return t.nullValue.setErrorNotForClientCall(R)}getKeys(){return t.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 k.errorValue}static staticInitializeNotForClientCall(){A.trueValue=new A(!0),A.falseValue=new A(!1),t.errorValue=new k("ERROR",!0),t.nullValue=new N,t.dummyKeys=new e}static staticReleaseNotForClientCall(){A.trueValue=null,A.falseValue=null,t.errorValue=null,t.nullValue=null,t.dummyKeys=null}};class L{constructor(t,e){this._parseCallback=E.parseJsonObject,this._error=null,this._lineCount=0,this._root=null,null!=t&&this.parseBytes(t,e,this._parseCallback)}static create(t,e){const i=new L;return i.parseBytes(t,e,i._parseCallback)?i:(L.delete(i),null)}static delete(t){}getRoot(){return this._root}static arrayBufferToString(t){const e=new Uint8Array(t);let i="";for(let t=0,s=e.length;t<s;++t)i+="%"+this.pad(e[t].toString(16));return i=decodeURIComponent(i),i}static pad(t){return t.length<2?"0"+t:t}parseBytes(t,e,i){const s=new Array(1),r=L.arrayBufferToString(t);if(this._root=null==i?this.parseValue(r,e,0,s):i(JSON.parse(r),new U),this._error){let t="\0";return t="Json parse error : @line "+(this._lineCount+1)+"\n",this._root=new O(t),M("{0}",this._root.getRawString()),!1}return null!=this._root||(this._root=new k(new g(this._error),!1),!1)}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals("EOF")}parseValue(t,e,i,s){if(this._error)return null;let r,a=null,n=i;for(;n<e;n++){switch(t[n]){case"-":case".":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{const e=new Array(1);return r=X(t.slice(n),e),s[0]=t.indexOf(e[0]),new D(r)}case'"':return new O(this.parseString(t,e,n+1,s));case"[":return a=this.parseArray(t,e,n+1,s),a;case"{":return a=this.parseObject(t,e,n+1,s),a;case"n":return n+3<e?(a=new N,s[0]=n+4):this._error="parse null",a;case"t":return n+3<e?(a=A.trueValue,s[0]=n+4):this._error="parse true",a;case"f":return n+4<e?(a=A.falseValue,s[0]=n+5):this._error="illegal ',' position",a;case",":return this._error="illegal ',' position",null;case"]":return s[0]=n,null;case"\n":this._lineCount++}}return this._error="illegal end of value",null}parseString(t,e,i,s){if(this._error)return null;if(!t)return this._error="string is null",null;let r,a,n=i;const o=new g("");let l=i;for(;n<e;n++)switch(r=t[n],r){case'"':return s[0]=n+1,o.append(t.slice(l),n-l),o.s;case"//":if(n++,n-1>l&&o.append(t.slice(l),n-l),l=n+1,n<e)switch(a=t[n],a){case"\\":o.expansion(1,"\\");break;case'"':o.expansion(1,'"');break;case"/":o.expansion(1,"/");break;case"b":o.expansion(1,"\b");break;case"f":o.expansion(1,"\f");break;case"n":o.expansion(1,"\n");break;case"r":o.expansion(1,"\r");break;case"t":o.expansion(1,"\t");break;case"u":this._error="parse string/unicord escape not supported"}else this._error="parse string/escape error"}return this._error="parse string/illegal end",null}parseObject(t,e,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;const r=new U;let a="",n=i,o="";const l=Array(1);let h=!1;for(;n<e;n++){t:for(;n<e;n++)switch(o=t[n],o){case'"':if(a=this.parseString(t,e,n+1,l),this._error)return null;n=l[0],h=!0;break t;case"}":return s[0]=n+1,r;case":":this._error="illegal ':' position";break;case"\n":this._lineCount++}if(!h)return this._error="key not found",null;h=!1;t:for(;n<e;n++)switch(o=t[n],o){case":":h=!0,n++;break t;case"}":this._error="illegal '}' position";break;case"\n":this._lineCount++}if(!h)return this._error="':' not found",null;const i=this.parseValue(t,e,n,l);if(this._error)return null;n=l[0],r.put(a,i);t:for(;n<e;n++)switch(o=t[n],o){case",":break t;case"}":return s[0]=n+1,r;case"\n":this._lineCount++}}return this._error="illegal end of perseObject",null}parseArray(t,e,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;let r,a=new z,n=i;const o=new Array(1);for(;n<e;n++){const i=this.parseValue(t,e,n,o);if(this._error)return null;n=o[0],i&&a.add(i);t:for(;n<e;n++)switch(r=t[n],r){case",":break t;case"]":return s[0]=n+1,a;case"\n":++this._lineCount}}return a=void 0,this._error="illegal end of parseObject",null}}class D extends T{constructor(t){super(),this._value=t}isFloat(){return!0}getString(t,e){return this._value=parseFloat("\0"),this._stringBuffer="\0",this._stringBuffer}toInt(t=0){return parseInt(this._value.toString())}toFloat(t=0){return this._value}equals(t){return"number"==typeof t&&(!Math.round(t)&&t==this._value)}}class A extends T{isBool(){return!0}toBoolean(t=!1){return this._boolValue}getString(t,e){return this._stringBuffer=this._boolValue?"true":"false",this._stringBuffer}equals(t){return"boolean"==typeof t&&t==this._boolValue}isStatic(){return!0}constructor(t){super(),this._boolValue=t}}class O extends T{constructor(t){super(),"string"==typeof t&&(this._stringBuffer=t),t instanceof g&&(this._stringBuffer=t.s)}isString(){return!0}getString(t,e){return this._stringBuffer}equals(t){return"string"==typeof t?this._stringBuffer==t:t instanceof g&&this._stringBuffer==t.s}}class k extends O{isStatic(){return this._isStatic}setErrorNotForClientCall(t){return this._stringBuffer=t,this}constructor(t,e){super(t),this._isStatic=e}isError(){return!0}}class N extends T{isNull(){return!0}getString(t,e){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(t){return this._stringBuffer=t,k.nullValue}constructor(){super(),this._stringBuffer="NullValue"}}class z extends T{constructor(){super(),this._array=new e}release(){for(let t=this._array.begin();t.notEqual(this._array.end());t.preIncrement()){let e=t.ptr();e&&!e.isStatic()&&(e=void 0,e=null)}}isArray(){return!0}getValueByIndex(t){if(t<0||this._array.getSize()<=t)return T.errorValue.setErrorNotForClientCall("Error: index out of bounds");const e=this._array.at(t);return null==e?T.nullValue:e}getValueByString(t){return T.errorValue.setErrorNotForClientCall(R)}getString(t,e){const i=e+"[\n";for(let t=this._array.begin();t.notEqual(this._array.end());t.increment()){const i=t.ptr();this._stringBuffer+=e+""+i.getString(e+" ")+"\n"}return this._stringBuffer=i+e+"]\n",this._stringBuffer}add(t){this._array.pushBack(t)}getVector(t=null){return this._array}getSize(){return this._array.getSize()}}class U extends T{constructor(){super(),this._map=new I}release(){const t=this._map.begin();for(;t.notEqual(this._map.end());){let e=t.ptr().second;e&&!e.isStatic()&&(e=void 0,e=null),t.preIncrement()}}isMap(){return!0}getValueByString(t){if(t instanceof g){const e=this._map.getValue(t.s);return null==e?T.nullValue:e}for(let e=this._map.begin();e.notEqual(this._map.end());e.preIncrement())if(e.ptr().first==t)return null==e.ptr().second?T.nullValue:e.ptr().second;return T.nullValue}getValueByIndex(t){return T.errorValue.setErrorNotForClientCall(R)}getString(t,e){this._stringBuffer=e+"{\n";const i=this._map.begin();for(;i.notEqual(this._map.end());){const t=i.ptr().first,s=i.ptr().second;this._stringBuffer+=e+" "+t+" : "+s.getString(e+" ")+" \n",i.preIncrement()}return this._stringBuffer+=e+"}\n",this._stringBuffer}getMap(t){return this._map}put(t,e){this._map.setValue(t,e)}getKeys(){if(!this._keys){this._keys=new e;const t=this._map.begin();for(;t.notEqual(this._map.end());){const e=t.ptr().first;this._keys.pushBack(e),t.preIncrement()}}return this._keys}getSize(){return this._keys.getSize()}}var G;function X(t,e){let i=0;for(let e=1;;e++){const s=t.slice(e-1,e);if("e"==s||"-"==s||"E"==s)continue;const r=t.substring(0,e),a=Number(r);if(isNaN(a))break;i=e}let s=parseFloat(t);return isNaN(s)&&(s=NaN),e[0]=t.slice(i),s}!function(t){t.CubismJson=L,t.JsonArray=z,t.JsonBoolean=A,t.JsonError=k,t.JsonFloat=D,t.JsonMap=U,t.JsonNullvalue=N,t.JsonString=O,t.Value=T}(G||(G={}));let Y=!1,j=!1,H=null,q=null;const W=Object.freeze({vertexOffset:0,vertexStep:2});function J(t){t&&(t=void 0)}class ${static startUp(t=null){if(Y)return M("CubismFramework.startUp() is already done."),Y;if(H=t,null!=H&&Live2DCubismCore.Logging.csmSetLogFunction(H.logFunction),Y=!0,Y){const t=Live2DCubismCore.Version.csmGetVersion(),e=(16711680&t)>>16,i=65535&t,s=t;M("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+((4278190080&t)>>24)).slice(-2),("00"+e).slice(-2),("0000"+i).slice(-4),s)}return M("CubismFramework.startUp() is complete."),Y}static cleanUp(){Y=!1,j=!1,H=null,q=null}static initialize(t=0){C(Y),Y?j?v("CubismFramework.initialize() skipped, already initialized."):(T.staticInitializeNotForClientCall(),q=new _,Live2DCubismCore.Memory.initializeAmountOfMemory(t),j=!0,M("CubismFramework.initialize() is complete.")):v("CubismFramework is not started.")}static dispose(){C(Y),Y?j?(T.staticReleaseNotForClientCall(),q.release(),q=null,p.staticRelease(),j=!1,M("CubismFramework.dispose() is complete.")):v("CubismFramework.dispose() skipped, not initialized."):v("CubismFramework is not started.")}static isStarted(){return Y}static isInitialized(){return j}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return null!=H?H.loggingLevel:K.LogLevel_Off}static getIdManager(){return q}constructor(){}}class Z{}var K,Q;!function(t){t[t.LogLevel_Verbose=0]="LogLevel_Verbose",t[t.LogLevel_Debug=1]="LogLevel_Debug",t[t.LogLevel_Info=2]="LogLevel_Info",t[t.LogLevel_Warning=3]="LogLevel_Warning",t[t.LogLevel_Error=4]="LogLevel_Error",t[t.LogLevel_Off=5]="LogLevel_Off"}(K||(K={})),function(t){t.Constant=W,t.csmDelete=J,t.CubismFramework=$}(Q||(Q={}));const tt="../../Resources/",et=["Haru","Hiyori","Mark","Natori","Rice","Mao","Wanko"],it=et.length,st="Body",rt=K.LogLevel_Verbose;class at{static loadFileAsBytes(t,e){fetch(t).then((t=>t.arrayBuffer())).then((t=>e(t,t.byteLength)))}static getDeltaTime(){return this.deltaTime}static updateTime(){this.currentFrame=Date.now(),this.deltaTime=(this.currentFrame-this.lastFrame)/1e3,this.lastFrame=this.currentFrame}static printMessage(t){console.trace(t)}}at.lastUpdate=Date.now(),at.currentFrame=0,at.lastFrame=0,at.deltaTime=0;class nt{constructor(){this._gl=null,this._gl=null}initialize(t){return this._gl=t.getContext("webgl2"),!!this._gl||(alert("Cannot initialize WebGL. This browser does not support."),this._gl=null,!1)}release(){}getGl(){return this._gl}}const ot=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:"});var lt,ht,ut,gt,dt,_t,ct;!function(t){t.HitAreaBody=ot.HitAreaBody,t.HitAreaHead=ot.HitAreaHead,t.HitAreaPrefix=ot.HitAreaPrefix,t.ParamAngleX=ot.ParamAngleX,t.ParamAngleY=ot.ParamAngleY,t.ParamAngleZ=ot.ParamAngleZ,t.ParamArmLA=ot.ParamArmLA,t.ParamArmLB=ot.ParamArmLB,t.ParamArmRA=ot.ParamArmRA,t.ParamArmRB=ot.ParamArmRB,t.ParamBaseX=ot.ParamBaseX,t.ParamBaseY=ot.ParamBaseY,t.ParamBodyAngleX=ot.ParamBodyAngleX,t.ParamBodyAngleY=ot.ParamBodyAngleY,t.ParamBodyAngleZ=ot.ParamBodyAngleZ,t.ParamBreath=ot.ParamBreath,t.ParamBrowLAngle=ot.ParamBrowLAngle,t.ParamBrowLForm=ot.ParamBrowLForm,t.ParamBrowLX=ot.ParamBrowLX,t.ParamBrowLY=ot.ParamBrowLY,t.ParamBrowRAngle=ot.ParamBrowRAngle,t.ParamBrowRForm=ot.ParamBrowRForm,t.ParamBrowRX=ot.ParamBrowRX,t.ParamBrowRY=ot.ParamBrowRY,t.ParamBustX=ot.ParamBustX,t.ParamBustY=ot.ParamBustY,t.ParamCheek=ot.ParamCheek,t.ParamEyeBallForm=ot.ParamEyeBallForm,t.ParamEyeBallX=ot.ParamEyeBallX,t.ParamEyeBallY=ot.ParamEyeBallY,t.ParamEyeLOpen=ot.ParamEyeLOpen,t.ParamEyeLSmile=ot.ParamEyeLSmile,t.ParamEyeROpen=ot.ParamEyeROpen,t.ParamEyeRSmile=ot.ParamEyeRSmile,t.ParamHairBack=ot.ParamHairBack,t.ParamHairFluffy=ot.ParamHairFluffy,t.ParamHairFront=ot.ParamHairFront,t.ParamHairSide=ot.ParamHairSide,t.ParamHandL=ot.ParamHandL,t.ParamHandR=ot.ParamHandR,t.ParamMouthForm=ot.ParamMouthForm,t.ParamMouthOpenY=ot.ParamMouthOpenY,t.ParamNONE=ot.ParamNONE,t.ParamShoulderY=ot.ParamShoulderY,t.PartsArmLPrefix=ot.PartsArmLPrefix,t.PartsArmPrefix=ot.PartsArmPrefix,t.PartsArmRPrefix=ot.PartsArmRPrefix,t.PartsIdCore=ot.PartsIdCore}(lt||(lt={}));class mt{}(ht||(ht={})).ICubismModelSetting=mt,function(t){t[t.FrequestNode_Groups=0]="FrequestNode_Groups",t[t.FrequestNode_Moc=1]="FrequestNode_Moc",t[t.FrequestNode_Motions=2]="FrequestNode_Motions",t[t.FrequestNode_Expressions=3]="FrequestNode_Expressions",t[t.FrequestNode_Textures=4]="FrequestNode_Textures",t[t.FrequestNode_Physics=5]="FrequestNode_Physics",t[t.FrequestNode_Pose=6]="FrequestNode_Pose",t[t.FrequestNode_HitAreas=7]="FrequestNode_HitAreas"}(ut||(ut={}));class pt extends mt{constructor(t,i){super(),this.version="Version",this.fileReferences="FileReferences",this.groups="Groups",this.layout="Layout",this.hitAreas="HitAreas",this.moc="Moc",this.textures="Textures",this.physics="Physics",this.pose="Pose",this.expressions="Expressions",this.motions="Motions",this.userData="UserData",this.name="Name",this.filePath="File",this.id="Id",this.ids="Ids",this.target="Target",this.idle="Idle",this.tapBody="TapBody",this.pinchIn="PinchIn",this.pinchOut="PinchOut",this.shake="Shake",this.flickHead="FlickHead",this.parameter="Parameter",this.soundPath="Sound",this.fadeInTime="FadeInTime",this.fadeOutTime="FadeOutTime",this.centerX="CenterX",this.centerY="CenterY",this.x="X",this.y="Y",this.width="Width",this.height="Height",this.lipSync="LipSync",this.eyeBlink="EyeBlink",this.initParameter="init_param",this.initPartsVisible="init_parts_visible",this.val="val",this._json=L.create(t,i),this.getJson()&&(this._jsonValue=new e,this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.groups)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.hitAreas)))}release(){L.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue.at(ut.FrequestNode_Moc).getRawString():""}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue.at(ut.FrequestNode_Textures).getSize():0}getTextureDirectory(){const t=this._jsonValue.at(ut.FrequestNode_Textures).getValueByIndex(0).getRawString().split("/"),e=t.length-1;let i="";for(let s=0;s<e;s++)i+=t[s],s<e-1&&(i+="/");return i}getTextureFileName(t){return this._jsonValue.at(ut.FrequestNode_Textures).getValueByIndex(t).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue.at(ut.FrequestNode_HitAreas).getSize():0}getHitAreaId(t){return $.getIdManager().getId(this._jsonValue.at(ut.FrequestNode_HitAreas).getValueByIndex(t).getValueByString(this.id).getRawString())}getHitAreaName(t){return this._jsonValue.at(ut.FrequestNode_HitAreas).getValueByIndex(t).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue.at(ut.FrequestNode_Physics).getRawString():""}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue.at(ut.FrequestNode_Pose).getRawString():""}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue.at(ut.FrequestNode_Expressions).getSize():0}getExpressionName(t){return this._jsonValue.at(ut.FrequestNode_Expressions).getValueByIndex(t).getValueByString(this.name).getRawString()}getExpressionFileName(t){return this._jsonValue.at(ut.FrequestNode_Expressions).getValueByIndex(t).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue.at(ut.FrequestNode_Motions).getKeys().getSize():0}getMotionGroupName(t){return this.isExistMotionGroups()?this._jsonValue.at(ut.FrequestNode_Motions).getKeys().at(t):null}getMotionCount(t){return this.isExistMotionGroupName(t)?this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getSize():0}getMotionFileName(t,e){return this.isExistMotionGroupName(t)?this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.filePath).getRawString():""}getMotionSoundFileName(t,e){return this.isExistMotionSoundFile(t,e)?this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath).getRawString():""}getMotionFadeInTimeValue(t,e){return this.isExistMotionFadeIn(t,e)?this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(t,e){return this.isExistMotionFadeOut(t,e)?this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():""}getLayoutMap(t){const e=this.getJson().getRoot().getValueByString(this.layout).getMap();if(null==e)return!1;let i=!1;for(const s=e.begin();s.notEqual(e.end());s.preIncrement())t.setValue(s.ptr().first,s.ptr().second.toFloat()),i=!0;return i}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(ut.FrequestNode_Groups).getSize();e++){const i=this._jsonValue.at(ut.FrequestNode_Groups).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.eyeBlink){t=i.getValueByString(this.ids).getVector().getSize();break}}return t}getEyeBlinkParameterId(t){if(!this.isExistEyeBlinkParameters())return null;for(let e=0;e<this._jsonValue.at(ut.FrequestNode_Groups).getSize();e++){const i=this._jsonValue.at(ut.FrequestNode_Groups).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.eyeBlink)return $.getIdManager().getId(i.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(ut.FrequestNode_Groups).getSize();e++){const i=this._jsonValue.at(ut.FrequestNode_Groups).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.lipSync){t=i.getValueByString(this.ids).getVector().getSize();break}}return t}getLipSyncParameterId(t){if(!this.isExistLipSyncParameters())return null;for(let e=0;e<this._jsonValue.at(ut.FrequestNode_Groups).getSize();e++){const i=this._jsonValue.at(ut.FrequestNode_Groups).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.lipSync)return $.getIdManager().getId(i.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}isExistModelFile(){const t=this._jsonValue.at(ut.FrequestNode_Moc);return!t.isNull()&&!t.isError()}isExistTextureFiles(){const t=this._jsonValue.at(ut.FrequestNode_Textures);return!t.isNull()&&!t.isError()}isExistHitAreas(){const t=this._jsonValue.at(ut.FrequestNode_HitAreas);return!t.isNull()&&!t.isError()}isExistPhysicsFile(){const t=this._jsonValue.at(ut.FrequestNode_Physics);return!t.isNull()&&!t.isError()}isExistPoseFile(){const t=this._jsonValue.at(ut.FrequestNode_Pose);return!t.isNull()&&!t.isError()}isExistExpressionFile(){const t=this._jsonValue.at(ut.FrequestNode_Expressions);return!t.isNull()&&!t.isError()}isExistMotionGroups(){const t=this._jsonValue.at(ut.FrequestNode_Motions);return!t.isNull()&&!t.isError()}isExistMotionGroupName(t){const e=this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t);return!e.isNull()&&!e.isError()}isExistMotionSoundFile(t,e){const i=this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath);return!i.isNull()&&!i.isError()}isExistMotionFadeIn(t,e){const i=this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime);return!i.isNull()&&!i.isError()}isExistMotionFadeOut(t,e){const i=this._jsonValue.at(ut.FrequestNode_Motions).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime);return!i.isNull()&&!i.isError()}isExistUserDataFile(){const t=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!t.isNull()&&!t.isError()}isExistEyeBlinkParameters(){if(this._jsonValue.at(ut.FrequestNode_Groups).isNull()||this._jsonValue.at(ut.FrequestNode_Groups).isError())return!1;for(let t=0;t<this._jsonValue.at(ut.FrequestNode_Groups).getSize();++t)if(this._jsonValue.at(ut.FrequestNode_Groups).getValueByIndex(t).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue.at(ut.FrequestNode_Groups).isNull()||this._jsonValue.at(ut.FrequestNode_Groups).isError())return!1;for(let t=0;t<this._jsonValue.at(ut.FrequestNode_Groups).getSize();++t)if(this._jsonValue.at(ut.FrequestNode_Groups).getValueByIndex(t).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}}!function(t){t.CubismModelSettingJson=pt,t.FrequestNode=ut}(gt||(gt={}));class ft{static create(){return new ft}static delete(t){}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=2*this._currentTime*Math.PI;for(let e=0;e<this._breathParameters.getSize();++e){const s=this._breathParameters.at(e);t.addParameterValueById(s.parameterId,s.offset+s.peak*Math.sin(i/s.cycle),s.weight)}}constructor(){this._currentTime=0}}class yt{constructor(t,e,i,s,r){this.parameterId=null==t?null:t,this.offset=null==e?0:e,this.peak=null==i?0:i,this.cycle=null==s?0:s,this.weight=null==r?0:r}}!function(t){t.BreathParameterData=yt,t.CubismBreath=ft}(dt||(dt={}));class St{static create(t=null){return new St(t)}static delete(t){}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,e,i){this._closingSeconds=t,this._closedSeconds=e,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(t,e){let i;this._userTimeSeconds+=e;let s=0;switch(this._blinkingState){case _t.EyeState_Closing:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,s>=1&&(s=1,this._blinkingState=_t.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-s;break;case _t.EyeState_Closed:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,s>=1&&(this._blinkingState=_t.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case _t.EyeState_Opening:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,s>=1&&(s=1,this._blinkingState=_t.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=s;break;case _t.EyeState_Interval:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=_t.EyeState_Closing,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case _t.EyeState_First:default:this._blinkingState=_t.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1}St.CloseIfZero||(i=-i);for(let e=0;e<this._parameterIds.getSize();++e)t.setParameterValueById(this._parameterIds.at(e),i)}constructor(t){if(this._blinkingState=_t.EyeState_First,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new e,null!=t)for(let e=0;e<t.getEyeBlinkParameterCount();++e)this._parameterIds.pushBack(t.getEyeBlinkParameterId(e))}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}}St.CloseIfZero=!0,function(t){t[t.EyeState_First=0]="EyeState_First",t[t.EyeState_Interval=1]="EyeState_Interval",t[t.EyeState_Closing=2]="EyeState_Closing",t[t.EyeState_Closed=3]="EyeState_Closed",t[t.EyeState_Opening=4]="EyeState_Opening"}(_t||(_t={})),function(t){t.CubismEyeBlink=St,t.EyeState=_t}(ct||(ct={}));const Ct="FadeInTime",xt="Link";class Mt{static create(t,e){const i=L.create(t,e);if(!i)return null;const s=new Mt,r=i.getRoot();r.getValueByString(Ct).isNull()||(s._fadeTimeSeconds=r.getValueByString(Ct).toFloat(.5),s._fadeTimeSeconds<0&&(s._fadeTimeSeconds=.5));const a=r.getValueByString("Groups"),n=a.getSize();for(let t=0;t<n;++t){const e=a.getValueByIndex(t),i=e.getSize();let r=0;for(let t=0;t<i;++t){const i=e.getValueByIndex(t),a=new vt,n=$.getIdManager().getId(i.getValueByString("Id").getRawString());if(a.partId=n,!i.getValueByString(xt).isNull()){const t=i.getValueByString(xt),e=t.getSize();for(let i=0;i<e;++i){const e=new vt,s=$.getIdManager().getId(t.getValueByIndex(i).getString());e.partId=s,a.link.pushBack(e)}}s._partGroups.pushBack(a.clone()),++r}s._partGroupCounts.pushBack(r)}return L.delete(i),s}static delete(t){}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let i=0;for(let s=0;s<this._partGroupCounts.getSize();s++){const r=this._partGroupCounts.at(s);this.doFade(t,e,i,r),i+=r}this.copyPartOpacities(t)}reset(t){let e=0;for(let i=0;i<this._partGroupCounts.getSize();++i){const s=this._partGroupCounts.at(i);for(let i=e;i<e+s;++i){this._partGroups.at(i).initialize(t);const s=this._partGroups.at(i).partIndex,r=this._partGroups.at(i).parameterIndex;if(!(s<0)){t.setPartOpacityByIndex(s,i==e?1:0),t.setParameterValueByIndex(r,i==e?1:0);for(let e=0;e<this._partGroups.at(i).link.getSize();++e)this._partGroups.at(i).link.at(e).initialize(t)}}e+=s}}copyPartOpacities(t){for(let e=0;e<this._partGroups.getSize();++e){const i=this._partGroups.at(e);if(0==i.link.getSize())continue;const s=this._partGroups.at(e).partIndex,r=t.getPartOpacityByIndex(s);for(let e=0;e<i.link.getSize();++e){const s=i.link.at(e).partIndex;s<0||t.setPartOpacityByIndex(s,r)}}}doFade(t,e,i,s){let r=-1,a=1;const n=.5;for(let n=i;n<i+s;++n){const i=this._partGroups.at(n).partIndex,s=this._partGroups.at(n).parameterIndex;if(t.getParameterValueByIndex(s)>.001){if(r>=0)break;if(r=n,0==this._fadeTimeSeconds){a=1;continue}a=t.getPartOpacityByIndex(i),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}r<0&&(r=0,a=1);for(let e=i;e<i+s;++e){const i=this._partGroups.at(e).partIndex;if(r==e)t.setPartOpacityByIndex(i,a);else{let e,s=t.getPartOpacityByIndex(i);e=a<n?-.5*a/n+1:(1-a)*n/.5;(1-e)*(1-a)>.15&&(e=1-.15/(1-a)),s>e&&(s=e),t.setPartOpacityByIndex(i,s)}}}constructor(){this._fadeTimeSeconds=.5,this._lastModel=null,this._partGroups=new e,this._partGroupCounts=new e}}class vt{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new e,null!=t){this.partId=t.partId;for(const e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone())}}assignment(t){this.partId=t.partId;for(const e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone());return this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new vt;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new e;for(let e=this.link.begin();e.notEqual(this.link.end());e.increment())t.link.pushBack(e.ptr().clone());return t}}var bt,Pt,Bt,wt;!function(t){t.CubismPose=Mt,t.PartData=vt}(bt||(bt={}));class Ft extends c{constructor(t,e){super(),this._width=void 0!==t?t:0,this._height=void 0!==e?e:0,this.setHeight(2)}setWidth(t){const e=t/this._width,i=e;this.scale(e,i)}setHeight(t){const e=t/this._height,i=e;this.scale(e,i)}setPosition(t,e){this.translate(t,e)}setCenterPosition(t,e){this.centerX(t),this.centerY(e)}top(t){this.setY(t)}bottom(t){const e=this._height*this.getScaleY();this.translateY(t-e)}left(t){this.setX(t)}right(t){const e=this._width*this.getScaleX();this.translateX(t-e)}centerX(t){const e=this._width*this.getScaleX();this.translateX(t-e/2)}setX(t){this.translateX(t)}centerY(t){const e=this._height*this.getScaleY();this.translateY(t-e/2)}setY(t){this.translateY(t)}setupFromLayout(t){for(const e=t.begin();e.notEqual(t.end());e.preIncrement()){const t=e.ptr().first,i=e.ptr().second;"width"==t?this.setWidth(i):"height"==t&&this.setHeight(i)}for(const e=t.begin();e.notEqual(t.end());e.preIncrement()){const t=e.ptr().first,i=e.ptr().second;"x"==t?this.setX(i):"y"==t?this.setY(i):"center_x"==t?this.centerX(i):"center_y"==t?this.centerY(i):"top"==t?this.top(i):"bottom"==t?this.bottom(i):"left"==t?this.left(i):"right"==t&&this.right(i)}}}(Pt||(Pt={})).CubismModelMatrix=Ft;class It{constructor(t,e){this.x=t,this.y=e,this.x=null==t?0:t,this.y=null==e?0:e}add(t){const e=new It(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new It(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new It(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new It(t,t))}division(t){const e=new It(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new It(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(){const 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)}}(Bt||(Bt={})).CubismVector2=It;class Vt{static range(t,e,i){return t<e?t=e: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(0===t)return t;let e=t;const i=e<0;let s;return i&&(e=-e),e===1/0?s=1/0:(s=Math.exp(Math.log(e)/3),s=(e/(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,e){return t>e?t:e}static min(t,e){return t>e?e:t}static clamp(t,e,i){return t<e?e:i<t?i:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return 180*t/Math.PI}static directionToRadian(t,e){let i=Math.atan2(e.y,e.x)-Math.atan2(t.y,t.x);for(;i<-Math.PI;)i+=2*Math.PI;for(;i>Math.PI;)i-=2*Math.PI;return i}static directionToDegrees(t,e){const i=this.directionToRadian(t,e);let s=this.radianToDegrees(i);return e.x-t.x>0&&(s=-s),s}static radianToDirection(t){const e=new It;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(t,e,i){return this.abs(t)<Vt.Epsilon?this.abs(e)<Vt.Epsilon?-i:-i/e:-(e+this.sqrt(e*e-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,e,i,s){if(this.abs(t)<Vt.Epsilon)return this.range(this.quadraticEquation(e,i,s),0,1);const r=e/t,a=i/t,n=(3*a-r*r)/3,o=n/3,l=(2*r*r*r-9*r*a+27*(s/t))/27,h=l/2,u=h*h+o*o*o,g=.5,d=.51;if(u<0){const t=-n/3,e=t*t*t,i=this.sqrt(e),s=-l/(2*i),a=this.range(s,-1,1),o=Math.acos(a),h=2*this.cbrt(i),u=h*this.cos(o/3)-r/3;if(this.abs(u-g)<d)return this.range(u,0,1);const _=h*this.cos((o+2*Math.PI)/3)-r/3;if(this.abs(_-g)<d)return this.range(_,0,1);const c=h*this.cos((o+4*Math.PI)/3)-r/3;return this.range(c,0,1)}if(0==u){let t;t=h<0?this.cbrt(-h):-this.cbrt(h);const e=2*t-r/3;if(this.abs(e-g)<d)return this.range(e,0,1);const i=-t-r/3;return this.range(i,0,1)}const _=this.sqrt(u),c=this.cbrt(_-h)-this.cbrt(_+h)-r/3;return this.range(c,0,1)}static mod(t,e){if(!isFinite(t)||0===e||isNaN(t)||isNaN(e))return console.warn(`divided: ${t}, divisor: ${e} mod() returns 'NaN'.`),NaN;const i=Math.abs(t),s=Math.abs(e);let r=i-Math.floor(i/s)*s;return r*=Math.sign(t),r}constructor(){}}Vt.Epsilon=1e-5,(wt||(wt={})).CubismMath=Vt;class Et{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(t){this._userTimeSeconds+=t;const e=4/30;if(0==this._lastTimeSeconds)return void(this._lastTimeSeconds=this._userTimeSeconds);const i=30*(this._userTimeSeconds-this._lastTimeSeconds);this._lastTimeSeconds=this._userTimeSeconds;const s=i*e/4.5,r=this._faceTargetX-this._faceX,a=this._faceTargetY-this._faceY;if(Vt.abs(r)<=.01&&Vt.abs(a)<=.01)return;const n=Vt.sqrt(r*r+a*a),o=e*a/n;let l=e*r/n-this._faceVX,h=o-this._faceVY;const u=Vt.sqrt(l*l+h*h);(u<-s||u>s)&&(l*=s/u,h*=s/u),this._faceVX+=l,this._faceVY+=h;{const t=.5*(Vt.sqrt(s*s+16*s*n-8*s*n)-s),e=Vt.sqrt(this._faceVX*this._faceVX+this._faceVY*this._faceVY);e>t&&(this._faceVX*=t/e,this._faceVY*=t/e)}this._faceX+=this._faceVX,this._faceY+=this._faceVY}getX(){return this._faceX}getY(){return this._faceY}set(t,e){this._faceTargetX=t,this._faceTargetY=e}}var Rt,Tt;(Rt||(Rt={})).CubismTargetPoint=Et;class Lt{static delete(t){t.release(),t=null}constructor(){this.setBeganMotionHandler=t=>this._onBeganMotion=t,this.getBeganMotionHandler=()=>this._onBeganMotion,this.setFinishedMotionHandler=t=>this._onFinishedMotion=t,this.getFinishedMotionHandler=()=>this._onFinishedMotion,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 e}release(){this._weight=0}updateParameters(t,e,i){if(!e.isAvailable()||e.isFinished())return;this.setupMotionQueueEntry(e,i);const s=this.updateFadeWeight(e,i);this.doUpdateParameters(t,i,s,e),e.getEndTime()>0&&e.getEndTime()<i&&e.setIsFinished(!0)}setupMotionQueueEntry(t,e){null==t||t.isStarted()||t.isAvailable()&&(t.setIsStarted(!0),t.setStartTime(e-this._offsetSeconds),t.setFadeInStartTime(e),t.getEndTime()<0&&this.adjustEndTime(t),t._motion._onBeganMotion&&t._motion._onBeganMotion(t._motion))}updateFadeWeight(t,e){null==t&&P.print(K.LogLevel_Error,"motionQueueEntry is null.");let i=this._weight;return i=i*(0==this._fadeInSeconds?1:Vt.getEasingSine((e-t.getFadeInStartTime())/this._fadeInSeconds))*(0==this._fadeOutSeconds||t.getEndTime()<0?1:Vt.getEasingSine((t.getEndTime()-e)/this._fadeOutSeconds)),t.setState(e,i),C(0<=i&&i<=1),i}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}setLoop(t){this._isLoop=t}getLoop(){return this._isLoop}setLoopFadeIn(t){this._isLoopFadeIn=t}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(t,e){return this._firedEventValues}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){return null}getModelOpacityValue(){return 1}adjustEndTime(t){const e=this.getDuration(),i=e<=0?-1:t.getStartTime()+e;t.setEndTime(i)}}(Tt||(Tt={})).ACubismMotion=Lt;const Dt="Parameters",At="Blend";class Ot extends Lt{static create(t,e){const i=new Ot;return i.parse(t,e),i}doUpdateParameters(t,e,i,s){for(let e=0;e<this._parameters.getSize();++e){const s=this._parameters.at(e);switch(s.blendType){case kt.Additive:t.addParameterValueById(s.parameterId,s.value,i);break;case kt.Multiply:t.multiplyParameterValueById(s.parameterId,s.value,i);break;case kt.Overwrite:t.setParameterValueById(s.parameterId,s.value,i)}}}calculateExpressionParameters(t,e,i,s,r,a){if(null!=i&&null!=s&&i.isAvailable()){this._fadeWeight=this.updateFadeWeight(i,e);for(let e=0;e<s.getSize();++e){const i=s.at(e);if(null==i.parameterId)continue;const n=i.overwriteValue=t.getParameterValueById(i.parameterId),o=this.getExpressionParameters();let l=-1;for(let t=0;t<o.getSize();++t)if(i.parameterId==o.at(t).parameterId){l=t;break}if(l<0){0==r?(i.additiveValue=Ot.DefaultAdditiveValue,i.multiplyValue=Ot.DefaultMultiplyValue,i.overwriteValue=n):(i.additiveValue=this.calculateValue(i.additiveValue,Ot.DefaultAdditiveValue,a),i.multiplyValue=this.calculateValue(i.multiplyValue,Ot.DefaultMultiplyValue,a),i.overwriteValue=this.calculateValue(i.overwriteValue,n,a));continue}const h=o.at(l).value;let u,g,d;switch(o.at(l).blendType){case kt.Additive:u=h,g=Ot.DefaultMultiplyValue,d=n;break;case kt.Multiply:u=Ot.DefaultAdditiveValue,g=h,d=n;break;case kt.Overwrite:u=Ot.DefaultAdditiveValue,g=Ot.DefaultMultiplyValue,d=h;break;default:return}0==r?(i.additiveValue=u,i.multiplyValue=g,i.overwriteValue=d):(i.additiveValue=i.additiveValue*(1-a)+u*a,i.multiplyValue=i.multiplyValue*(1-a)+g*a,i.overwriteValue=i.overwriteValue*(1-a)+d*a)}}}getExpressionParameters(){return this._param