@galacean/engine-spine 0.0.0-experimental-engine-spine-caifu.0 → 0.0.0-experimental-engine-spine-caifu.1
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/dist/browser.js +29 -1
- package/dist/main.js +29 -1
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +29 -1
- package/dist/module.js +29 -1
- package/dist/module.js.map +1 -1
- package/package.json +2 -3
package/dist/browser.js
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.Spine={}),t.Galacean)}(this,(function(t,e){"use strict";function s(t,e,s,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,s,i);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(a=(r<3?n(a):r>3?n(e,s,a):n(e,s))||a);return r>3&&a&&Object.defineProperty(e,s,a),a}"function"==typeof SuppressedError&&SuppressedError;class i{entries={};size=0;add(t){let e=this.entries[t];return this.entries[t]=!0,!e&&(this.size++,!0)}addAll(t){let e=this.size;for(var s=0,i=t.length;s<i;s++)this.add(t[s]);return e!=this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}}class n{r;g;b;a;static WHITE=new n(1,1,1,1);static RED=new n(1,0,0,1);static GREEN=new n(0,1,0,1);static BLUE=new n(0,0,1,1);static MAGENTA=new n(1,0,1,1);constructor(t=0,e=0,s=0,i=0){this.r=t,this.g=e,this.b=s,this.a=i}set(t,e,s,i){return this.r=t,this.g=e,this.b=s,this.a=i,this.clamp()}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=8!=t.length?1:parseInt(t.substr(6,2),16)/255,this}add(t,e,s,i){return this.r+=t,this.g+=e,this.b+=s,this.a+=i,this.clamp()}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(t,e){t.r=((4278190080&e)>>>24)/255,t.g=((16711680&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255}static rgb888ToColor(t,e){t.r=((16711680&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255}toRgb888(){const t=t=>("0"+(255*t).toString(16)).slice(-2);return Number("0x"+t(this.r)+t(this.g)+t(this.b))}static fromString(t){return(new n).setFromString(t)}}class r{static PI=3.1415927;static PI2=2*r.PI;static invPI2=1/r.PI2;static radiansToDegrees=180/r.PI;static radDeg=r.radiansToDegrees;static degreesToRadians=r.PI/180;static degRad=r.degreesToRadians;static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(t){return Math.cos(t*r.degRad)}static sinDeg(t){return Math.sin(t*r.degRad)}static atan2Deg(t,e){return Math.atan2(t,e)*r.degRad}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){let e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(t,e){return r.randomTriangularWith(t,e,.5*(t+e))}static randomTriangularWith(t,e,s){let i=Math.random(),n=e-t;return i<=(s-t)/n?t+Math.sqrt(i*n*(s-t)):e-Math.sqrt((1-i)*n*(e-s))}static isPowerOfTwo(t){return t&&!(t&t-1)}}class a{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class o extends a{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow(2*(t-1),this.power)/(this.power%2==0?-2:2)+1}}class l{static SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array;static arrayCopy(t,e,s,i,n){for(let r=e,a=i;r<e+n;r++,a++)s[a]=t[r]}static arrayFill(t,e,s,i){for(let n=e;n<s;n++)t[n]=i}static setArraySize(t,e,s=0){let i=t.length;if(i==e)return t;if(t.length=e,i<e)for(let n=i;n<e;n++)t[n]=s;return t}static ensureArrayCapacity(t,e,s=0){return t.length>=e?t:l.setArraySize(t,e,s)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(t){if(l.SUPPORTS_TYPED_ARRAYS)return new Float32Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static newShortArray(t){if(l.SUPPORTS_TYPED_ARRAYS)return new Int16Array(t);{let e=new Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static toFloatArray(t){return l.SUPPORTS_TYPED_ARRAYS?new Float32Array(t):t}static toSinglePrecision(t){return l.SUPPORTS_TYPED_ARRAYS?Math.fround(t):t}static webkit602BugfixHelper(t,e){}static contains(t,e,s=!0){for(var i=0;i<t.length;i++)if(t[i]==e)return!0;return!1}static enumValue(t,e){return t[e[0].toUpperCase()+e.slice(1)]}}class h{items=new Array;instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&t.reset(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)this.free(t[e])}clear(){this.items.length=0}}class c{x;y;constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class d{name;constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}}class u extends d{static nextID=0;id=u.nextID++;bones=null;vertices=[];worldVerticesLength=0;timelineAttachment=this;constructor(t){super(t)}computeWorldVertices(t,e,s,i,n,r){s=n+(s>>1)*r;let a=t.bone.skeleton,o=t.deform,l=this.vertices,h=this.bones;if(!h){o.length>0&&(l=o);let a=t.bone,h=a.worldX,c=a.worldY,d=a.a,u=a.b,m=a.c,f=a.d;for(let t=e,a=n;a<s;t+=2,a+=r){let e=l[t],s=l[t+1];i[a]=e*d+s*u+h,i[a+1]=e*m+s*f+c}return}let c=0,d=0;for(let t=0;t<e;t+=2){let t=h[c];c+=t+1,d+=t}let u=a.bones;if(0==o.length)for(let t=n,e=3*d;t<s;t+=r){let s=0,n=0,r=h[c++];for(r+=c;c<r;c++,e+=3){let t=u[h[c]],i=l[e],r=l[e+1],a=l[e+2];s+=(i*t.a+r*t.b+t.worldX)*a,n+=(i*t.c+r*t.d+t.worldY)*a}i[t]=s,i[t+1]=n}else{let t=o;for(let e=n,a=3*d,o=d<<1;e<s;e+=r){let s=0,n=0,r=h[c++];for(r+=c;c<r;c++,a+=3,o+=2){let e=u[h[c]],i=l[a]+t[o],r=l[a+1]+t[o+1],d=l[a+2];s+=(i*e.a+r*e.b+e.worldX)*d,n+=(i*e.c+r*e.d+e.worldY)*d}i[e]=s,i[e+1]=n}}}copyTo(t){this.bones?(t.bones=new Array(this.bones.length),l.arrayCopy(this.bones,0,t.bones,0,this.bones.length)):t.bones=null,this.vertices&&(t.vertices=l.newFloatArray(this.vertices.length),l.arrayCopy(this.vertices,0,t.vertices,0,this.vertices.length)),t.worldVerticesLength=this.worldVerticesLength,t.timelineAttachment=this.timelineAttachment}}class m{static _nextID=0;id=m.nextID();regions;start=0;digits=0;setupIndex=0;constructor(t){this.regions=new Array(t)}copy(){let t=new m(this.regions.length);return l.arrayCopy(this.regions,0,t.regions,0,this.regions.length),t.start=this.start,t.digits=this.digits,t.setupIndex=this.setupIndex,t}apply(t,e){let s=t.sequenceIndex;-1==s&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1);let i=this.regions[s];e.region!=i&&(e.region=i,e.updateRegion())}getPath(t,e){let s=t,i=(this.start+e).toString();for(let t=this.digits-i.length;t>0;t--)s+="0";return s+=i,s}static nextID(){return m._nextID++}}var f;!function(t){t[t.hold=0]="hold",t[t.once=1]="once",t[t.loop=2]="loop",t[t.pingpong=3]="pingpong",t[t.onceReverse=4]="onceReverse",t[t.loopReverse=5]="loopReverse",t[t.pingpongReverse=6]="pingpongReverse"}(f||(f={}));const p=[f.hold,f.once,f.loop,f.pingpong,f.onceReverse,f.loopReverse,f.pingpongReverse];class g{name;timelines=[];timelineIds=new i;duration;constructor(t,e,s){if(!t)throw new Error("name cannot be null.");this.name=t,this.setTimelines(e),this.duration=s}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t,this.timelineIds.clear();for(var e=0;e<t.length;e++)this.timelineIds.addAll(t[e].getPropertyIds())}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,s,i,n,r,a,o){if(!t)throw new Error("skeleton cannot be null.");i&&0!=this.duration&&(s%=this.duration,e>0&&(e%=this.duration));let l=this.timelines;for(let i=0,h=l.length;i<h;i++)l[i].apply(t,e,s,n,r,a,o)}}var x,w;t.MixBlend=void 0,(x=t.MixBlend||(t.MixBlend={}))[x.setup=0]="setup",x[x.first=1]="first",x[x.replace=2]="replace",x[x.add=3]="add",t.MixDirection=void 0,(w=t.MixDirection||(t.MixDirection={}))[w.mixIn=0]="mixIn",w[w.mixOut=1]="mixOut";const b={rotate:0,x:1,y:2,scaleX:3,scaleY:4,shearX:5,shearY:6,inherit:7,rgb:8,alpha:9,rgb2:10,attachment:11,deform:12,event:13,drawOrder:14,ikConstraint:15,transformConstraint:16,pathConstraintPosition:17,pathConstraintSpacing:18,pathConstraintMix:19,physicsConstraintInertia:20,physicsConstraintStrength:21,physicsConstraintDamping:22,physicsConstraintMass:23,physicsConstraintWind:24,physicsConstraintGravity:25,physicsConstraintMix:26,physicsConstraintReset:27,sequence:28};class y{propertyIds;frames;constructor(t,e){this.propertyIds=e,this.frames=l.newFloatArray(t*this.getFrameEntries())}getPropertyIds(){return this.propertyIds}getFrameEntries(){return 1}getFrameCount(){return this.frames.length/this.getFrameEntries()}getDuration(){return this.frames[this.frames.length-this.getFrameEntries()]}static search1(t,e){let s=t.length;for(let i=1;i<s;i++)if(t[i]>e)return i-1;return s-1}static search(t,e,s){let i=t.length;for(let n=s;n<i;n+=s)if(t[n]>e)return n-s;return i-s}}class M extends y{curves;constructor(t,e,s){super(t,s),this.curves=l.newFloatArray(t+18*e),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){let e=this.getFrameCount()+18*t;if(this.curves.length>e){let t=l.newFloatArray(e);l.arrayCopy(this.curves,0,t,0,e),this.curves=t}}setBezier(t,e,s,i,n,r,a,o,l,h,c){let d=this.curves,u=this.getFrameCount()+18*t;0==s&&(d[e]=2+u);let m=.03*(i-2*r+o),f=.03*(n-2*a+l),p=.006*(3*(r-o)-i+h),g=.006*(3*(a-l)-n+c),x=2*m+p,w=2*f+g,b=.3*(r-i)+m+.16666667*p,y=.3*(a-n)+f+.16666667*g,M=i+b,S=n+y;for(let t=u+18;u<t;u+=2)d[u]=M,d[u+1]=S,b+=x,y+=w,x+=p,w+=g,M+=b,S+=y}getBezierValue(t,e,s,i){let n=this.curves;if(n[i]>t){let r=this.frames[e],a=this.frames[e+s];return a+(t-r)/(n[i]-r)*(n[i+1]-a)}let r=i+18;for(i+=2;i<r;i+=2)if(n[i]>=t){let e=n[i-2],s=n[i-1];return s+(t-e)/(n[i]-e)*(n[i+1]-s)}e+=this.getFrameEntries();let a=n[r-2],o=n[r-1];return o+(t-a)/(this.frames[e]-a)*(this.frames[e+s]-o)}}class S extends M{constructor(t,e,s){super(t,e,[s])}getFrameEntries(){return 2}setFrame(t,e,s){t<<=1,this.frames[t]=e,this.frames[t+1]=s}getCurveValue(t){let e=this.frames,s=e.length-2;for(let i=2;i<=s;i+=2)if(e[i]>t){s=i-2;break}let i=this.curves[s>>1];switch(i){case 0:let i=e[s],n=e[s+1];return n+(t-i)/(e[s+2]-i)*(e[s+2+1]-n);case 1:return e[s+1]}return this.getBezierValue(t,s,1,i-2)}getRelativeValue(e,s,i,n,r){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return r;case t.MixBlend.first:return n+(r-n)*s}return n}let a=this.getCurveValue(e);switch(i){case t.MixBlend.setup:return r+a*s;case t.MixBlend.first:case t.MixBlend.replace:a+=r-n}return n+a*s}getAbsoluteValue(e,s,i,n,r){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return r;case t.MixBlend.first:return n+(r-n)*s}return n}let a=this.getCurveValue(e);return i==t.MixBlend.setup?r+(a-r)*s:n+(a-n)*s}getAbsoluteValue2(e,s,i,n,r,a){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return r;case t.MixBlend.first:return n+(r-n)*s}return n}return i==t.MixBlend.setup?r+(a-r)*s:n+(a-n)*s}getScaleValue(e,s,i,n,a,o){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return o;case t.MixBlend.first:return a+(o-a)*s}return a}let l=this.getCurveValue(e)*o;if(1==s)return i==t.MixBlend.add?a+l-o:l;if(n==t.MixDirection.mixOut)switch(i){case t.MixBlend.setup:return o+(Math.abs(l)*r.signum(o)-o)*s;case t.MixBlend.first:case t.MixBlend.replace:return a+(Math.abs(l)*r.signum(a)-a)*s}else{let e=0;switch(i){case t.MixBlend.setup:return e=Math.abs(o)*r.signum(l),e+(l-e)*s;case t.MixBlend.first:case t.MixBlend.replace:return e=Math.abs(a)*r.signum(l),e+(l-e)*s}}return a+(l-o)*s}}class v extends M{constructor(t,e,s,i){super(t,e,[s,i])}getFrameEntries(){return 3}setFrame(t,e,s,i){t*=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i}}class k extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.rotate+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.rotation=this.getRelativeValue(s,n,r,o.rotation,o.data.rotation))}}class I extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.x+"|"+s,b.y+"|"+s),this.boneIndex=s}apply(e,s,i,n,r,a,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(a){case t.MixBlend.setup:return l.x=l.data.x,void(l.y=l.data.y);case t.MixBlend.first:l.x+=(l.data.x-l.x)*r,l.y+=(l.data.y-l.y)*r}return}let c=0,d=0,u=y.search(h,i,3),m=this.curves[u/3];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+3]-t);c+=(h[u+3+1]-c)*e,d+=(h[u+3+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}switch(a){case t.MixBlend.setup:l.x=l.data.x+c*r,l.y=l.data.y+d*r;break;case t.MixBlend.first:case t.MixBlend.replace:l.x+=(l.data.x+c-l.x)*r,l.y+=(l.data.y+d-l.y)*r;break;case t.MixBlend.add:l.x+=c*r,l.y+=d*r}}}class A extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.x+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.x=this.getRelativeValue(s,n,r,o.x,o.data.x))}}class T extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.y+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.y=this.getRelativeValue(s,n,r,o.y,o.data.y))}}class B extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleX+"|"+s,b.scaleY+"|"+s),this.boneIndex=s}apply(e,s,i,n,a,o,l){let h=e.bones[this.boneIndex];if(!h.active)return;let c,d,u=this.frames;if(i<u[0]){switch(o){case t.MixBlend.setup:return h.scaleX=h.data.scaleX,void(h.scaleY=h.data.scaleY);case t.MixBlend.first:h.scaleX+=(h.data.scaleX-h.scaleX)*a,h.scaleY+=(h.data.scaleY-h.scaleY)*a}return}let m=y.search(u,i,3),f=this.curves[m/3];switch(f){case 0:let t=u[m];c=u[m+1],d=u[m+2];let e=(i-t)/(u[m+3]-t);c+=(u[m+3+1]-c)*e,d+=(u[m+3+2]-d)*e;break;case 1:c=u[m+1],d=u[m+2];break;default:c=this.getBezierValue(i,m,1,f-2),d=this.getBezierValue(i,m,2,f+18-2)}if(c*=h.data.scaleX,d*=h.data.scaleY,1==a)o==t.MixBlend.add?(h.scaleX+=c-h.data.scaleX,h.scaleY+=d-h.data.scaleY):(h.scaleX=c,h.scaleY=d);else{let e=0,s=0;if(l==t.MixDirection.mixOut)switch(o){case t.MixBlend.setup:e=h.data.scaleX,s=h.data.scaleY,h.scaleX=e+(Math.abs(c)*r.signum(e)-e)*a,h.scaleY=s+(Math.abs(d)*r.signum(s)-s)*a;break;case t.MixBlend.first:case t.MixBlend.replace:e=h.scaleX,s=h.scaleY,h.scaleX=e+(Math.abs(c)*r.signum(e)-e)*a,h.scaleY=s+(Math.abs(d)*r.signum(s)-s)*a;break;case t.MixBlend.add:h.scaleX+=(c-h.data.scaleX)*a,h.scaleY+=(d-h.data.scaleY)*a}else switch(o){case t.MixBlend.setup:e=Math.abs(h.data.scaleX)*r.signum(c),s=Math.abs(h.data.scaleY)*r.signum(d),h.scaleX=e+(c-e)*a,h.scaleY=s+(d-s)*a;break;case t.MixBlend.first:case t.MixBlend.replace:e=Math.abs(h.scaleX)*r.signum(c),s=Math.abs(h.scaleY)*r.signum(d),h.scaleX=e+(c-e)*a,h.scaleY=s+(d-s)*a;break;case t.MixBlend.add:h.scaleX+=(c-h.data.scaleX)*a,h.scaleY+=(d-h.data.scaleY)*a}}}}class C extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleX+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.scaleX=this.getScaleValue(s,n,r,a,o.scaleX,o.data.scaleX))}}class F extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.scaleY+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.scaleY=this.getScaleValue(s,n,r,a,o.scaleY,o.data.scaleY))}}class E extends v{boneIndex=0;constructor(t,e,s){super(t,e,b.shearX+"|"+s,b.shearY+"|"+s),this.boneIndex=s}apply(e,s,i,n,r,a,o){let l=e.bones[this.boneIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(a){case t.MixBlend.setup:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case t.MixBlend.first:l.shearX+=(l.data.shearX-l.shearX)*r,l.shearY+=(l.data.shearY-l.shearY)*r}return}let c=0,d=0,u=y.search(h,i,3),m=this.curves[u/3];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+3]-t);c+=(h[u+3+1]-c)*e,d+=(h[u+3+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}switch(a){case t.MixBlend.setup:l.shearX=l.data.shearX+c*r,l.shearY=l.data.shearY+d*r;break;case t.MixBlend.first:case t.MixBlend.replace:l.shearX+=(l.data.shearX+c-l.shearX)*r,l.shearY+=(l.data.shearY+d-l.shearY)*r;break;case t.MixBlend.add:l.shearX+=c*r,l.shearY+=d*r}}}class Y extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.shearX+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.shearX=this.getRelativeValue(s,n,r,o.shearX,o.data.shearX))}}class R extends S{boneIndex=0;constructor(t,e,s){super(t,e,b.shearY+"|"+s),this.boneIndex=s}apply(t,e,s,i,n,r,a){let o=t.bones[this.boneIndex];o.active&&(o.shearY=this.getRelativeValue(s,n,r,o.shearY,o.data.shearY))}}class P extends y{boneIndex=0;constructor(t,e){super(t,[b.inherit+"|"+e]),this.boneIndex=e}getFrameEntries(){return 2}setFrame(t,e,s){t*=2,this.frames[t]=e,this.frames[t+1]=s}apply(e,s,i,n,r,a,o){let l=e.bones[this.boneIndex];if(!l.active)return;if(o==t.MixDirection.mixOut)return void(a==t.MixBlend.setup&&(l.inherit=l.data.inherit));let h=this.frames;i<h[0]?a!=t.MixBlend.setup&&a!=t.MixBlend.first||(l.inherit=l.data.inherit):l.inherit=this.frames[y.search(h,i,2)+1]}}class X extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.alpha+"|"+s]),this.slotIndex=s}getFrameEntries(){return 5}setFrame(t,e,s,i,n,r){t*=5,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=r}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color;if(i<h[0]){let e=l.data.color;switch(a){case t.MixBlend.setup:return void c.setFromColor(e);case t.MixBlend.first:c.add((e.r-c.r)*r,(e.g-c.g)*r,(e.b-c.b)*r,(e.a-c.a)*r)}return}let d=0,u=0,m=0,f=0,p=y.search(h,i,5),g=this.curves[p/5];switch(g){case 0:let t=h[p];d=h[p+1],u=h[p+2],m=h[p+3],f=h[p+4];let e=(i-t)/(h[p+5]-t);d+=(h[p+5+1]-d)*e,u+=(h[p+5+2]-u)*e,m+=(h[p+5+3]-m)*e,f+=(h[p+5+4]-f)*e;break;case 1:d=h[p+1],u=h[p+2],m=h[p+3],f=h[p+4];break;default:d=this.getBezierValue(i,p,1,g-2),u=this.getBezierValue(i,p,2,g+18-2),m=this.getBezierValue(i,p,3,g+36-2),f=this.getBezierValue(i,p,4,g+54-2)}1==r?c.set(d,u,m,f):(a==t.MixBlend.setup&&c.setFromColor(l.data.color),c.add((d-c.r)*r,(u-c.g)*r,(m-c.b)*r,(f-c.a)*r))}}class _ extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s]),this.slotIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,n){t<<=2,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color;if(i<h[0]){let e=l.data.color;switch(a){case t.MixBlend.setup:return c.r=e.r,c.g=e.g,void(c.b=e.b);case t.MixBlend.first:c.r+=(e.r-c.r)*r,c.g+=(e.g-c.g)*r,c.b+=(e.b-c.b)*r}return}let d=0,u=0,m=0,f=y.search(h,i,4),p=this.curves[f>>2];switch(p){case 0:let t=h[f];d=h[f+1],u=h[f+2],m=h[f+3];let e=(i-t)/(h[f+4]-t);d+=(h[f+4+1]-d)*e,u+=(h[f+4+2]-u)*e,m+=(h[f+4+3]-m)*e;break;case 1:d=h[f+1],u=h[f+2],m=h[f+3];break;default:d=this.getBezierValue(i,f,1,p-2),u=this.getBezierValue(i,f,2,p+18-2),m=this.getBezierValue(i,f,3,p+36-2)}if(1==r)c.r=d,c.g=u,c.b=m;else{if(a==t.MixBlend.setup){let t=l.data.color;c.r=t.r,c.g=t.g,c.b=t.b}c.r+=(d-c.r)*r,c.g+=(u-c.g)*r,c.b+=(m-c.b)*r}}}class V extends S{slotIndex=0;constructor(t,e,s){super(t,e,b.alpha+"|"+s),this.slotIndex=s}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=l.color;if(i<this.frames[0]){let e=l.data.color;switch(a){case t.MixBlend.setup:return void(h.a=e.a);case t.MixBlend.first:h.a+=(e.a-h.a)*r}return}let c=this.getCurveValue(i);1==r?h.a=c:(a==t.MixBlend.setup&&(h.a=l.data.color.a),h.a+=(c-h.a)*r)}}class D extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.alpha+"|"+s,b.rgb2+"|"+s]),this.slotIndex=s}getFrameEntries(){return 8}setFrame(t,e,s,i,n,r,a,o,l){t<<=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=r,this.frames[t+5]=a,this.frames[t+6]=o,this.frames[t+7]=l}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color,d=l.darkColor;if(i<h[0]){let e=l.data.color,s=l.data.darkColor;switch(a){case t.MixBlend.setup:return c.setFromColor(e),d.r=s.r,d.g=s.g,void(d.b=s.b);case t.MixBlend.first:c.add((e.r-c.r)*r,(e.g-c.g)*r,(e.b-c.b)*r,(e.a-c.a)*r),d.r+=(s.r-d.r)*r,d.g+=(s.g-d.g)*r,d.b+=(s.b-d.b)*r}return}let u=0,m=0,f=0,p=0,g=0,x=0,w=0,b=y.search(h,i,8),M=this.curves[b>>3];switch(M){case 0:let t=h[b];u=h[b+1],m=h[b+2],f=h[b+3],p=h[b+4],g=h[b+5],x=h[b+6],w=h[b+7];let e=(i-t)/(h[b+8]-t);u+=(h[b+8+1]-u)*e,m+=(h[b+8+2]-m)*e,f+=(h[b+8+3]-f)*e,p+=(h[b+8+4]-p)*e,g+=(h[b+8+5]-g)*e,x+=(h[b+8+6]-x)*e,w+=(h[b+8+7]-w)*e;break;case 1:u=h[b+1],m=h[b+2],f=h[b+3],p=h[b+4],g=h[b+5],x=h[b+6],w=h[b+7];break;default:u=this.getBezierValue(i,b,1,M-2),m=this.getBezierValue(i,b,2,M+18-2),f=this.getBezierValue(i,b,3,M+36-2),p=this.getBezierValue(i,b,4,M+54-2),g=this.getBezierValue(i,b,5,M+72-2),x=this.getBezierValue(i,b,6,M+90-2),w=this.getBezierValue(i,b,7,M+108-2)}if(1==r)c.set(u,m,f,p),d.r=g,d.g=x,d.b=w;else{if(a==t.MixBlend.setup){c.setFromColor(l.data.color);let t=l.data.darkColor;d.r=t.r,d.g=t.g,d.b=t.b}c.add((u-c.r)*r,(m-c.g)*r,(f-c.b)*r,(p-c.a)*r),d.r+=(g-d.r)*r,d.g+=(x-d.g)*r,d.b+=(w-d.b)*r}}}class O extends M{slotIndex=0;constructor(t,e,s){super(t,e,[b.rgb+"|"+s,b.rgb2+"|"+s]),this.slotIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,n,r,a,o){t*=7,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=r,this.frames[t+5]=a,this.frames[t+6]=o}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=this.frames,c=l.color,d=l.darkColor;if(i<h[0]){let e=l.data.color,s=l.data.darkColor;switch(a){case t.MixBlend.setup:return c.r=e.r,c.g=e.g,c.b=e.b,d.r=s.r,d.g=s.g,void(d.b=s.b);case t.MixBlend.first:c.r+=(e.r-c.r)*r,c.g+=(e.g-c.g)*r,c.b+=(e.b-c.b)*r,d.r+=(s.r-d.r)*r,d.g+=(s.g-d.g)*r,d.b+=(s.b-d.b)*r}return}let u=0,m=0,f=0,p=0,g=0,x=0,w=y.search(h,i,7),b=this.curves[w/7];switch(b){case 0:let t=h[w];u=h[w+1],m=h[w+2],f=h[w+3],p=h[w+4],g=h[w+5],x=h[w+6];let e=(i-t)/(h[w+7]-t);u+=(h[w+7+1]-u)*e,m+=(h[w+7+2]-m)*e,f+=(h[w+7+3]-f)*e,p+=(h[w+7+4]-p)*e,g+=(h[w+7+5]-g)*e,x+=(h[w+7+6]-x)*e;break;case 1:u=h[w+1],m=h[w+2],f=h[w+3],p=h[w+4],g=h[w+5],x=h[w+6];break;default:u=this.getBezierValue(i,w,1,b-2),m=this.getBezierValue(i,w,2,b+18-2),f=this.getBezierValue(i,w,3,b+36-2),p=this.getBezierValue(i,w,4,b+54-2),g=this.getBezierValue(i,w,5,b+72-2),x=this.getBezierValue(i,w,6,b+90-2)}if(1==r)c.r=u,c.g=m,c.b=f,d.r=p,d.g=g,d.b=x;else{if(a==t.MixBlend.setup){let t=l.data.color,e=l.data.darkColor;c.r=t.r,c.g=t.g,c.b=t.b,d.r=e.r,d.g=e.g,d.b=e.b}c.r+=(u-c.r)*r,c.g+=(m-c.g)*r,c.b+=(f-c.b)*r,d.r+=(p-d.r)*r,d.g+=(g-d.g)*r,d.b+=(x-d.b)*r}}}class N extends y{slotIndex=0;attachmentNames;constructor(t,e){super(t,[b.attachment+"|"+e]),this.slotIndex=e,this.attachmentNames=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];l.bone.active&&(o!=t.MixDirection.mixOut?i<this.frames[0]?a!=t.MixBlend.setup&&a!=t.MixBlend.first||this.setAttachment(e,l,l.data.attachmentName):this.setAttachment(e,l,this.attachmentNames[y.search1(this.frames,i)]):a==t.MixBlend.setup&&this.setAttachment(e,l,l.data.attachmentName))}setAttachment(t,e,s){e.setAttachment(s?t.getAttachment(this.slotIndex,s):null)}}class L extends M{slotIndex=0;attachment;vertices;constructor(t,e,s,i){super(t,e,[b.deform+"|"+s+"|"+i.id]),this.slotIndex=s,this.attachment=i,this.vertices=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.vertices[t]=s}setBezier(t,e,s,i,n,r,a,o,l,h,c){let d=this.curves,u=this.getFrameCount()+18*t;0==s&&(d[e]=2+u);let m=.03*(i-2*r+o),f=.03*l-.06*a,p=.006*(3*(r-o)-i+h),g=.018*(a-l+.33333333),x=2*m+p,w=2*f+g,b=.3*(r-i)+m+.16666667*p,y=.3*a+f+.16666667*g,M=i+b,S=y;for(let t=u+18;u<t;u+=2)d[u]=M,d[u+1]=S,b+=x,y+=w,x+=p,w+=g,M+=b,S+=y}getCurvePercent(t,e){let s=this.curves,i=s[e];switch(i){case 0:let s=this.frames[e];return(t-s)/(this.frames[e+this.getFrameEntries()]-s);case 1:return 0}if(i-=2,s[i]>t){let n=this.frames[e];return s[i+1]*(t-n)/(s[i]-n)}let n=i+18;for(i+=2;i<n;i+=2)if(s[i]>=t){let e=s[i-2],n=s[i-1];return n+(t-e)/(s[i]-e)*(s[i+1]-n)}let r=s[n-2],a=s[n-1];return a+(1-a)*(t-r)/(this.frames[e+this.getFrameEntries()]-r)}apply(e,s,i,n,r,a,o){let h=e.slots[this.slotIndex];if(!h.bone.active)return;let c=h.getAttachment();if(!c)return;if(!(c instanceof u)||c.timelineAttachment!=this.attachment)return;let d=h.deform;0==d.length&&(a=t.MixBlend.setup);let m=this.vertices,f=m[0].length,p=this.frames;if(i<p[0]){switch(a){case t.MixBlend.setup:return void(d.length=0);case t.MixBlend.first:if(1==r)return void(d.length=0);d.length=f;let e=c;if(e.bones){r=1-r;for(g=0;g<f;g++)d[g]*=r}else{let t=e.vertices;for(var g=0;g<f;g++)d[g]+=(t[g]-d[g])*r}}return}if(d.length=f,i>=p[p.length-1]){let e=m[p.length-1];if(1==r)if(a==t.MixBlend.add){let t=c;if(t.bones)for(let t=0;t<f;t++)d[t]+=e[t];else{let s=t.vertices;for(let t=0;t<f;t++)d[t]+=e[t]-s[t]}}else l.arrayCopy(e,0,d,0,f);else switch(a){case t.MixBlend.setup:{let t=c;if(t.bones)for(let t=0;t<f;t++)d[t]=e[t]*r;else{let s=t.vertices;for(let t=0;t<f;t++){let i=s[t];d[t]=i+(e[t]-i)*r}}break}case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<f;t++)d[t]+=(e[t]-d[t])*r;break;case t.MixBlend.add:let s=c;if(s.bones)for(let t=0;t<f;t++)d[t]+=e[t]*r;else{let t=s.vertices;for(let s=0;s<f;s++)d[s]+=(e[s]-t[s])*r}}return}let x=y.search1(p,i),w=this.getCurvePercent(i,x),b=m[x],M=m[x+1];if(1==r)if(a==t.MixBlend.add){let t=c;if(t.bones)for(let t=0;t<f;t++){let e=b[t];d[t]+=e+(M[t]-e)*w}else{let e=t.vertices;for(let t=0;t<f;t++){let s=b[t];d[t]+=s+(M[t]-s)*w-e[t]}}}else for(let t=0;t<f;t++){let e=b[t];d[t]=e+(M[t]-e)*w}else switch(a){case t.MixBlend.setup:{let t=c;if(t.bones)for(let t=0;t<f;t++){let e=b[t];d[t]=(e+(M[t]-e)*w)*r}else{let e=t.vertices;for(let t=0;t<f;t++){let s=b[t],i=e[t];d[t]=i+(s+(M[t]-s)*w-i)*r}}break}case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<f;t++){let e=b[t];d[t]+=(e+(M[t]-e)*w-d[t])*r}break;case t.MixBlend.add:let e=c;if(e.bones)for(let t=0;t<f;t++){let e=b[t];d[t]+=(e+(M[t]-e)*w)*r}else{let t=e.vertices;for(let e=0;e<f;e++){let s=b[e];d[e]+=(s+(M[e]-s)*w-t[e])*r}}}}}class q extends y{static propertyIds=[""+b.event];events;constructor(t){super(t,q.propertyIds),this.events=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e.time,this.events[t]=e}apply(t,e,s,i,n,r,a){if(!i)return;let o=this.frames,l=this.frames.length;if(e>s)this.apply(t,e,Number.MAX_VALUE,i,n,r,a),e=-1;else if(e>=o[l-1])return;if(s<o[0])return;let h=0;if(e<o[0])h=0;else{h=y.search1(o,e)+1;let t=o[h];for(;h>0&&o[h-1]==t;)h--}for(;h<l&&s>=o[h];h++)i.push(this.events[h])}}class U extends y{static propertyIds=[""+b.drawOrder];drawOrders;constructor(t){super(t,U.propertyIds),this.drawOrders=new Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(e,s,i,n,r,a,o){if(o==t.MixDirection.mixOut)return void(a==t.MixBlend.setup&&l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length));if(i<this.frames[0])return void(a!=t.MixBlend.setup&&a!=t.MixBlend.first||l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length));let h=y.search1(this.frames,i),c=this.drawOrders[h];if(c){let t=e.drawOrder,s=e.slots;for(let e=0,i=c.length;e<i;e++)t[e]=s[c[e]]}else l.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length)}}class W extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.ikConstraint+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,i,n,r,a){t*=6,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=n,this.frames[t+4]=r?1:0,this.frames[t+5]=a?1:0}apply(e,s,i,n,r,a,o){let l=e.ikConstraints[this.constraintIndex];if(!l.active)return;let h=this.frames;if(i<h[0]){switch(a){case t.MixBlend.setup:return l.mix=l.data.mix,l.softness=l.data.softness,l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,void(l.stretch=l.data.stretch);case t.MixBlend.first:l.mix+=(l.data.mix-l.mix)*r,l.softness+=(l.data.softness-l.softness)*r,l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,l.stretch=l.data.stretch}return}let c=0,d=0,u=y.search(h,i,6),m=this.curves[u/6];switch(m){case 0:let t=h[u];c=h[u+1],d=h[u+2];let e=(i-t)/(h[u+6]-t);c+=(h[u+6+1]-c)*e,d+=(h[u+6+2]-d)*e;break;case 1:c=h[u+1],d=h[u+2];break;default:c=this.getBezierValue(i,u,1,m-2),d=this.getBezierValue(i,u,2,m+18-2)}a==t.MixBlend.setup?(l.mix=l.data.mix+(c-l.data.mix)*r,l.softness=l.data.softness+(d-l.data.softness)*r,o==t.MixDirection.mixOut?(l.bendDirection=l.data.bendDirection,l.compress=l.data.compress,l.stretch=l.data.stretch):(l.bendDirection=h[u+3],l.compress=0!=h[u+4],l.stretch=0!=h[u+5])):(l.mix+=(c-l.mix)*r,l.softness+=(d-l.softness)*r,o==t.MixDirection.mixIn&&(l.bendDirection=h[u+3],l.compress=0!=h[u+4],l.stretch=0!=h[u+5]))}}class z extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.transformConstraint+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,n,r,a,o){let l=this.frames;l[t*=7]=e,l[t+1]=s,l[t+2]=i,l[t+3]=n,l[t+4]=r,l[t+5]=a,l[t+6]=o}apply(e,s,i,n,r,a,o){let l=e.transformConstraints[this.constraintIndex];if(!l.active)return;let h,c,d,u,m,f,p=this.frames;if(i<p[0]){let e=l.data;switch(a){case t.MixBlend.setup:return l.mixRotate=e.mixRotate,l.mixX=e.mixX,l.mixY=e.mixY,l.mixScaleX=e.mixScaleX,l.mixScaleY=e.mixScaleY,void(l.mixShearY=e.mixShearY);case t.MixBlend.first:l.mixRotate+=(e.mixRotate-l.mixRotate)*r,l.mixX+=(e.mixX-l.mixX)*r,l.mixY+=(e.mixY-l.mixY)*r,l.mixScaleX+=(e.mixScaleX-l.mixScaleX)*r,l.mixScaleY+=(e.mixScaleY-l.mixScaleY)*r,l.mixShearY+=(e.mixShearY-l.mixShearY)*r}return}let g=y.search(p,i,7),x=this.curves[g/7];switch(x){case 0:let t=p[g];h=p[g+1],c=p[g+2],d=p[g+3],u=p[g+4],m=p[g+5],f=p[g+6];let e=(i-t)/(p[g+7]-t);h+=(p[g+7+1]-h)*e,c+=(p[g+7+2]-c)*e,d+=(p[g+7+3]-d)*e,u+=(p[g+7+4]-u)*e,m+=(p[g+7+5]-m)*e,f+=(p[g+7+6]-f)*e;break;case 1:h=p[g+1],c=p[g+2],d=p[g+3],u=p[g+4],m=p[g+5],f=p[g+6];break;default:h=this.getBezierValue(i,g,1,x-2),c=this.getBezierValue(i,g,2,x+18-2),d=this.getBezierValue(i,g,3,x+36-2),u=this.getBezierValue(i,g,4,x+54-2),m=this.getBezierValue(i,g,5,x+72-2),f=this.getBezierValue(i,g,6,x+90-2)}if(a==t.MixBlend.setup){let t=l.data;l.mixRotate=t.mixRotate+(h-t.mixRotate)*r,l.mixX=t.mixX+(c-t.mixX)*r,l.mixY=t.mixY+(d-t.mixY)*r,l.mixScaleX=t.mixScaleX+(u-t.mixScaleX)*r,l.mixScaleY=t.mixScaleY+(m-t.mixScaleY)*r,l.mixShearY=t.mixShearY+(f-t.mixShearY)*r}else l.mixRotate+=(h-l.mixRotate)*r,l.mixX+=(c-l.mixX)*r,l.mixY+=(d-l.mixY)*r,l.mixScaleX+=(u-l.mixScaleX)*r,l.mixScaleY+=(m-l.mixScaleY)*r,l.mixShearY+=(f-l.mixShearY)*r}}class G extends S{constraintIndex=0;constructor(t,e,s){super(t,e,b.pathConstraintPosition+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,r,a){let o=t.pathConstraints[this.constraintIndex];o.active&&(o.position=this.getAbsoluteValue(s,n,r,o.position,o.data.position))}}class $ extends S{constraintIndex=0;constructor(t,e,s){super(t,e,b.pathConstraintSpacing+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,r,a){let o=t.pathConstraints[this.constraintIndex];o.active&&(o.spacing=this.getAbsoluteValue(s,n,r,o.spacing,o.data.spacing))}}class j extends M{constraintIndex=0;constructor(t,e,s){super(t,e,[b.pathConstraintMix+"|"+s]),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,n){let r=this.frames;r[t<<=2]=e,r[t+1]=s,r[t+2]=i,r[t+3]=n}apply(e,s,i,n,r,a,o){let l=e.pathConstraints[this.constraintIndex];if(!l.active)return;let h,c,d,u=this.frames;if(i<u[0]){switch(a){case t.MixBlend.setup:return l.mixRotate=l.data.mixRotate,l.mixX=l.data.mixX,void(l.mixY=l.data.mixY);case t.MixBlend.first:l.mixRotate+=(l.data.mixRotate-l.mixRotate)*r,l.mixX+=(l.data.mixX-l.mixX)*r,l.mixY+=(l.data.mixY-l.mixY)*r}return}let m=y.search(u,i,4),f=this.curves[m>>2];switch(f){case 0:let t=u[m];h=u[m+1],c=u[m+2],d=u[m+3];let e=(i-t)/(u[m+4]-t);h+=(u[m+4+1]-h)*e,c+=(u[m+4+2]-c)*e,d+=(u[m+4+3]-d)*e;break;case 1:h=u[m+1],c=u[m+2],d=u[m+3];break;default:h=this.getBezierValue(i,m,1,f-2),c=this.getBezierValue(i,m,2,f+18-2),d=this.getBezierValue(i,m,3,f+36-2)}if(a==t.MixBlend.setup){let t=l.data;l.mixRotate=t.mixRotate+(h-t.mixRotate)*r,l.mixX=t.mixX+(c-t.mixX)*r,l.mixY=t.mixY+(d-t.mixY)*r}else l.mixRotate+=(h-l.mixRotate)*r,l.mixX+=(c-l.mixX)*r,l.mixY+=(d-l.mixY)*r}}class H extends S{constraintIndex=0;constructor(t,e,s,i){super(t,e,i+"|"+s),this.constraintIndex=s}apply(t,e,s,i,n,r,a){let o;if(-1==this.constraintIndex){const e=s>=this.frames[0]?this.getCurveValue(s):0;for(const i of t.physicsConstraints)i.active&&this.global(i.data)&&this.set(i,this.getAbsoluteValue2(s,n,r,this.get(i),this.setup(i),e))}else o=t.physicsConstraints[this.constraintIndex],o.active&&this.set(o,this.getAbsoluteValue(s,n,r,this.get(o),this.setup(o)))}}class J extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintInertia)}setup(t){return t.data.inertia}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}}class K extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintStrength)}setup(t){return t.data.strength}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}}class Q extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintDamping)}setup(t){return t.data.damping}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}}class Z extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintMass)}setup(t){return 1/t.data.massInverse}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}}class tt extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintWind)}setup(t){return t.data.wind}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}}class et extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintGravity)}setup(t){return t.data.gravity}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}}class st extends H{constructor(t,e,s){super(t,e,s,b.physicsConstraintMix)}setup(t){return t.data.mix}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}}class it extends y{static propertyIds=[b.physicsConstraintReset.toString()];constraintIndex;constructor(t,e){super(t,it.propertyIds),this.constraintIndex=e}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e}apply(t,e,s,i,n,r,a){let o;if(-1!=this.constraintIndex&&(o=t.physicsConstraints[this.constraintIndex],!o.active))return;const l=this.frames;if(e>s)this.apply(t,e,Number.MAX_VALUE,[],n,r,a),e=-1;else if(e>=l[l.length-1])return;if(!(s<l[0])&&(e<l[0]||s>=l[y.search1(l,e)+1]))if(null!=o)o.reset();else for(const e of t.physicsConstraints)e.active&&e.reset()}}class nt extends y{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(t,e,s){super(t,[b.sequence+"|"+e+"|"+s.sequence.id]),this.slotIndex=e,this.attachment=s}getFrameEntries(){return nt.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(t,e,s,i,n){let r=this.frames;r[t*=nt.ENTRIES]=e,r[t+nt.MODE]=s|i<<4,r[t+nt.DELAY]=n}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex];if(!l.bone.active)return;let h=l.attachment,c=this.attachment;if(!(h==c||h instanceof u&&h.timelineAttachment==c))return;if(o==t.MixDirection.mixOut)return void(a==t.MixBlend.setup&&(l.sequenceIndex=-1));let d=this.frames;if(i<d[0])return void(a!=t.MixBlend.setup&&a!=t.MixBlend.first||(l.sequenceIndex=-1));let m=y.search(d,i,nt.ENTRIES),g=d[m],x=d[m+nt.MODE],w=d[m+nt.DELAY];if(!this.attachment.sequence)return;let b=x>>4,M=this.attachment.sequence.regions.length,S=p[15&x];if(S!=f.hold)switch(b+=(i-g)/w+1e-5|0,S){case f.once:b=Math.min(M-1,b);break;case f.loop:b%=M;break;case f.pingpong:{let t=(M<<1)-2;b=0==t?0:b%t,b>=M&&(b=t-b);break}case f.onceReverse:b=Math.max(M-1-b,0);break;case f.loopReverse:b=M-1-b%M;break;case f.pingpongReverse:{let t=(M<<1)-2;b=0==t?0:(b+M-1)%t,b>=M&&(b=t-b)}}l.sequenceIndex=b}}class rt{static _emptyAnimation=new g("<empty>",[],0);static emptyAnimation(){return rt._emptyAnimation}data;tracks=new Array;timeScale=1;unkeyedState=0;events=new Array;listeners=new Array;queue=new ot(this);propertyIDs=new i;animationsChanged=!1;trackEntryPool=new h((()=>new at));constructor(t){this.data=t}update(t){t*=this.timeScale;let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(!i)continue;i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast;let n=t*i.timeScale;if(i.delay>0){if(i.delay-=n,i.delay>0)continue;n=-i.delay,i.delay=0}let r=i.next;if(r){let e=i.trackLast-r.delay;if(e>=0){for(r.delay=0,r.trackTime+=0==i.timeScale?0:(e/i.timeScale+t)*r.timeScale,i.trackTime+=n,this.setCurrent(s,r,!0);r.mixingFrom;)r.mixTime+=t,r=r.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&!i.mixingFrom){e[s]=null,this.queue.end(i),this.clearNext(i);continue}if(i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null,t&&(t.mixingTo=null);t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(!s)return!0;let i=this.updateMixingFrom(s,e);return s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,t.mixTime>0&&t.mixTime>=t.mixDuration?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,s.mixingFrom&&(s.mixingFrom.mixingTo=t),t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e,!1)}apply(e){if(!e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let a=0,o=i.length;a<o;a++){let o=i[a];if(!o||o.delay>0)continue;n=!0;let h=0==a?t.MixBlend.first:o.mixBlend,c=o.alpha;o.mixingFrom?c*=this.applyMixingFrom(o,e,h):o.trackTime>=o.trackEnd&&!o.next&&(c=0);let d=c>=o.alphaAttachmentThreshold,u=o.animationLast,m=o.getAnimationTime(),f=m,p=s;o.reverse&&(f=o.animation.duration-f,p=null);let g=o.animation.timelines,x=g.length;if(0==a&&1==c||h==t.MixBlend.add){0==a&&(d=!0);for(let s=0;s<x;s++){l.webkit602BugfixHelper(c,h);var r=g[s];r instanceof N?this.applyAttachmentTimeline(r,e,f,h,d):r.apply(e,u,f,p,c,h,t.MixDirection.mixIn)}}else{let s=o.timelineMode,i=o.shortestRotation,n=!i&&o.timelinesRotation.length!=x<<1;n&&(o.timelinesRotation.length=x<<1);for(let r=0;r<x;r++){let a=g[r],m=s[r]==ht?h:t.MixBlend.setup;!i&&a instanceof k?this.applyRotateTimeline(a,e,f,c,m,o.timelinesRotation,r<<1,n):a instanceof N?this.applyAttachmentTimeline(a,e,f,h,d):(l.webkit602BugfixHelper(c,h),a.apply(e,u,f,p,c,m,t.MixDirection.mixIn))}}this.queueEvents(o,m),s.length=0,o.nextAnimationLast=m,o.nextTrackLast=o.trackTime}for(var a=this.unkeyedState+ft,o=e.slots,h=0,c=e.slots.length;h<c;h++){var d=o[h];if(d.attachmentState==a){var u=d.data.attachmentName;d.setAttachment(u?e.getAttachment(d.data.index,u):null)}}return this.unkeyedState+=2,this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;n.mixingFrom&&this.applyMixingFrom(n,s,i);let r=0;0==e.mixDuration?(r=1,i==t.MixBlend.first&&(i=t.MixBlend.setup)):(r=e.mixTime/e.mixDuration,r>1&&(r=1),i!=t.MixBlend.first&&(i=n.mixBlend));let a=r<n.mixAttachmentThreshold,o=r<n.mixDrawOrderThreshold,h=n.animation.timelines,c=h.length,d=n.alpha*e.interruptAlpha,u=d*(1-r),m=n.animationLast,f=n.getAnimationTime(),p=f,g=null;if(n.reverse?p=n.animation.duration-p:r<n.eventThreshold&&(g=this.events),i==t.MixBlend.add)for(let e=0;e<c;e++)h[e].apply(s,m,p,g,u,i,t.MixDirection.mixOut);else{let e=n.timelineMode,r=n.timelineHoldMix,f=n.shortestRotation,x=!f&&n.timelinesRotation.length!=c<<1;x&&(n.timelinesRotation.length=c<<1),n.totalAlpha=0;for(let w=0;w<c;w++){let c,b=h[w],y=t.MixDirection.mixOut,M=0;switch(e[w]){case ht:if(!o&&b instanceof U)continue;c=i,M=u;break;case ct:c=t.MixBlend.setup,M=u;break;case dt:c=i,M=d;break;case ut:c=t.MixBlend.setup,M=d;break;default:c=t.MixBlend.setup;let e=r[w];M=d*Math.max(0,1-e.mixTime/e.mixDuration)}n.totalAlpha+=M,!f&&b instanceof k?this.applyRotateTimeline(b,s,p,M,c,n.timelinesRotation,w<<1,x):b instanceof N?this.applyAttachmentTimeline(b,s,p,c,a&&M>=n.alphaAttachmentThreshold):(l.webkit602BugfixHelper(M,i),o&&b instanceof U&&c==t.MixBlend.setup&&(y=t.MixDirection.mixIn),b.apply(s,m,p,g,M,c,y))}}return e.mixDuration>0&&this.queueEvents(n,f),this.events.length=0,n.nextAnimationLast=f,n.nextTrackLast=n.trackTime,r}applyAttachmentTimeline(e,s,i,n,r){var a=s.slots[e.slotIndex];a.bone.active&&(i<e.frames[0]?n!=t.MixBlend.setup&&n!=t.MixBlend.first||this.setAttachment(s,a,a.data.attachmentName,r):this.setAttachment(s,a,e.attachmentNames[y.search1(e.frames,i)],r),a.attachmentState<=this.unkeyedState&&(a.attachmentState=this.unkeyedState+ft))}setAttachment(t,e,s,i){e.setAttachment(s?t.getAttachment(e.data.index,s):null),i&&(e.attachmentState=this.unkeyedState+pt)}applyRotateTimeline(e,s,i,n,a,o,l,h){if(h&&(o[l]=0),1==n)return void e.apply(s,0,i,null,1,a,t.MixDirection.mixIn);let c=s.bones[e.boneIndex];if(!c.active)return;let d=0,u=0;if(i<e.frames[0])switch(a){case t.MixBlend.setup:c.rotation=c.data.rotation;default:return;case t.MixBlend.first:d=c.rotation,u=c.data.rotation}else d=a==t.MixBlend.setup?c.data.rotation:c.rotation,u=c.data.rotation+e.getCurveValue(i);let m=0,f=u-d;if(f-=360*Math.ceil(f/360-.5),0==f)m=o[l];else{let t=0,e=0;h?(t=0,e=f):(t=o[l],e=o[l+1]);let s=t-t%360;m=f+s;let i=f>=0,n=t>=0;Math.abs(e)<=90&&r.signum(e)!=r.signum(f)&&(Math.abs(t-s)>180?(m+=360*r.signum(t),n=i):0!=s?m-=360*r.signum(t):n=i),n!=i&&(m+=360*r.signum(t)),o[l]=m}o[l+1]=f,c.rotation=d+m*n}queueEvents(t,e){let s=t.animationStart,i=t.animationEnd,n=i-s,r=t.trackLast%n,a=this.events,o=0,l=a.length;for(;o<l;o++){let e=a[o];if(e.time<r)break;e.time>i||this.queue.event(t,e)}let h=!1;if(t.loop)if(0==n)h=!0;else{const e=Math.floor(t.trackTime/n);h=e>0&&e>Math.floor(t.trackLast/n)}else h=e>=i&&t.animationLast<i;for(h&&this.queue.complete(t);o<l;o++){let e=a[o];e.time<s||this.queue.event(t,e)}}clearTracks(){let t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t>=this.tracks.length)return;let e=this.tracks[t];if(!e)return;this.queue.end(e),this.clearNext(e);let s=e;for(;;){let t=s.mixingFrom;if(!t)break;this.queue.end(t),s.mixingFrom=null,s.mixingTo=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,e.previous=null,i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,i.mixingTo=e,e.mixTime=0,i.mixingFrom&&i.mixDuration>0&&(e.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(e)}setAnimation(t,e,s=!1){let i=this.data.skeletonData.findAnimation(e);if(!i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s=!1){if(!e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.clearNext(n),n=n.mixingFrom,i=!1):this.clearNext(n));let r=this.trackEntry(t,e,s,n);return this.setCurrent(t,r,i),this.queue.drain(),r}addAnimation(t,e,s=!1,i=0){let n=this.data.skeletonData.findAnimation(e);if(!n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s=!1,i=0){if(!e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(n)for(;n.next;)n=n.next;let r=this.trackEntry(t,e,s,n);return n?(n.next=r,r.previous=n,i<=0&&(i+=n.getTrackComplete()-r.mixDuration)):(this.setCurrent(t,r,!0),this.queue.drain()),r.delay=i,r}setEmptyAnimation(t,e=0){let s=this.setAnimationWith(t,rt.emptyAnimation(),!1);return s.mixDuration=e,s.trackEnd=e,s}addEmptyAnimation(t,e=0,s=0){let i=this.addAnimationWith(t,rt.emptyAnimation(),!1,s);return s<=0&&(i.delay+=i.mixDuration-e),i.mixDuration=e,i.trackEnd=e,i}setEmptyAnimations(t=0){let e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let e=0,s=this.tracks.length;e<s;e++){let s=this.tracks[e];s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(l.ensureArrayCapacity(this.tracks,t+1,null),this.tracks.length=t+1,null)}trackEntry(e,s,i,n){let r=this.trackEntryPool.obtain();return r.reset(),r.trackIndex=e,r.animation=s,r.loop=i,r.holdPrevious=!1,r.reverse=!1,r.shortestRotation=!1,r.eventThreshold=0,r.alphaAttachmentThreshold=0,r.mixAttachmentThreshold=0,r.mixDrawOrderThreshold=0,r.animationStart=0,r.animationEnd=s.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.mixTime=0,r.mixDuration=n?this.data.getMix(n.animation,s):0,r.interruptAlpha=1,r.totalAlpha=0,r.mixBlend=t.MixBlend.replace,r}clearNext(t){let e=t.next;for(;e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1,this.propertyIDs.clear();let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i){for(;i.mixingFrom;)i=i.mixingFrom;do{i.mixingTo&&i.mixBlend==t.MixBlend.add||this.computeHold(i),i=i.mixingTo}while(i)}}}computeHold(t){let e=t.mixingTo,s=t.animation.timelines,i=t.animation.timelines.length,n=t.timelineMode;n.length=i;let r=t.timelineHoldMix;r.length=0;let a=this.propertyIDs;if(e&&e.holdPrevious)for(let t=0;t<i;t++)n[t]=a.addAll(s[t].getPropertyIds())?ut:dt;else t:for(let o=0;o<i;o++){let i=s[o],l=i.getPropertyIds();if(a.addAll(l))if(!e||i instanceof N||i instanceof U||i instanceof q||!e.animation.hasTimeline(l))n[o]=ct;else{for(let s=e.mixingTo;s;s=s.mixingTo)if(!s.animation.hasTimeline(l)){if(t.mixDuration>0){n[o]=mt,r[o]=s;continue t}break}n[o]=ut}else n[o]=ht}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(!t)throw new Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}}class at{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;holdPrevious=!1;reverse=!1;shortestRotation=!1;eventThreshold=0;mixAttachmentThreshold=0;alphaAttachmentThreshold=0;mixDrawOrderThreshold=0;animationStart=0;animationEnd=0;animationLast=0;nextAnimationLast=0;delay=0;trackTime=0;trackLast=0;nextTrackLast=0;trackEnd=0;timeScale=0;alpha=0;mixTime=0;_mixDuration=0;interruptAlpha=0;totalAlpha=0;get mixDuration(){return this._mixDuration}set mixDuration(t){this._mixDuration=t}setMixDurationWithDelay(t,e){this._mixDuration=t,null!=this.previous&&e<=0&&(e+=this.previous.getTrackComplete()-t),this.delay=e}mixBlend=t.MixBlend.replace;timelineMode=new Array;timelineHoldMix=new Array;timelinesRotation=new Array;reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){let t=this.animationEnd-this.animationStart;if(0!=t){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime<t)return t}return this.trackTime}wasApplied(){return-1!=this.nextTrackLast}isNextReady(){return null!=this.next&&this.nextTrackLast-this.next.delay>=0}}class ot{objects=[];drainDisabled=!1;animState;constructor(t){this.animState=t}start(e){this.objects.push(t.EventType.start),this.objects.push(e),this.animState.animationsChanged=!0}interrupt(e){this.objects.push(t.EventType.interrupt),this.objects.push(e)}end(e){this.objects.push(t.EventType.end),this.objects.push(e),this.animState.animationsChanged=!0}dispose(e){this.objects.push(t.EventType.dispose),this.objects.push(e)}complete(e){this.objects.push(t.EventType.complete),this.objects.push(e)}event(e,s){this.objects.push(t.EventType.event),this.objects.push(e),this.objects.push(s)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let e=this.objects,s=this.animState.listeners;for(let i=0;i<e.length;i+=2){let n=e[i],r=e[i+1];switch(n){case t.EventType.start:r.listener&&r.listener.start&&r.listener.start(r);for(let t=0;t<s.length;t++){let e=s[t];e.start&&e.start(r)}break;case t.EventType.interrupt:r.listener&&r.listener.interrupt&&r.listener.interrupt(r);for(let t=0;t<s.length;t++){let e=s[t];e.interrupt&&e.interrupt(r)}break;case t.EventType.end:r.listener&&r.listener.end&&r.listener.end(r);for(let t=0;t<s.length;t++){let e=s[t];e.end&&e.end(r)}case t.EventType.dispose:r.listener&&r.listener.dispose&&r.listener.dispose(r);for(let t=0;t<s.length;t++){let e=s[t];e.dispose&&e.dispose(r)}this.animState.trackEntryPool.free(r);break;case t.EventType.complete:r.listener&&r.listener.complete&&r.listener.complete(r);for(let t=0;t<s.length;t++){let e=s[t];e.complete&&e.complete(r)}break;case t.EventType.event:let n=e[2+i++];r.listener&&r.listener.event&&r.listener.event(r,n);for(let t=0;t<s.length;t++){let e=s[t];e.event&&e.event(r,n)}}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var lt;t.EventType=void 0,(lt=t.EventType||(t.EventType={}))[lt.start=0]="start",lt[lt.interrupt=1]="interrupt",lt[lt.end=2]="end",lt[lt.dispose=3]="dispose",lt[lt.complete=4]="complete",lt[lt.event=5]="event";const ht=0,ct=1,dt=2,ut=3,mt=4,ft=1,pt=2;class gt{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(!i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(!n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");let i=t.name+"."+e.name;this.animationToMixTime[i]=s}getMix(t,e){let s=t.name+"."+e.name,i=this.animationToMixTime[s];return void 0===i?this.defaultMix:i}}class xt extends u{color=new n(1,1,1,1);constructor(t){super(t)}copy(){let t=new xt(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t}}class wt extends u{endSlot=null;color=new n(.2275,.2275,.8078,1);constructor(t){super(t)}copy(){let t=new wt(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t}}class bt{_image;constructor(t){this._image=t}getImage(){return this._image}}var yt,Mt,St,vt,kt,It,At,Tt,Bt;t.TextureFilter=void 0,(yt=t.TextureFilter||(t.TextureFilter={}))[yt.Nearest=9728]="Nearest",yt[yt.Linear=9729]="Linear",yt[yt.MipMap=9987]="MipMap",yt[yt.MipMapNearestNearest=9984]="MipMapNearestNearest",yt[yt.MipMapLinearNearest=9985]="MipMapLinearNearest",yt[yt.MipMapNearestLinear=9986]="MipMapNearestLinear",yt[yt.MipMapLinearLinear=9987]="MipMapLinearLinear",t.TextureWrap=void 0,(Mt=t.TextureWrap||(t.TextureWrap={}))[Mt.MirroredRepeat=33648]="MirroredRepeat",Mt[Mt.ClampToEdge=33071]="ClampToEdge",Mt[Mt.Repeat=10497]="Repeat";class Ct{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0}class Ft{pages=new Array;regions=new Array;constructor(e){let s=new Et(e),i=new Array(4),n={size:t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},format:()=>{},filter:e=>{e.minFilter=l.enumValue(t.TextureFilter,i[1]),e.magFilter=l.enumValue(t.TextureFilter,i[2])},repeat:e=>{-1!=i[1].indexOf("x")&&(e.uWrap=t.TextureWrap.Repeat),-1!=i[1].indexOf("y")&&(e.vWrap=t.TextureWrap.Repeat)},pma:t=>{t.pma="true"==i[1]}};var r={xy:t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2])},size:t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},bounds:t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2]),t.width=parseInt(i[3]),t.height=parseInt(i[4])},offset:t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2])},orig:t=>{t.originalWidth=parseInt(i[1]),t.originalHeight=parseInt(i[2])},offsets:t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2]),t.originalWidth=parseInt(i[3]),t.originalHeight=parseInt(i[4])},rotate:t=>{let e=i[1];"true"==e?t.degrees=90:"false"!=e&&(t.degrees=parseInt(e))},index:t=>{t.index=parseInt(i[1])}};let a=s.readLine();for(;a&&0==a.trim().length;)a=s.readLine();for(;a&&0!=a.trim().length&&0!=s.readEntry(i,a);)a=s.readLine();let o=null,h=null,c=null;for(;null!==a;)if(0==a.trim().length)o=null,a=s.readLine();else if(o){let t=new Rt(o,a);for(;;){let e=s.readEntry(i,a=s.readLine());if(0==e)break;let n=r[i[0]];if(n)n(t);else{h||(h=[]),c||(c=[]),h.push(i[0]);let t=[];for(let s=0;s<e;s++)t.push(parseInt(i[s+1]));c.push(t)}}0==t.originalWidth&&0==t.originalHeight&&(t.originalWidth=t.width,t.originalHeight=t.height),h&&h.length>0&&c&&c.length>0&&(t.names=h,t.values=c,h=null,c=null),t.u=t.x/o.width,t.v=t.y/o.height,90==t.degrees?(t.u2=(t.x+t.height)/o.width,t.v2=(t.y+t.width)/o.height):(t.u2=(t.x+t.width)/o.width,t.v2=(t.y+t.height)/o.height),this.regions.push(t)}else{for(o=new Yt(a.trim());0!=s.readEntry(i,a=s.readLine());){let t=n[i[0]];t&&t(o)}this.pages.push(o)}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}setTextures(t,e=""){for(let s of this.pages)s.setTexture(t.get(e+s.name))}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture?.dispose()}}class Et{lines;index=0;constructor(t){this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readEntry(t,e){if(!e)return 0;if(0==(e=e.trim()).length)return 0;let s=e.indexOf(":");if(-1==s)return 0;t[0]=e.substr(0,s).trim();for(let i=1,n=s+1;;i++){let s=e.indexOf(",",n);if(-1==s)return t[i]=e.substr(n).trim(),i;if(t[i]=e.substr(n,s-n).trim(),n=s+1,4==i)return 4}}}class Yt{name;minFilter=t.TextureFilter.Nearest;magFilter=t.TextureFilter.Nearest;uWrap=t.TextureWrap.ClampToEdge;vWrap=t.TextureWrap.ClampToEdge;texture=null;width=0;height=0;pma=!1;regions=new Array;constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(let e of this.regions)e.texture=t}}class Rt extends Ct{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(t,e){super(),this.page=t,this.name=e,t.regions.push(this)}}class Pt extends u{region=null;path;regionUVs=[];uvs=[];triangles=[];color=new n(1,1,1,1);width=0;height=0;hullLength=0;edges=[];parentMesh=null;sequence=null;tempColor=new n(0,0,0,0);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.regionUVs;this.uvs&&this.uvs.length==t.length||(this.uvs=l.newFloatArray(t.length));let e=this.uvs,s=this.uvs.length,i=this.region.u,n=this.region.v,r=0,a=0;if(this.region instanceof Rt){let o=this.region,l=o.page,h=l.width,c=l.height;switch(o.degrees){case 90:i-=(o.originalHeight-o.offsetY-o.height)/h,n-=(o.originalWidth-o.offsetX-o.width)/c,r=o.originalHeight/h,a=o.originalWidth/c;for(let o=0;o<s;o+=2)e[o]=i+t[o+1]*r,e[o+1]=n+(1-t[o])*a;return;case 180:i-=(o.originalWidth-o.offsetX-o.width)/h,n-=o.offsetY/c,r=o.originalWidth/h,a=o.originalHeight/c;for(let o=0;o<s;o+=2)e[o]=i+(1-t[o])*r,e[o+1]=n+(1-t[o+1])*a;return;case 270:i-=o.offsetY/h,n-=o.offsetX/c,r=o.originalHeight/h,a=o.originalWidth/c;for(let o=0;o<s;o+=2)e[o]=i+(1-t[o+1])*r,e[o+1]=n+t[o]*a;return}i-=o.offsetX/h,n-=(o.originalHeight-o.offsetY-o.height)/c,r=o.originalWidth/h,a=o.originalHeight/c}else this.region?(r=this.region.u2-i,a=this.region.v2-n):(i=n=0,r=a=1);for(let o=0;o<s;o+=2)e[o]=i+t[o]*r,e[o+1]=n+t[o+1]*a}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}copy(){if(this.parentMesh)return this.newLinkedMesh();let t=new Pt(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),this.copyTo(t),t.regionUVs=new Array(this.regionUVs.length),l.arrayCopy(this.regionUVs,0,t.regionUVs,0,this.regionUVs.length),t.uvs=new Array(this.uvs.length),l.arrayCopy(this.uvs,0,t.uvs,0,this.uvs.length),t.triangles=new Array(this.triangles.length),l.arrayCopy(this.triangles,0,t.triangles,0,this.triangles.length),t.hullLength=this.hullLength,t.sequence=null!=this.sequence?this.sequence.copy():null,this.edges&&(t.edges=new Array(this.edges.length),l.arrayCopy(this.edges,0,t.edges,0,this.edges.length)),t.width=this.width,t.height=this.height,t}computeWorldVertices(t,e,s,i,n,r){null!=this.sequence&&this.sequence.apply(t,this),super.computeWorldVertices(t,e,s,i,n,r)}newLinkedMesh(){let t=new Pt(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),t.timelineAttachment=this.timelineAttachment,t.setParentMesh(this.parentMesh?this.parentMesh:this),null!=t.region&&t.updateRegion(),t}}class Xt extends u{lengths=[];closed=!1;constantSpeed=!1;color=new n(1,1,1,1);constructor(t){super(t)}copy(){let t=new Xt(this.name);return this.copyTo(t),t.lengths=new Array(this.lengths.length),l.arrayCopy(this.lengths,0,t.lengths,0,this.lengths.length),t.closed=closed,t.constantSpeed=this.constantSpeed,t.color.setFromColor(this.color),t}}class _t extends u{x=0;y=0;rotation=0;color=new n(.38,.94,0,1);constructor(t){super(t)}computeWorldPosition(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e}computeWorldRotation(t){const e=this.rotation*r.degRad,s=Math.cos(e),i=Math.sin(e),n=s*t.a+i*t.b,a=s*t.c+i*t.d;return r.atan2Deg(a,n)}copy(){let t=new _t(this.name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t}}class Vt extends d{x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;color=new n(1,1,1,1);path;region=null;sequence=null;offset=l.newFloatArray(8);uvs=l.newFloatArray(8);tempColor=new n(1,1,1,1);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw new Error("Region not set.");let t=this.region,e=this.uvs;if(null==t)return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=1,e[5]=1,e[6]=1,void(e[7]=0);let s=this.width/this.region.originalWidth*this.scaleX,i=this.height/this.region.originalHeight*this.scaleY,n=-this.width/2*this.scaleX+this.region.offsetX*s,a=-this.height/2*this.scaleY+this.region.offsetY*i,o=n+this.region.width*s,l=a+this.region.height*i,h=this.rotation*r.degRad,c=Math.cos(h),d=Math.sin(h),u=this.x,m=this.y,f=n*c+u,p=n*d,g=a*c+m,x=a*d,w=o*c+u,b=o*d,y=l*c+m,M=l*d,S=this.offset;S[0]=f-x,S[1]=g+p,S[2]=f-M,S[3]=y+p,S[4]=w-M,S[5]=y+b,S[6]=w-x,S[7]=g+b,90==t.degrees?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(t,e,s,i){null!=this.sequence&&this.sequence.apply(t,this);let n=t.bone,r=this.offset,a=n.worldX,o=n.worldY,l=n.a,h=n.b,c=n.c,d=n.d,u=0,m=0;u=r[0],m=r[1],e[s]=u*l+m*h+a,e[s+1]=u*c+m*d+o,s+=i,u=r[2],m=r[3],e[s]=u*l+m*h+a,e[s+1]=u*c+m*d+o,s+=i,u=r[4],m=r[5],e[s]=u*l+m*h+a,e[s+1]=u*c+m*d+o,s+=i,u=r[6],m=r[7],e[s]=u*l+m*h+a,e[s+1]=u*c+m*d+o}copy(){let t=new Vt(this.name,this.path);return t.region=this.region,t.x=this.x,t.y=this.y,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.rotation=this.rotation,t.width=this.width,t.height=this.height,l.arrayCopy(this.uvs,0,t.uvs,0,8),l.arrayCopy(this.offset,0,t.offset,0,8),t.color.setFromColor(this.color),t.sequence=null!=this.sequence?this.sequence.copy():null,t}static X1=0;static Y1=1;static C1R=2;static C1G=3;static C1B=4;static C1A=5;static U1=6;static V1=7;static X2=8;static Y2=9;static C2R=10;static C2G=11;static C2B=12;static C2A=13;static U2=14;static V2=15;static X3=16;static Y3=17;static C3R=18;static C3G=19;static C3B=20;static C3A=21;static U3=22;static V3=23;static X4=24;static Y4=25;static C4R=26;static C4G=27;static C4B=28;static C4A=29;static U4=30;static V4=31}class Dt{atlas;constructor(t){this.atlas=t}loadSequence(t,e,s){let i=s.regions;for(let n=0,r=i.length;n<r;n++){let r=s.getPath(e,n),a=this.atlas.findRegion(r);if(null==a)throw new Error("Region not found in atlas: "+r+" (sequence: "+t+")");i[n]=a}}newRegionAttachment(t,e,s,i){let n=new Vt(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");n.region=t}return n}newMeshAttachment(t,e,s,i){let n=new Pt(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");n.region=t}return n}newBoundingBoxAttachment(t,e){return new xt(e)}newPathAttachment(t,e){return new Xt(e)}newPointAttachment(t,e){return new _t(e)}newClippingAttachment(t,e){return new wt(e)}}class Ot{index=0;name;parent=null;length=0;x=0;y=0;rotation=0;scaleX=1;scaleY=1;shearX=0;shearY=0;inherit=t.Inherit.Normal;skinRequired=!1;color=new n;icon;visible=!1;constructor(t,e,s){if(t<0)throw new Error("index must be >= 0.");if(!e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}t.Inherit=void 0,(St=t.Inherit||(t.Inherit={}))[St.Normal=0]="Normal",St[St.OnlyTranslation=1]="OnlyTranslation",St[St.NoRotationOrReflection=2]="NoRotationOrReflection",St[St.NoScale=3]="NoScale",St[St.NoScaleOrReflection=4]="NoScaleOrReflection";class Nt{data;skeleton;parent=null;children=new Array;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;ax=0;ay=0;arotation=0;ascaleX=0;ascaleY=0;ashearX=0;ashearY=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;inherit=t.Inherit.Normal;sorted=!1;active=!1;constructor(t,e,s){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}isActive(){return this.active}update(t){this.updateWorldTransformWith(this.ax,this.ay,this.arotation,this.ascaleX,this.ascaleY,this.ashearX,this.ashearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(e,s,i,n,a,o,l){this.ax=e,this.ay=s,this.arotation=i,this.ascaleX=n,this.ascaleY=a,this.ashearX=o,this.ashearY=l;let h=this.parent;if(!h){let t=this.skeleton;const h=t.scaleX,c=t.scaleY,d=(i+o)*r.degRad,u=(i+90+l)*r.degRad;return this.a=Math.cos(d)*n*h,this.b=Math.cos(u)*a*h,this.c=Math.sin(d)*n*c,this.d=Math.sin(u)*a*c,this.worldX=e*h+t.x,void(this.worldY=s*c+t.y)}let c=h.a,d=h.b,u=h.c,m=h.d;switch(this.worldX=c*e+d*s+h.worldX,this.worldY=u*e+m*s+h.worldY,this.inherit){case t.Inherit.Normal:{const t=(i+o)*r.degRad,e=(i+90+l)*r.degRad,s=Math.cos(t)*n,h=Math.cos(e)*a,f=Math.sin(t)*n,p=Math.sin(e)*a;return this.a=c*s+d*f,this.b=c*h+d*p,this.c=u*s+m*f,void(this.d=u*h+m*p)}case t.Inherit.OnlyTranslation:{const t=(i+o)*r.degRad,e=(i+90+l)*r.degRad;this.a=Math.cos(t)*n,this.b=Math.cos(e)*a,this.c=Math.sin(t)*n,this.d=Math.sin(e)*a;break}case t.Inherit.NoRotationOrReflection:{let t=1/this.skeleton.scaleX,e=1/this.skeleton.scaleY;c*=t,u*=e;let s=c*c+u*u,h=0;s>1e-4?(s=Math.abs(c*m*e-d*t*u)/s,d=u*s,m=c*s,h=Math.atan2(u,c)*r.radDeg):(c=0,u=0,h=90-Math.atan2(m,d)*r.radDeg);const f=(i+o-h)*r.degRad,p=(i+l-h+90)*r.degRad,g=Math.cos(f)*n,x=Math.cos(p)*a,w=Math.sin(f)*n,b=Math.sin(p)*a;this.a=c*g-d*w,this.b=c*x-d*b,this.c=u*g+m*w,this.d=u*x+m*b;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:{i*=r.degRad;const e=Math.cos(i),s=Math.sin(i);let h=(c*e+d*s)/this.skeleton.scaleX,f=(u*e+m*s)/this.skeleton.scaleY,p=Math.sqrt(h*h+f*f);p>1e-5&&(p=1/p),h*=p,f*=p,p=Math.sqrt(h*h+f*f),this.inherit==t.Inherit.NoScale&&c*m-d*u<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(p=-p),i=Math.PI/2+Math.atan2(f,h);const g=Math.cos(i)*p,x=Math.sin(i)*p;o*=r.degRad,l=(90+l)*r.degRad;const w=Math.cos(o)*n,b=Math.cos(l)*a,y=Math.sin(o)*n,M=Math.sin(l)*a;this.a=h*w+g*y,this.b=h*b+g*M,this.c=f*w+x*y,this.d=f*b+x*M;break}}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY}setToSetupPose(){let t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY,this.inherit=t.inherit}updateAppliedTransform(){let e=this.parent;if(!e)return this.ax=this.worldX-this.skeleton.x,this.ay=this.worldY-this.skeleton.y,this.arotation=Math.atan2(this.c,this.a)*r.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*r.radDeg);let s,i,n,a,o=e.a,l=e.b,h=e.c,c=e.d,d=1/(o*c-l*h),u=c*d,m=l*d,f=h*d,p=o*d,g=this.worldX-e.worldX,x=this.worldY-e.worldY;if(this.ax=g*u-x*m,this.ay=x*p-g*f,this.inherit==t.Inherit.OnlyTranslation)s=this.a,i=this.b,n=this.c,a=this.d;else{switch(this.inherit){case t.Inherit.NoRotationOrReflection:{let t=Math.abs(o*c-l*h)/(o*o+h*h);l=-h*this.skeleton.scaleX*t/this.skeleton.scaleY,c=o*this.skeleton.scaleY*t/this.skeleton.scaleX,d=1/(o*c-l*h),u=c*d,m=l*d;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:let e=r.cosDeg(this.rotation),s=r.sinDeg(this.rotation);o=(o*e+l*s)/this.skeleton.scaleX,h=(h*e+c*s)/this.skeleton.scaleY;let i=Math.sqrt(o*o+h*h);i>1e-5&&(i=1/i),o*=i,h*=i,i=Math.sqrt(o*o+h*h),this.inherit==t.Inherit.NoScale&&d<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(i=-i);let n=r.PI/2+Math.atan2(h,o);l=Math.cos(n)*i,c=Math.sin(n)*i,d=1/(o*c-l*h),u=c*d,m=l*d,f=h*d,p=o*d}s=u*this.a-m*this.c,i=u*this.b-m*this.d,n=p*this.c-f*this.a,a=p*this.d-f*this.b}if(this.ashearX=0,this.ascaleX=Math.sqrt(s*s+n*n),this.ascaleX>1e-4){let t=s*a-i*n;this.ascaleY=t/this.ascaleX,this.ashearY=-Math.atan2(s*i+n*a,t)*r.radDeg,this.arotation=Math.atan2(n,s)*r.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(i*i+a*a),this.ashearY=0,this.arotation=90-Math.atan2(a,i)*r.radDeg}getWorldRotationX(){return Math.atan2(this.c,this.a)*r.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*r.radDeg}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}worldToLocal(t){let e=1/(this.a*this.d-this.b*this.c),s=t.x-this.worldX,i=t.y-this.worldY;return t.x=s*this.d*e-i*this.b*e,t.y=i*this.a*e-s*this.c*e,t}localToWorld(t){let e=t.x,s=t.y;return t.x=e*this.a+s*this.b+this.worldX,t.y=e*this.c+s*this.d+this.worldY,t}worldToParent(t){if(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.worldToLocal(t)}parentToWorld(t){if(null==t)throw new Error("world cannot be null.");return null==this.parent?t:this.parent.localToWorld(t)}worldToLocalRotation(t){let e=r.sinDeg(t),s=r.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*r.radDeg+this.rotation-this.shearX}localToWorldRotation(t){t-=this.rotation-this.shearX;let e=r.sinDeg(t),s=r.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*r.radDeg}rotateWorld(t){t*=r.degRad;const e=Math.sin(t),s=Math.cos(t),i=this.a,n=this.b;this.a=s*i-e*this.c,this.b=s*n-e*this.d,this.c=e*i+s*this.c,this.d=e*n+s*this.d}}class Lt{name;order;skinRequired;constructor(t,e,s){this.name=t,this.order=e,this.skinRequired=s}}class qt{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return-1!=e?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){for(var e=window.atob(t),s=e.length,i=new Uint8Array(s),n=0;n<s;n++)i[n]=e.charCodeAt(n);return i}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");if(-1==e)throw new Error("Not a binary data URI.");return e+=7,this.base64ToUint8Array(t.substr(e))}downloadText(t,e,s){if(this.start(t,e,s))return;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToString(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",t,!0);let n=()=>{this.finish(t,i.status,i.responseText)};i.onload=n,i.onerror=n,i.send()}downloadJson(t,e,s){this.downloadText(t,(t=>{e(JSON.parse(t))}),s)}downloadBinary(t,e,s){if(this.start(t,e,s))return;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToUint8Array(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";let n=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{200==i.status||0==i.status?this.finish(t,200,new Uint8Array(i.response)):n()},i.onerror=n,i.send()}start(t,e,s){let i=this.callbacks[t];try{if(i)return!0;this.callbacks[t]=i=[]}finally{i.push(e,s)}}finish(t,e,s){let i=this.callbacks[t];delete this.callbacks[t];let n=200==e||0==e?[s]:[e,s];for(let t=n.length-1,e=i.length;t<e;t+=2)i[t].apply(null,n)}}class Ut{data;intValue=0;floatValue=0;stringValue=null;time=0;volume=0;balance=0;constructor(t,e){if(!e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class Wt{name;intValue=0;floatValue=0;stringValue=null;audioPath=null;volume=0;balance=0;constructor(t){this.name=t}}class zt{data;bones;target;bendDirection=0;compress=!1;stretch=!1;mix=1;softness=0;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw new Error(`Couldn't find bone ${t.target.name}`);this.target=s,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}update(t){if(0==this.mix)return;let e=this.target,s=this.bones;switch(s.length){case 1:this.apply1(s[0],e.worldX,e.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(s[0],s[1],e.worldX,e.worldY,this.bendDirection,this.stretch,this.data.uniform,this.softness,this.mix)}}apply1(e,s,i,n,a,o,l){let h=e.parent;if(!h)throw new Error("IK bone must have parent.");let c=h.a,d=h.b,u=h.c,m=h.d,f=-e.ashearX-e.arotation,p=0,g=0;switch(e.inherit){case t.Inherit.OnlyTranslation:p=(s-e.worldX)*r.signum(e.skeleton.scaleX),g=(i-e.worldY)*r.signum(e.skeleton.scaleY);break;case t.Inherit.NoRotationOrReflection:let n=Math.abs(c*m-d*u)/Math.max(1e-4,c*c+u*u),a=c/e.skeleton.scaleX,o=u/e.skeleton.scaleY;d=-o*n*e.skeleton.scaleX,m=a*n*e.skeleton.scaleY,f+=Math.atan2(o,a)*r.radDeg;default:let l=s-h.worldX,x=i-h.worldY,w=c*m-d*u;Math.abs(w)<=1e-4?(p=0,g=0):(p=(l*m-x*d)/w-e.ax,g=(x*c-l*u)/w-e.ay)}f+=Math.atan2(g,p)*r.radDeg,e.ascaleX<0&&(f+=180),f>180?f-=360:f<-180&&(f+=360);let x=e.ascaleX,w=e.ascaleY;if(n||a){switch(e.inherit){case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:p=s-e.worldX,g=i-e.worldY}const r=e.data.length*x;if(r>1e-4){const t=p*p+g*g;if(n&&t<r*r||a&&t>r*r){const e=(Math.sqrt(t)/r-1)*l+1;x*=e,o&&(w*=e)}}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+f*l,x,w,e.ashearX,e.ashearY)}apply2(e,s,i,n,a,o,l,h,c){if(e.inherit!=t.Inherit.Normal||s.inherit!=t.Inherit.Normal)return;let d=e.ax,u=e.ay,m=e.ascaleX,f=e.ascaleY,p=m,g=f,x=s.ascaleX,w=0,b=0,y=0;m<0?(m=-m,w=180,y=-1):(w=0,y=1),f<0&&(f=-f,y=-y),x<0?(x=-x,b=180):b=0;let M=s.ax,S=0,v=0,k=0,I=e.a,A=e.b,T=e.c,B=e.d,C=Math.abs(m-f)<=1e-4;!C||o?(S=0,v=I*M+e.worldX,k=T*M+e.worldY):(S=s.ay,v=I*M+A*S+e.worldX,k=T*M+B*S+e.worldY);let F=e.parent;if(!F)throw new Error("IK parent must itself have a parent.");I=F.a,A=F.b,T=F.c,B=F.d;let E=I*B-A*T,Y=v-F.worldX,R=k-F.worldY;E=Math.abs(E)<=1e-4?0:1/E;let P,X,_=(Y*B-R*A)*E-d,V=(R*I-Y*T)*E-u,D=Math.sqrt(_*_+V*V),O=s.data.length*x;if(D<1e-4)return this.apply1(e,i,n,!1,o,!1,c),void s.updateWorldTransformWith(M,S,0,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY);Y=i-F.worldX,R=n-F.worldY;let N=(Y*B-R*A)*E-d,L=(R*I-Y*T)*E-u,q=N*N+L*L;if(0!=h){h*=m*(x+1)*.5;let t=Math.sqrt(q),e=t-D-O*m+h;if(e>0){let s=Math.min(1,e/(2*h))-1;s=(e-h*(1-s*s))/t,N-=s*N,L-=s*L,q=N*N+L*L}}t:if(C){O*=m;let t=(q-D*D-O*O)/(2*D*O);t<-1?(t=-1,X=Math.PI*a):t>1?(t=1,X=0,o&&(I=(Math.sqrt(q)/(D+O)-1)*c+1,p*=I,l&&(g*=I))):X=Math.acos(t)*a,I=D+O*t,A=O*Math.sin(X),P=Math.atan2(L*I-N*A,N*I+L*A)}else{I=m*O,A=f*O;let t=I*I,e=A*A,s=Math.atan2(L,N);T=e*D*D+t*q-t*e;let i=-2*e*D,n=e-t;if(B=i*i-4*n*T,B>=0){let t=Math.sqrt(B);i<0&&(t=-t),t=.5*-(i+t);let e=t/n,r=T/t,o=Math.abs(e)<Math.abs(r)?e:r;if(e=q-o*o,e>=0){R=Math.sqrt(e)*a,P=s-Math.atan2(R,o),X=Math.atan2(R/f,(o-D)/m);break t}}let o=r.PI,l=D-I,h=l*l,c=0,d=0,u=D+I,p=u*u,g=0;T=-I*D/(t-e),T>=-1&&T<=1&&(T=Math.acos(T),Y=I*Math.cos(T)+D,R=A*Math.sin(T),B=Y*Y+R*R,B<h&&(o=T,h=B,l=Y,c=R),B>p&&(d=T,p=B,u=Y,g=R)),q<=.5*(h+p)?(P=s-Math.atan2(c*a,l),X=o*a):(P=s-Math.atan2(g*a,u),X=d*a)}let U=Math.atan2(S,M)*y,W=e.arotation;P=(P-U)*r.radDeg+w-W,P>180?P-=360:P<-180&&(P+=360),e.updateWorldTransformWith(d,u,W+P*c,p,g,0,0),W=s.arotation,X=((X+U)*r.radDeg-s.ashearX)*y+b-W,X>180?X-=360:X<-180&&(X+=360),s.updateWorldTransformWith(M,S,W+X*c,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY)}}class Gt extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}bendDirection=0;compress=!1;stretch=!1;uniform=!1;mix=0;softness=0;constructor(t){super(t,0,!1)}}class $t extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("SlotData not set.")}positionMode=t.PositionMode.Fixed;spacingMode=t.SpacingMode.Fixed;rotateMode=t.RotateMode.Chain;offsetRotation=0;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;constructor(t){super(t,0,!1)}}t.PositionMode=void 0,(vt=t.PositionMode||(t.PositionMode={}))[vt.Fixed=0]="Fixed",vt[vt.Percent=1]="Percent",t.SpacingMode=void 0,(kt=t.SpacingMode||(t.SpacingMode={}))[kt.Length=0]="Length",kt[kt.Fixed=1]="Fixed",kt[kt.Percent=2]="Percent",kt[kt.Proportional=3]="Proportional",t.RotateMode=void 0,(It=t.RotateMode||(t.RotateMode={}))[It.Tangent=0]="Tangent",It[It.Chain=1]="Chain",It[It.ChainScale=2]="ChainScale";class jt{static NONE=-1;static BEFORE=-2;static AFTER=-3;static epsilon=1e-5;data;bones;target;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;spaces=new Array;positions=new Array;world=new Array;curves=new Array;lengths=new Array;segments=new Array;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0,i=t.bones.length;s<i;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findSlot(t.target.name);if(!s)throw new Error(`Couldn't find target bone ${t.target.name}`);this.target=s,this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}update(e){let s=this.target.getAttachment();if(!(s instanceof Xt))return;let i=this.mixRotate,n=this.mixX,a=this.mixY;if(0==i&&0==n&&0==a)return;let o=this.data,h=o.rotateMode==t.RotateMode.Tangent,c=o.rotateMode==t.RotateMode.ChainScale,d=this.bones,u=d.length,m=h?u:u+1,f=l.setArraySize(this.spaces,m),p=c?this.lengths=l.setArraySize(this.lengths,u):[],g=this.spacing;switch(o.spacingMode){case t.SpacingMode.Percent:if(c)for(let t=0,e=m-1;t<e;t++){let e=d[t],s=e.data.length,i=s*e.a,n=s*e.c;p[t]=Math.sqrt(i*i+n*n)}l.arrayFill(f,1,m,g);break;case t.SpacingMode.Proportional:let e=0;for(let t=0,s=m-1;t<s;){let s=d[t],i=s.data.length;if(i<jt.epsilon)c&&(p[t]=0),f[++t]=g;else{let n=i*s.a,r=i*s.c,a=Math.sqrt(n*n+r*r);c&&(p[t]=a),f[++t]=a,e+=a}}if(e>0){e=m/e*g;for(let t=1;t<m;t++)f[t]*=e}break;default:let s=o.spacingMode==t.SpacingMode.Length;for(let t=0,e=m-1;t<e;){let e=d[t],i=e.data.length;if(i<jt.epsilon)c&&(p[t]=0),f[++t]=g;else{let n=i*e.a,r=i*e.c,a=Math.sqrt(n*n+r*r);c&&(p[t]=a),f[++t]=(s?i+g:g)*a/i}}}let x=this.computeWorldPositions(s,m,h),w=x[0],b=x[1],y=o.offsetRotation,M=!1;if(0==y)M=o.rotateMode==t.RotateMode.Chain;else{M=!1;let t=this.target.bone;y*=t.a*t.d-t.b*t.c>0?r.degRad:-r.degRad}for(let t=0,e=3;t<u;t++,e+=3){let s=d[t];s.worldX+=(w-s.worldX)*n,s.worldY+=(b-s.worldY)*a;let o=x[e],l=x[e+1],u=o-w,m=l-b;if(c){let e=p[t];if(0!=e){let t=(Math.sqrt(u*u+m*m)/e-1)*i+1;s.a*=t,s.c*=t}}if(w=o,b=l,i>0){let n=s.a,a=s.b,o=s.c,l=s.d,c=0,d=0,p=0;if(c=h?x[e-1]:0==f[t+1]?x[e+2]:Math.atan2(m,u),c-=Math.atan2(o,n),M){d=Math.cos(c),p=Math.sin(c);let t=s.data.length;w+=(t*(d*n-p*o)-u)*i,b+=(t*(p*n+d*o)-m)*i}else c+=y;c>r.PI?c-=r.PI2:c<-r.PI&&(c+=r.PI2),c*=i,d=Math.cos(c),p=Math.sin(c),s.a=d*n-p*o,s.b=d*a-p*l,s.c=p*n+d*o,s.d=p*a+d*l}s.updateAppliedTransform()}}computeWorldPositions(e,s,i){let n=this.target,r=this.position,a=this.spaces,o=l.setArraySize(this.positions,3*s+2),h=this.world,c=e.closed,d=e.worldVerticesLength,u=d/6,m=jt.NONE;if(!e.constantSpeed){let f=e.lengths;u-=c?1:2;let p,g=f[u];switch(this.data.positionMode==t.PositionMode.Percent&&(r*=g),this.data.spacingMode){case t.SpacingMode.Percent:p=g;break;case t.SpacingMode.Proportional:p=g/s;break;default:p=1}h=l.setArraySize(this.world,8);for(let t=0,l=0,x=0;t<s;t++,l+=3){let s=a[t]*p;r+=s;let w=r;if(c)w%=g,w<0&&(w+=g),x=0;else{if(w<0){m!=jt.BEFORE&&(m=jt.BEFORE,e.computeWorldVertices(n,2,4,h,0,2)),this.addBeforePosition(w,h,0,o,l);continue}if(w>g){m!=jt.AFTER&&(m=jt.AFTER,e.computeWorldVertices(n,d-6,4,h,0,2)),this.addAfterPosition(w-g,h,0,o,l);continue}}for(;;x++){let t=f[x];if(!(w>t)){if(0==x)w/=t;else{let e=f[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,c&&x==u?(e.computeWorldVertices(n,d-4,4,h,0,2),e.computeWorldVertices(n,0,4,h,4,2)):e.computeWorldVertices(n,6*x+2,8,h,0,2)),this.addCurvePosition(w,h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],o,l,i||t>0&&0==s)}return o}c?(d+=2,h=l.setArraySize(this.world,d),e.computeWorldVertices(n,2,d-4,h,0,2),e.computeWorldVertices(n,0,2,h,d-4,2),h[d-2]=h[0],h[d-1]=h[1]):(u--,d-=4,h=l.setArraySize(this.world,d),e.computeWorldVertices(n,2,d,h,0,2));let f,p=l.setArraySize(this.curves,u),g=0,x=h[0],w=h[1],b=0,y=0,M=0,S=0,v=0,k=0,I=0,A=0,T=0,B=0,C=0,F=0,E=0,Y=0;for(let t=0,e=2;t<u;t++,e+=6)b=h[e],y=h[e+1],M=h[e+2],S=h[e+3],v=h[e+4],k=h[e+5],I=.1875*(x-2*b+M),A=.1875*(w-2*y+S),T=.09375*(3*(b-M)-x+v),B=.09375*(3*(y-S)-w+k),C=2*I+T,F=2*A+B,E=.75*(b-x)+I+.16666667*T,Y=.75*(y-w)+A+.16666667*B,g+=Math.sqrt(E*E+Y*Y),E+=C,Y+=F,C+=T,F+=B,g+=Math.sqrt(E*E+Y*Y),E+=C,Y+=F,g+=Math.sqrt(E*E+Y*Y),E+=C+T,Y+=F+B,g+=Math.sqrt(E*E+Y*Y),p[t]=g,x=v,w=k;switch(this.data.positionMode==t.PositionMode.Percent&&(r*=g),this.data.spacingMode){case t.SpacingMode.Percent:f=g;break;case t.SpacingMode.Proportional:f=g/s;break;default:f=1}let R=this.segments,P=0;for(let t=0,e=0,n=0,l=0;t<s;t++,e+=3){let s=a[t]*f;r+=s;let u=r;if(c)u%=g,u<0&&(u+=g),n=0;else{if(u<0){this.addBeforePosition(u,h,0,o,e);continue}if(u>g){this.addAfterPosition(u-g,h,d-4,o,e);continue}}for(;;n++){let t=p[n];if(!(u>t)){if(0==n)u/=t;else{let e=p[n-1];u=(u-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=h[t],w=h[t+1],b=h[t+2],y=h[t+3],M=h[t+4],S=h[t+5],v=h[t+6],k=h[t+7],I=.03*(x-2*b+M),A=.03*(w-2*y+S),T=.006*(3*(b-M)-x+v),B=.006*(3*(y-S)-w+k),C=2*I+T,F=2*A+B,E=.3*(b-x)+I+.16666667*T,Y=.3*(y-w)+A+.16666667*B,P=Math.sqrt(E*E+Y*Y),R[0]=P,t=1;t<8;t++)E+=C,Y+=F,C+=T,F+=B,P+=Math.sqrt(E*E+Y*Y),R[t]=P;E+=C,Y+=F,P+=Math.sqrt(E*E+Y*Y),R[8]=P,E+=C+T,Y+=F+B,P+=Math.sqrt(E*E+Y*Y),R[9]=P,l=0}for(u*=P;;l++){let t=R[l];if(!(u>t)){if(0==l)u/=t;else{let e=R[l-1];u=l+(u-e)/(t-e)}break}}this.addCurvePosition(.1*u,x,w,b,y,M,S,v,k,o,e,i||t>0&&0==s)}return o}addBeforePosition(t,e,s,i,n){let r=e[s],a=e[s+1],o=e[s+2]-r,l=e[s+3]-a,h=Math.atan2(l,o);i[n]=r+t*Math.cos(h),i[n+1]=a+t*Math.sin(h),i[n+2]=h}addAfterPosition(t,e,s,i,n){let r=e[s+2],a=e[s+3],o=r-e[s],l=a-e[s+1],h=Math.atan2(l,o);i[n]=r+t*Math.cos(h),i[n+1]=a+t*Math.sin(h),i[n+2]=h}addCurvePosition(t,e,s,i,n,r,a,o,l,h,c,d){if(0==t||isNaN(t))return h[c]=e,h[c+1]=s,void(h[c+2]=Math.atan2(n-s,i-e));let u=t*t,m=u*t,f=1-t,p=f*f,g=p*f,x=f*t,w=3*x,b=f*w,y=w*t,M=e*g+i*b+r*y+o*m,S=s*g+n*b+a*y+l*m;h[c]=M,h[c+1]=S,d&&(h[c+2]=t<.001?Math.atan2(n-s,i-e):Math.atan2(S-(s*p+n*x*2+a*u),M-(e*p+i*x*2+r*u)))}}class Ht{data;_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("Bone not set.")}inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xVelocity=0;yOffset=0;yVelocity=0;rotateOffset=0;rotateVelocity=0;scaleOffset=0;scaleVelocity=0;active=!1;skeleton;remaining=0;lastTime=0;constructor(t,e){this.data=t,this.skeleton=e,this.bone=e.bones[t.bone.index],this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}reset(){this.remaining=0,this.lastTime=this.skeleton.time,this._reset=!0,this.xOffset=0,this.xVelocity=0,this.yOffset=0,this.yVelocity=0,this.rotateOffset=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleVelocity=0}setToSetupPose(){const t=this.data;this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}isActive(){return this.active}update(e){const s=this.mix;if(0==s)return;const i=this.data.x>0,n=this.data.y>0,a=this.data.rotate>0||this.data.shearX>0,o=this.data.scaleX>0,l=this.bone,h=l.data.length;switch(e){case t.Physics.none:return;case t.Physics.reset:this.reset();case t.Physics.update:const e=this.skeleton,c=Math.max(this.skeleton.time-this.lastTime,0);this.remaining+=c,this.lastTime=e.time;const d=l.worldX,u=l.worldY;if(this._reset)this._reset=!1,this.ux=d,this.uy=u;else{let t=this.remaining,m=this.inertia,f=this.data.step,p=this.skeleton.data.referenceScale,g=-1,x=this.data.limit*c,w=x*Math.abs(e.scaleY);if(x*=Math.abs(e.scaleX),i||n){if(i){const t=(this.ux-d)*m;this.xOffset+=t>x?x:t<-x?-x:t,this.ux=d}if(n){const t=(this.uy-u)*m;this.yOffset+=t>w?w:t<-w?-w:t,this.uy=u}if(t>=f){g=Math.pow(this.damping,60*f);const e=this.massInverse*f,s=this.strength,r=this.wind*p,a=(Qt.yDown?-this.gravity:this.gravity)*p;do{i&&(this.xVelocity+=(r-this.xOffset*s)*e,this.xOffset+=this.xVelocity*f,this.xVelocity*=g),n&&(this.yVelocity-=(a+this.yOffset*s)*e,this.yOffset+=this.yVelocity*f,this.yVelocity*=g),t-=f}while(t>=f)}i&&(l.worldX+=this.xOffset*s*this.data.x),n&&(l.worldY+=this.yOffset*s*this.data.y)}if(a||o){let e=Math.atan2(l.c,l.a),i=0,n=0,c=0,d=this.cx-l.worldX,u=this.cy-l.worldY;if(d>x?d=x:d<-x&&(d=-x),u>w?u=w:u<-w&&(u=-w),a){c=(this.data.rotate+this.data.shearX)*s;let t=Math.atan2(u+this.ty,d+this.tx)-e-this.rotateOffset*c;this.rotateOffset+=(t-Math.ceil(t*r.invPI2-.5)*r.PI2)*m,t=this.rotateOffset*c+e,i=Math.cos(t),n=Math.sin(t),o&&(t=h*l.getWorldScaleX(),t>0&&(this.scaleOffset+=(d*i+u*n)*m/t))}else{i=Math.cos(e),n=Math.sin(e);const t=h*l.getWorldScaleX();t>0&&(this.scaleOffset+=(d*i+u*n)*m/t)}if(t=this.remaining,t>=f){-1==g&&(g=Math.pow(this.damping,60*f));const s=this.massInverse*f,r=this.strength,l=this.wind,d=Qt.yDown?-this.gravity:this.gravity,u=h/p;for(;;)if(t-=f,o&&(this.scaleVelocity+=(l*i-d*n-this.scaleOffset*r)*s,this.scaleOffset+=this.scaleVelocity*f,this.scaleVelocity*=g),a){if(this.rotateVelocity-=((l*n+d*i)*u+this.rotateOffset*r)*s,this.rotateOffset+=this.rotateVelocity*f,this.rotateVelocity*=g,t<f)break;const a=this.rotateOffset*c+e;i=Math.cos(a),n=Math.sin(a)}else if(t<f)break}}this.remaining=t}this.cx=l.worldX,this.cy=l.worldY;break;case t.Physics.pose:i&&(l.worldX+=this.xOffset*s*this.data.x),n&&(l.worldY+=this.yOffset*s*this.data.y)}if(a){let t=this.rotateOffset*s,e=0,i=0,n=0;if(this.data.shearX>0){let s=0;this.data.rotate>0&&(s=t*this.data.rotate,e=Math.sin(s),i=Math.cos(s),n=l.b,l.b=i*n-e*l.d,l.d=e*n+i*l.d),s+=t*this.data.shearX,e=Math.sin(s),i=Math.cos(s),n=l.a,l.a=i*n-e*l.c,l.c=e*n+i*l.c}else t*=this.data.rotate,e=Math.sin(t),i=Math.cos(t),n=l.a,l.a=i*n-e*l.c,l.c=e*n+i*l.c,n=l.b,l.b=i*n-e*l.d,l.d=e*n+i*l.d}if(o){const t=1+this.scaleOffset*s*this.data.scaleX;l.a*=t,l.c*=t}e!=t.Physics.pose&&(this.tx=h*l.a,this.ty=h*l.c),l.updateAppliedTransform()}translate(t,e){this.ux-=t,this.uy-=e,this.cx-=t,this.cy-=e}rotate(t,e,s){const i=s*r.degRad,n=Math.cos(i),a=Math.sin(i),o=this.cx-t,l=this.cy-e;this.translate(o*n-l*a-o,o*a+l*n-l)}}class Jt{data;bone;color;darkColor=null;attachment=null;attachmentState=0;sequenceIndex=-1;deform=new Array;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new n,this.darkColor=t.darkColor?new n:null,this.setToSetupPose()}getSkeleton(){return this.bone.skeleton}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(t instanceof u&&this.attachment instanceof u&&t.timelineAttachment==this.attachment.timelineAttachment||(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}setToSetupPose(){this.color.setFromColor(this.data.color),this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),this.data.attachmentName?(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.attachment=null}}class Kt{data;bones;target;mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;temp=new c;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw new Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw new Error(`Couldn't find target bone ${t.target.name}.`);this.target=s,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}isActive(){return this.active}setToSetupPose(){const t=this.data;this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}update(t){0==this.mixRotate&&0==this.mixX&&0==this.mixY&&0==this.mixScaleX&&0==this.mixScaleY&&0==this.mixShearY||(this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld())}applyAbsoluteWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,a=this.mixShearY,o=0!=e||0!=s,l=this.target,h=l.a,c=l.b,d=l.c,u=l.d,m=h*u-c*d>0?r.degRad:-r.degRad,f=this.data.offsetRotation*m,p=this.data.offsetShearY*m,g=this.bones;for(let m=0,x=g.length;m<x;m++){let x=g[m];if(0!=t){let e=x.a,s=x.b,i=x.c,n=x.d,a=Math.atan2(d,h)-Math.atan2(i,e)+f;a>r.PI?a-=r.PI2:a<-r.PI&&(a+=r.PI2),a*=t;let o=Math.cos(a),l=Math.sin(a);x.a=o*e-l*i,x.b=o*s-l*n,x.c=l*e+o*i,x.d=l*s+o*n}if(o){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),x.worldX+=(t.x-x.worldX)*e,x.worldY+=(t.y-x.worldY)*s}if(0!=i){let t=Math.sqrt(x.a*x.a+x.c*x.c);0!=t&&(t=(t+(Math.sqrt(h*h+d*d)-t+this.data.offsetScaleX)*i)/t),x.a*=t,x.c*=t}if(0!=n){let t=Math.sqrt(x.b*x.b+x.d*x.d);0!=t&&(t=(t+(Math.sqrt(c*c+u*u)-t+this.data.offsetScaleY)*n)/t),x.b*=t,x.d*=t}if(a>0){let t=x.b,e=x.d,s=Math.atan2(e,t),i=Math.atan2(u,c)-Math.atan2(d,h)-(s-Math.atan2(x.c,x.a));i>r.PI?i-=r.PI2:i<-r.PI&&(i+=r.PI2),i=s+(i+p)*a;let n=Math.sqrt(t*t+e*e);x.b=Math.cos(i)*n,x.d=Math.sin(i)*n}x.updateAppliedTransform()}}applyRelativeWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,a=this.mixShearY,o=0!=e||0!=s,l=this.target,h=l.a,c=l.b,d=l.c,u=l.d,m=h*u-c*d>0?r.degRad:-r.degRad,f=this.data.offsetRotation*m,p=this.data.offsetShearY*m,g=this.bones;for(let m=0,x=g.length;m<x;m++){let x=g[m];if(0!=t){let e=x.a,s=x.b,i=x.c,n=x.d,a=Math.atan2(d,h)+f;a>r.PI?a-=r.PI2:a<-r.PI&&(a+=r.PI2),a*=t;let o=Math.cos(a),l=Math.sin(a);x.a=o*e-l*i,x.b=o*s-l*n,x.c=l*e+o*i,x.d=l*s+o*n}if(o){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),x.worldX+=t.x*e,x.worldY+=t.y*s}if(0!=i){let t=(Math.sqrt(h*h+d*d)-1+this.data.offsetScaleX)*i+1;x.a*=t,x.c*=t}if(0!=n){let t=(Math.sqrt(c*c+u*u)-1+this.data.offsetScaleY)*n+1;x.b*=t,x.d*=t}if(a>0){let t=Math.atan2(u,c)-Math.atan2(d,h);t>r.PI?t-=r.PI2:t<-r.PI&&(t+=r.PI2);let e=x.b,s=x.d;t=Math.atan2(s,e)+(t-r.PI/2+p)*a;let i=Math.sqrt(e*e+s*s);x.b=Math.cos(t)*i,x.d=Math.sin(t)*i}x.updateAppliedTransform()}}applyAbsoluteLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,r=this.mixShearY,a=this.target,o=this.bones;for(let l=0,h=o.length;l<h;l++){let h=o[l],c=h.arotation;0!=t&&(c+=(a.arotation-c+this.data.offsetRotation)*t);let d=h.ax,u=h.ay;d+=(a.ax-d+this.data.offsetX)*e,u+=(a.ay-u+this.data.offsetY)*s;let m=h.ascaleX,f=h.ascaleY;0!=i&&0!=m&&(m=(m+(a.ascaleX-m+this.data.offsetScaleX)*i)/m),0!=n&&0!=f&&(f=(f+(a.ascaleY-f+this.data.offsetScaleY)*n)/f);let p=h.ashearY;0!=r&&(p+=(a.ashearY-p+this.data.offsetShearY)*r),h.updateWorldTransformWith(d,u,c,m,f,h.ashearX,p)}}applyRelativeLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,n=this.mixScaleY,r=this.mixShearY,a=this.target,o=this.bones;for(let l=0,h=o.length;l<h;l++){let h=o[l],c=h.arotation+(a.arotation+this.data.offsetRotation)*t,d=h.ax+(a.ax+this.data.offsetX)*e,u=h.ay+(a.ay+this.data.offsetY)*s,m=h.ascaleX*((a.ascaleX-1+this.data.offsetScaleX)*i+1),f=h.ascaleY*((a.ascaleY-1+this.data.offsetScaleY)*n+1),p=h.ashearY+(a.ashearY+this.data.offsetShearY)*r;h.updateWorldTransformWith(d,u,c,m,f,h.ashearX,p)}}}class Qt{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;data;bones;slots;drawOrder;ikConstraints;transformConstraints;pathConstraints;physicsConstraints;_updateCache=new Array;skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return Qt.yDown?-this._scaleY:this._scaleY}set scaleY(t){this._scaleY=t}x=0;y=0;time=0;constructor(t){if(!t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(let e=0;e<t.bones.length;e++){let s,i=t.bones[e];if(i.parent){let t=this.bones[i.parent.index];s=new Nt(i,this,t),t.children.push(s)}else s=new Nt(i,this,null);this.bones.push(s)}this.slots=new Array,this.drawOrder=new Array;for(let e=0;e<t.slots.length;e++){let s=t.slots[e],i=this.bones[s.boneData.index],n=new Jt(s,i);this.slots.push(n),this.drawOrder.push(n)}this.ikConstraints=new Array;for(let e=0;e<t.ikConstraints.length;e++){let s=t.ikConstraints[e];this.ikConstraints.push(new zt(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new Kt(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new jt(s,this))}this.physicsConstraints=new Array;for(let e=0;e<t.physicsConstraints.length;e++){let s=t.physicsConstraints[e];this.physicsConstraints.push(new Ht(s,this))}this.color=new n(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.sorted=s.data.skinRequired,s.active=!s.sorted}if(this.skin){let t=this.skin.bones;for(let e=0,s=this.skin.bones.length;e<s;e++){let s=this.bones[t[e].index];do{s.sorted=!1,s.active=!0,s=s.parent}while(s)}}let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=this.physicsConstraints,r=e.length,a=s.length,o=i.length,l=this.physicsConstraints.length,h=r+a+o+l;t:for(let t=0;t<h;t++){for(let s=0;s<r;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<a;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<o;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}for(let e=0;e<l;e++){const s=n[e];if(s.data.order==t){this.sortPhysicsConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),1==s.length)this._updateCache.push(t),this.sortReset(i.children);else{let e=s[s.length-1];this.sortBone(e),this._updateCache.push(t),this.sortReset(i.children),e.sorted=!0}}sortPathConstraint(t){if(t.active=t.target.bone.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target,s=e.data.index,i=e.bone;this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,s,i);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],s,i);let n=e.getAttachment();n instanceof Xt&&this.sortPathConstraintAttachmentWith(n,i);let r=t.bones,a=r.length;for(let t=0;t<a;t++)this.sortBone(r[t]);this._updateCache.push(t);for(let t=0;t<a;t++)this.sortReset(r[t].children);for(let t=0;t<a;t++)r[t].sorted=!0}sortTransformConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&l.contains(this.skin.constraints,t.data,!0)),!t.active)return;this.sortBone(t.target);let e=t.bones,s=e.length;if(t.data.local)for(let t=0;t<s;t++){let s=e[t];this.sortBone(s.parent),this.sortBone(s)}else for(let t=0;t<s;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<s;t++)this.sortReset(e[t].children);for(let t=0;t<s;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,s){let i=t.attachments[e];if(i)for(let t in i)this.sortPathConstraintAttachmentWith(i[t],s)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof Xt))return;let s=t.bones;if(s){let t=this.bones;for(let e=0,i=s.length;e<i;){let i=s[e++];for(i+=e;e<i;)this.sortBone(t[s[e++]])}}else this.sortBone(e)}sortPhysicsConstraint(t){const e=t.bone;t.active=e.active&&(!t.data.skinRequired||null!=this.skin&&l.contains(this.skin.constraints,t.data,!0)),t.active&&(this.sortBone(e),this._updateCache.push(t),this.sortReset(e.children),e.sorted=!0)}sortBone(t){if(!t)return;if(t.sorted)return;let e=t.parent;e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,s=t.length;e<s;e++){let s=t[e];s.active&&(s.sorted&&this.sortReset(s.children),s.sorted=!1)}}updateWorldTransform(t){if(null==t)throw new Error("physics is undefined");let e=this.bones;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.ax=s.x,s.ay=s.y,s.arotation=s.rotation,s.ascaleX=s.scaleX,s.ascaleY=s.scaleY,s.ashearX=s.shearX,s.ashearY=s.shearY}let s=this._updateCache;for(let e=0,i=s.length;e<i;e++)s[e].update(t)}updateWorldTransformWith(t,e){let s=this.getRootBone();if(!s)throw new Error("Root bone must not be null.");let i=e.a,n=e.b,a=e.c,o=e.d;s.worldX=i*this.x+n*this.y+e.worldX,s.worldY=a*this.x+o*this.y+e.worldY;const l=(s.rotation+s.shearX)*r.degRad,h=(s.rotation+90+s.shearY)*r.degRad,c=Math.cos(l)*s.scaleX,d=Math.cos(h)*s.scaleY,u=Math.sin(l)*s.scaleX,m=Math.sin(h)*s.scaleY;s.a=(i*c+n*u)*this.scaleX,s.b=(i*d+n*m)*this.scaleX,s.c=(a*c+o*u)*this.scaleY,s.d=(a*d+o*m)*this.scaleY;let f=this._updateCache;for(let e=0,i=f.length;e<i;e++){let i=f[e];i!=s&&i.update(t)}}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){for(const t of this.bones)t.setToSetupPose();for(const t of this.ikConstraints)t.setToSetupPose();for(const t of this.transformConstraints)t.setToSetupPose();for(const t of this.pathConstraints)t.setToSetupPose();for(const t of this.physicsConstraints)t.setToSetupPose()}setSlotsToSetupPose(){let t=this.slots;l.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}setSkinByName(t){let e=this.data.findSkin(t);if(!e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(t!=this.skin){if(t)if(this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s],n=i.data.attachmentName;if(n){let e=t.getAttachment(s,n);e&&i.setAttachment(e)}}}this.skin=t,this.updateCache()}}getAttachmentByName(t,e){let s=this.data.findSlot(t);if(!s)throw new Error(`Can't find slot with name ${t}`);return this.getAttachment(s.index,e)}getAttachment(t,e){if(!e)throw new Error("attachmentName cannot be null.");if(this.skin){let s=this.skin.getAttachment(t,e);if(s)return s}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(!t)throw new Error("slotName cannot be null.");let s=this.slots;for(let i=0,n=s.length;i<n;i++){let n=s[i];if(n.data.name==t){let s=null;if(e&&(s=this.getAttachment(i,e),!s))throw new Error("Attachment not found: "+e+", for slot: "+t);return void n.setAttachment(s)}}throw new Error("Slot not found: "+t)}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.ikConstraints.find((e=>e.data.name==t))??null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.transformConstraints.find((e=>e.data.name==t))??null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");return this.pathConstraints.find((e=>e.data.name==t))??null}findPhysicsConstraint(t){if(null==t)throw new Error("constraintName cannot be null.");return this.physicsConstraints.find((e=>e.data.name==t))??null}getBoundsRect(){let t=new c,e=new c;return this.getBounds(t,e),{x:t.x,y:t.y,width:e.x,height:e.y}}getBounds(t,e,s=new Array(2),i=null){if(!t)throw new Error("offset cannot be null.");if(!e)throw new Error("size cannot be null.");let n=this.drawOrder,r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let t=0,e=n.length;t<e;t++){let e=n[t];if(!e.bone.active)continue;let c=0,d=null,u=null,m=e.getAttachment();if(m instanceof Vt)c=8,d=l.setArraySize(s,c,0),m.computeWorldVertices(e,d,0,2),u=Qt.quadTriangles;else if(m instanceof Pt){let t=m;c=t.worldVerticesLength,d=l.setArraySize(s,c,0),t.computeWorldVertices(e,0,c,d,0,2),u=t.triangles}else if(m instanceof wt&&null!=i){i.clipStart(e,m);continue}if(d&&u){null!=i&&i.isClipping()&&(i.clipTriangles(d,u,u.length),d=i.clippedVertices,c=i.clippedVertices.length);for(let t=0,e=d.length;t<e;t+=2){let e=d[t],s=d[t+1];r=Math.min(r,e),a=Math.min(a,s),o=Math.max(o,e),h=Math.max(h,s)}}null!=i&&i.clipEndWithSlot(e)}null!=i&&i.clipEnd(),t.set(r,a),e.set(o-r,h-a)}update(t){this.time+=t}physicsTranslate(t,e){const s=this.physicsConstraints;for(let i=0,n=s.length;i<n;i++)s[i].translate(t,e)}physicsRotate(t,e,s){const i=this.physicsConstraints;for(let n=0,r=i.length;n<r;n++)i[n].rotate(t,e,s)}}t.Physics=void 0,(At=t.Physics||(t.Physics={}))[At.none=0]="none",At[At.reset=1]="reset",At[At.update=2]="update",At[At.pose=3]="pose";class Zt extends Lt{_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;constructor(t){super(t,0,!1)}}class te{name=null;bones=new Array;slots=new Array;skins=new Array;defaultSkin=null;events=new Array;animations=new Array;ikConstraints=new Array;transformConstraints=new Array;pathConstraints=new Array;physicsConstraints=new Array;x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=0;imagesPath=null;audioPath=null;findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSkin(t){if(!t)throw new Error("skinName cannot be null.");let e=this.skins;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findEvent(t){if(!t)throw new Error("eventDataName cannot be null.");let e=this.events;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findAnimation(t){if(!t)throw new Error("animationName cannot be null.");let e=this.animations;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findIkConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findTransformConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findPathConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}findPhysicsConstraint(t){if(!t)throw new Error("constraintName cannot be null.");const e=this.physicsConstraints;for(let s=0,i=e.length;s<i;s++){const i=e[s];if(i.name==t)return i}return null}}class ee{slotIndex;name;attachment;constructor(t=0,e,s){this.slotIndex=t,this.name=e,this.attachment=s}}class se{name;attachments=new Array;bones=Array();constraints=new Array;color=new n(.99607843,.61960787,.30980393,1);constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t}setAttachment(t,e,s){if(!s)throw new Error("attachment cannot be null.");let i=this.attachments;t>=i.length&&(i.length=t+1),i[t]||(i[t]={}),i[t][e]=s}addSkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];this.setAttachment(s.slotIndex,s.name,s.attachment)}}copySkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];s.attachment&&(s.attachment instanceof Pt?(s.attachment=s.attachment.newLinkedMesh(),this.setAttachment(s.slotIndex,s.name,s.attachment)):(s.attachment=s.attachment.copy(),this.setAttachment(s.slotIndex,s.name,s.attachment)))}}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}removeAttachment(t,e){let s=this.attachments[t];s&&delete s[e]}getAttachments(){let t=new Array;for(var e=0;e<this.attachments.length;e++){let s=this.attachments[e];if(s)for(let i in s){let n=s[i];n&&t.push(new ee(e,i,n))}}return t}getAttachmentsForSlot(t,e){let s=this.attachments[t];if(s)for(let i in s){let n=s[i];n&&e.push(new ee(t,i,n))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(t,e){let s=0;for(let i=0;i<t.slots.length;i++){let n=t.slots[i],r=n.getAttachment();if(r&&s<e.attachments.length){let t=e.attachments[s];for(let e in t){if(r==t[e]){let t=this.getAttachment(s,e);t&&n.setAttachment(t);break}}}s++}}}class ie{index=0;name;boneData;color=new n(1,1,1,1);darkColor=null;attachmentName=null;blendMode=t.BlendMode.Normal;visible=!0;constructor(t,e,s){if(t<0)throw new Error("index must be >= 0.");if(!e)throw new Error("name cannot be null.");if(!s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}t.BlendMode=void 0,(Tt=t.BlendMode||(t.BlendMode={}))[Tt.Normal=0]="Normal",Tt[Tt.Additive=1]="Additive",Tt[Tt.Multiply=2]="Multiply",Tt[Tt.Screen=3]="Screen";class ne extends Lt{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;offsetRotation=0;offsetX=0;offsetY=0;offsetScaleX=0;offsetScaleY=0;offsetShearY=0;relative=!1;local=!1;constructor(t){super(t,0,!1)}}class re{scale=1;attachmentLoader;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new te;i.name="";let r=new ae(e),a=r.readInt32(),o=r.readInt32();i.hash=0==o&&0==a?null:o.toString(16)+a.toString(16),i.version=r.readString(),i.x=r.readFloat(),i.y=r.readFloat(),i.width=r.readFloat(),i.height=r.readFloat(),i.referenceScale=r.readFloat()*s;let h=r.readBoolean();h&&(i.fps=r.readFloat(),i.imagesPath=r.readString(),i.audioPath=r.readString());let c=0;c=r.readInt(!0);for(let t=0;t<c;t++){let t=r.readString();if(!t)throw new Error("String in string table must not be null.");r.strings.push(t)}c=r.readInt(!0);for(let t=0;t<c;t++){let e=r.readString();if(!e)throw new Error("Bone name must not be null.");let a=0==t?null:i.bones[r.readInt(!0)],o=new Ot(t,e,a);o.rotation=r.readFloat(),o.x=r.readFloat()*s,o.y=r.readFloat()*s,o.scaleX=r.readFloat(),o.scaleY=r.readFloat(),o.shearX=r.readFloat(),o.shearY=r.readFloat(),o.length=r.readFloat()*s,o.inherit=r.readByte(),o.skinRequired=r.readBoolean(),h&&(n.rgba8888ToColor(o.color,r.readInt32()),o.icon=r.readString()??void 0,o.visible=r.readBoolean()),i.bones.push(o)}c=r.readInt(!0);for(let t=0;t<c;t++){let e=r.readString();if(!e)throw new Error("Slot name must not be null.");let s=i.bones[r.readInt(!0)],a=new ie(t,e,s);n.rgba8888ToColor(a.color,r.readInt32());let o=r.readInt32();-1!=o&&n.rgb888ToColor(a.darkColor=new n,o),a.attachmentName=r.readStringRef(),a.blendMode=r.readInt(!0),h&&(a.visible=r.readBoolean()),i.slots.push(a)}c=r.readInt(!0);for(let t,e=0;e<c;e++){let e=r.readString();if(!e)throw new Error("IK constraint data name must not be null.");let n=new Gt(e);n.order=r.readInt(!0),t=r.readInt(!0);for(let e=0;e<t;e++)n.bones.push(i.bones[r.readInt(!0)]);n.target=i.bones[r.readInt(!0)];let a=r.readByte();n.skinRequired=!!(1&a),n.bendDirection=2&a?1:-1,n.compress=!!(4&a),n.stretch=!!(8&a),n.uniform=!!(16&a),32&a&&(n.mix=64&a?r.readFloat():1),128&a&&(n.softness=r.readFloat()*s),i.ikConstraints.push(n)}c=r.readInt(!0);for(let t,e=0;e<c;e++){let e=r.readString();if(!e)throw new Error("Transform constraint data name must not be null.");let n=new ne(e);n.order=r.readInt(!0),t=r.readInt(!0);for(let e=0;e<t;e++)n.bones.push(i.bones[r.readInt(!0)]);n.target=i.bones[r.readInt(!0)];let a=r.readByte();n.skinRequired=!!(1&a),n.local=!!(2&a),n.relative=!!(4&a),8&a&&(n.offsetRotation=r.readFloat()),16&a&&(n.offsetX=r.readFloat()*s),32&a&&(n.offsetY=r.readFloat()*s),64&a&&(n.offsetScaleX=r.readFloat()),128&a&&(n.offsetScaleY=r.readFloat()),a=r.readByte(),1&a&&(n.offsetShearY=r.readFloat()),2&a&&(n.mixRotate=r.readFloat()),4&a&&(n.mixX=r.readFloat()),8&a&&(n.mixY=r.readFloat()),16&a&&(n.mixScaleX=r.readFloat()),32&a&&(n.mixScaleY=r.readFloat()),64&a&&(n.mixShearY=r.readFloat()),i.transformConstraints.push(n)}c=r.readInt(!0);for(let e,n=0;n<c;n++){let n=r.readString();if(!n)throw new Error("Path constraint data name must not be null.");let a=new $t(n);a.order=r.readInt(!0),a.skinRequired=r.readBoolean(),e=r.readInt(!0);for(let t=0;t<e;t++)a.bones.push(i.bones[r.readInt(!0)]);a.target=i.slots[r.readInt(!0)];const o=r.readByte();a.positionMode=1&o,a.spacingMode=o>>1&3,a.rotateMode=o>>3&3,128&o&&(a.offsetRotation=r.readFloat()),a.position=r.readFloat(),a.positionMode==t.PositionMode.Fixed&&(a.position*=s),a.spacing=r.readFloat(),a.spacingMode!=t.SpacingMode.Length&&a.spacingMode!=t.SpacingMode.Fixed||(a.spacing*=s),a.mixRotate=r.readFloat(),a.mixX=r.readFloat(),a.mixY=r.readFloat(),i.pathConstraints.push(a)}c=r.readInt(!0);for(let t=0;t<c;t++){const t=r.readString();if(!t)throw new Error("Physics constraint data name must not be null.");const e=new Zt(t);e.order=r.readInt(!0),e.bone=i.bones[r.readInt(!0)];let n=r.readByte();e.skinRequired=!!(1&n),2&n&&(e.x=r.readFloat()),4&n&&(e.y=r.readFloat()),8&n&&(e.rotate=r.readFloat()),16&n&&(e.scaleX=r.readFloat()),32&n&&(e.shearX=r.readFloat()),e.limit=(64&n?r.readFloat():5e3)*s,e.step=1/r.readUnsignedByte(),e.inertia=r.readFloat(),e.strength=r.readFloat(),e.damping=r.readFloat(),e.massInverse=128&n?r.readFloat():1,e.wind=r.readFloat(),e.gravity=r.readFloat(),n=r.readByte(),1&n&&(e.inertiaGlobal=!0),2&n&&(e.strengthGlobal=!0),4&n&&(e.dampingGlobal=!0),8&n&&(e.massGlobal=!0),16&n&&(e.windGlobal=!0),32&n&&(e.gravityGlobal=!0),64&n&&(e.mixGlobal=!0),e.mix=128&n?r.readFloat():1,i.physicsConstraints.push(e)}let d=this.readSkin(r,i,!0,h);d&&(i.defaultSkin=d,i.skins.push(d));{let t=i.skins.length;for(l.setArraySize(i.skins,c=t+r.readInt(!0));t<c;t++){let e=this.readSkin(r,i,!1,h);if(!e)throw new Error("readSkin() should not have returned null.");i.skins[t]=e}}c=this.linkedMeshes.length;for(let t=0;t<c;t++){let e=this.linkedMeshes[t];const s=i.skins[e.skinIndex];if(!e.parent)throw new Error("Linked mesh parent must not be null");let n=s.getAttachment(e.slotIndex,e.parent);if(!n)throw new Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?n:e.mesh,e.mesh.setParentMesh(n),null!=e.mesh.region&&e.mesh.updateRegion()}this.linkedMeshes.length=0,c=r.readInt(!0);for(let t=0;t<c;t++){let t=r.readString();if(!t)throw new Error("Event data name must not be null");let e=new Wt(t);e.intValue=r.readInt(!1),e.floatValue=r.readFloat(),e.stringValue=r.readString(),e.audioPath=r.readString(),e.audioPath&&(e.volume=r.readFloat(),e.balance=r.readFloat()),i.events.push(e)}c=r.readInt(!0);for(let t=0;t<c;t++){let t=r.readString();if(!t)throw new Error("Animatio name must not be null.");i.animations.push(this.readAnimation(r,t,i))}return i}readSkin(t,e,s,i){let r=null,a=0;if(s){if(a=t.readInt(!0),0==a)return null;r=new se("default")}else{let s=t.readString();if(!s)throw new Error("Skin name must not be null.");r=new se(s),i&&n.rgba8888ToColor(r.color,t.readInt32()),r.bones.length=t.readInt(!0);for(let s=0,i=r.bones.length;s<i;s++)r.bones[s]=e.bones[t.readInt(!0)];for(let s=0,i=t.readInt(!0);s<i;s++)r.constraints.push(e.ikConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)r.constraints.push(e.transformConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)r.constraints.push(e.pathConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)r.constraints.push(e.physicsConstraints[t.readInt(!0)]);a=t.readInt(!0)}for(let s=0;s<a;s++){let s=t.readInt(!0);for(let n=0,a=t.readInt(!0);n<a;n++){let n=t.readStringRef();if(!n)throw new Error("Attachment name must not be null");let a=this.readAttachment(t,e,r,s,n,i);a&&r.setAttachment(s,n,a)}}return r}readAttachment(t,e,s,i,r,a){let o=this.scale,h=t.readByte();const c=8&h?t.readStringRef():r;if(!c)throw new Error("Attachment name must not be null");switch(7&h){case Bt.Region:{let e=16&h?t.readStringRef():null;const i=32&h?t.readInt32():4294967295,r=64&h?this.readSequence(t):null;let a=128&h?t.readFloat():0,l=t.readFloat(),d=t.readFloat(),u=t.readFloat(),m=t.readFloat(),f=t.readFloat(),p=t.readFloat();e||(e=c);let g=this.attachmentLoader.newRegionAttachment(s,c,e,r);return g?(g.path=e,g.x=l*o,g.y=d*o,g.scaleX=u,g.scaleY=m,g.rotation=a,g.width=f*o,g.height=p*o,n.rgba8888ToColor(g.color,i),g.sequence=r,null==r&&g.updateRegion(),g):null}case Bt.BoundingBox:{let e=this.readVertices(t,!!(16&h)),i=a?t.readInt32():0,r=this.attachmentLoader.newBoundingBoxAttachment(s,c);return r?(r.worldVerticesLength=e.length,r.vertices=e.vertices,r.bones=e.bones,a&&n.rgba8888ToColor(r.color,i),r):null}case Bt.Mesh:{let e=16&h?t.readStringRef():c;const i=32&h?t.readInt32():4294967295,r=64&h?this.readSequence(t):null,l=t.readInt(!0),d=this.readVertices(t,!!(128&h)),u=this.readFloatArray(t,d.length,1),m=this.readShortArray(t,3*(d.length-l-2));let f=[],p=0,g=0;a&&(f=this.readShortArray(t,t.readInt(!0)),p=t.readFloat(),g=t.readFloat()),e||(e=c);let x=this.attachmentLoader.newMeshAttachment(s,c,e,r);return x?(x.path=e,n.rgba8888ToColor(x.color,i),x.bones=d.bones,x.vertices=d.vertices,x.worldVerticesLength=d.length,x.triangles=m,x.regionUVs=u,null==r&&x.updateRegion(),x.hullLength=l<<1,x.sequence=r,a&&(x.edges=f,x.width=p*o,x.height=g*o),x):null}case Bt.LinkedMesh:{const e=16&h?t.readStringRef():c;if(null==e)throw new Error("Path of linked mesh must not be null");const r=32&h?t.readInt32():4294967295,l=64&h?this.readSequence(t):null,d=!!(128&h),u=t.readInt(!0),m=t.readStringRef();let f=0,p=0;a&&(f=t.readFloat(),p=t.readFloat());let g=this.attachmentLoader.newMeshAttachment(s,c,e,l);return g?(g.path=e,n.rgba8888ToColor(g.color,r),g.sequence=l,a&&(g.width=f*o,g.height=p*o),this.linkedMeshes.push(new oe(g,u,i,m,d)),g):null}case Bt.Path:{const e=!!(16&h),i=!!(32&h),r=this.readVertices(t,!!(64&h)),d=l.newArray(r.length/6,0);for(let e=0,s=d.length;e<s;e++)d[e]=t.readFloat()*o;const u=a?t.readInt32():0,m=this.attachmentLoader.newPathAttachment(s,c);return m?(m.closed=e,m.constantSpeed=i,m.worldVerticesLength=r.length,m.vertices=r.vertices,m.bones=r.bones,m.lengths=d,a&&n.rgba8888ToColor(m.color,u),m):null}case Bt.Point:{const e=t.readFloat(),i=t.readFloat(),r=t.readFloat(),l=a?t.readInt32():0,h=this.attachmentLoader.newPointAttachment(s,c);return h?(h.x=i*o,h.y=r*o,h.rotation=e,a&&n.rgba8888ToColor(h.color,l),h):null}case Bt.Clipping:{const i=t.readInt(!0),r=this.readVertices(t,!!(16&h));let o=a?t.readInt32():0,l=this.attachmentLoader.newClippingAttachment(s,c);return l?(l.endSlot=e.slots[i],l.worldVerticesLength=r.length,l.vertices=r.vertices,l.bones=r.bones,a&&n.rgba8888ToColor(l.color,o),l):null}}return null}readSequence(t){let e=new m(t.readInt(!0));return e.start=t.readInt(!0),e.digits=t.readInt(!0),e.setupIndex=t.readInt(!0),e}readVertices(t,e){const s=this.scale,i=t.readInt(!0),n=new le;if(n.length=i<<1,!e)return n.vertices=this.readFloatArray(t,n.length,s),n;let r=new Array,a=new Array;for(let e=0;e<i;e++){let e=t.readInt(!0);a.push(e);for(let i=0;i<e;i++)a.push(t.readInt(!0)),r.push(t.readFloat()*s),r.push(t.readFloat()*s),r.push(t.readFloat())}return n.vertices=l.toFloatArray(r),n.bones=a,n}readFloatArray(t,e,s){let i=new Array(e);if(1==s)for(let s=0;s<e;s++)i[s]=t.readFloat();else for(let n=0;n<e;n++)i[n]=t.readFloat()*s;return i}readShortArray(t,e){let s=new Array(e);for(let i=0;i<e;i++)s[i]=t.readInt(!0);return s}readAnimation(e,s,i){e.readInt(!0);let n=new Array,r=this.scale;for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0),r=i-1;switch(s){case ve:{let s=new N(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readStringRef());n.push(s);break}case ke:{let s=e.readInt(!0),a=new X(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;for(let t=0,s=0;a.setFrame(t,o,l,h,c,d),t!=r;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,r=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255;switch(e.readByte()){case qe:a.setStepped(t);break;case Ue:de(e,a,s++,t,0,o,i,l,n,1),de(e,a,s++,t,1,o,i,h,r,1),de(e,a,s++,t,2,o,i,c,u,1),de(e,a,s++,t,3,o,i,d,m,1)}o=i,l=n,h=r,c=u,d=m}n.push(a);break}case Ie:{let s=e.readInt(!0),a=new _(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255;for(let t=0,s=0;a.setFrame(t,o,l,h,c),t!=r;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,r=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;switch(e.readByte()){case qe:a.setStepped(t);break;case Ue:de(e,a,s++,t,0,o,i,l,n,1),de(e,a,s++,t,1,o,i,h,r,1),de(e,a,s++,t,2,o,i,c,d,1)}o=i,l=n,h=r,c=d}n.push(a);break}case Ae:{let s=e.readInt(!0),a=new D(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255;for(let t=0,s=0;a.setFrame(t,o,l,h,c,d,u,m,f),t!=r;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,r=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255,w=e.readUnsignedByte()/255,b=e.readUnsignedByte()/255;switch(e.readByte()){case qe:a.setStepped(t);break;case Ue:de(e,a,s++,t,0,o,i,l,n,1),de(e,a,s++,t,1,o,i,h,r,1),de(e,a,s++,t,2,o,i,c,p,1),de(e,a,s++,t,3,o,i,d,g,1),de(e,a,s++,t,4,o,i,u,x,1),de(e,a,s++,t,5,o,i,m,w,1),de(e,a,s++,t,6,o,i,f,b,1)}o=i,l=n,h=r,c=p,d=g,u=x,m=w,f=b}n.push(a);break}case Te:{let s=e.readInt(!0),a=new O(i,s,t),o=e.readFloat(),l=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255;for(let t=0,s=0;a.setFrame(t,o,l,h,c,d,u,m),t!=r;t++){let i=e.readFloat(),n=e.readUnsignedByte()/255,r=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255;switch(e.readByte()){case qe:a.setStepped(t);break;case Ue:de(e,a,s++,t,0,o,i,l,n,1),de(e,a,s++,t,1,o,i,h,r,1),de(e,a,s++,t,2,o,i,c,f,1),de(e,a,s++,t,3,o,i,d,p,1),de(e,a,s++,t,4,o,i,u,g,1),de(e,a,s++,t,5,o,i,m,x,1)}o=i,l=n,h=r,c=f,d=p,u=g,m=x}n.push(a);break}case Be:{let s=new V(i,e.readInt(!0),t),a=e.readFloat(),o=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,a,o),t!=r;t++){let n=e.readFloat(),r=e.readUnsignedByte()/255;switch(e.readByte()){case qe:s.setStepped(t);break;case Ue:de(e,s,i++,t,0,a,n,o,r,1)}a=n,o=r}n.push(s)}}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0);if(s==Se){let s=new P(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readByte());n.push(s);continue}let a=e.readInt(!0);switch(s){case ue:n.push(he(e,new k(i,a,t),1));break;case me:n.push(ce(e,new I(i,a,t),r));break;case fe:n.push(he(e,new A(i,a,t),r));break;case pe:n.push(he(e,new T(i,a,t),r));break;case ge:n.push(ce(e,new B(i,a,t),1));break;case xe:n.push(he(e,new C(i,a,t),1));break;case we:n.push(he(e,new F(i,a,t),1));break;case be:n.push(ce(e,new E(i,a,t),1));break;case ye:n.push(he(e,new Y(i,a,t),1));break;case Me:n.push(he(e,new R(i,a,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,a=new W(s,e.readInt(!0),t),o=e.readByte(),l=e.readFloat(),h=1&o?2&o?e.readFloat():1:0,c=4&o?e.readFloat()*r:0;for(let t=0,s=0;a.setFrame(t,l,h,c,8&o?1:-1,!!(16&o),!!(32&o)),t!=i;t++){o=e.readByte();const i=e.readFloat(),n=1&o?2&o?e.readFloat():1:0,d=4&o?e.readFloat()*r:0;64&o?a.setStepped(t):128&o&&(de(e,a,s++,t,0,l,i,h,n,1),de(e,a,s++,t,1,l,i,c,d,r)),l=i,h=n,c=d}n.push(a)}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,r=new z(s,e.readInt(!0),t),a=e.readFloat(),o=e.readFloat(),l=e.readFloat(),h=e.readFloat(),c=e.readFloat(),d=e.readFloat(),u=e.readFloat();for(let t=0,s=0;r.setFrame(t,a,o,l,h,c,d,u),t!=i;t++){let i=e.readFloat(),n=e.readFloat(),m=e.readFloat(),f=e.readFloat(),p=e.readFloat(),g=e.readFloat(),x=e.readFloat();switch(e.readByte()){case qe:r.setStepped(t);break;case Ue:de(e,r,s++,t,0,a,i,o,n,1),de(e,r,s++,t,1,a,i,l,m,1),de(e,r,s++,t,2,a,i,h,f,1),de(e,r,s++,t,3,a,i,c,p,1),de(e,r,s++,t,4,a,i,d,g,1),de(e,r,s++,t,5,a,i,u,x,1)}a=i,o=n,l=m,h=f,c=p,d=g,u=x}n.push(r)}for(let s=0,a=e.readInt(!0);s<a;s++){let s=e.readInt(!0),a=i.pathConstraints[s];for(let i=0,o=e.readInt(!0);i<o;i++){const i=e.readByte(),o=e.readInt(!0),l=e.readInt(!0);switch(i){case Ee:n.push(he(e,new G(o,l,s),a.positionMode==t.PositionMode.Fixed?r:1));break;case Ye:n.push(he(e,new $(o,l,s),a.spacingMode==t.SpacingMode.Length||a.spacingMode==t.SpacingMode.Fixed?r:1));break;case Re:let i=new j(o,l,s),h=e.readFloat(),c=e.readFloat(),d=e.readFloat(),u=e.readFloat();for(let t=0,s=0,n=i.getFrameCount()-1;i.setFrame(t,h,c,d,u),t!=n;t++){let n=e.readFloat(),r=e.readFloat(),a=e.readFloat(),o=e.readFloat();switch(e.readByte()){case qe:i.setStepped(t);break;case Ue:de(e,i,s++,t,0,h,n,c,r,1),de(e,i,s++,t,1,h,n,d,a,1),de(e,i,s++,t,2,h,n,u,o,1)}h=n,c=r,d=a,u=o}n.push(i)}}}for(let t=0,s=e.readInt(!0);t<s;t++){const t=e.readInt(!0)-1;for(let s=0,i=e.readInt(!0);s<i;s++){const s=e.readByte(),i=e.readInt(!0);if(s==Le){const s=new it(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat());n.push(s);continue}const r=e.readInt(!0);switch(s){case Pe:n.push(he(e,new J(i,r,t),1));break;case Xe:n.push(he(e,new K(i,r,t),1));break;case _e:n.push(he(e,new Q(i,r,t),1));break;case Ve:n.push(he(e,new Z(i,r,t),1));break;case De:n.push(he(e,new tt(i,r,t),1));break;case Oe:n.push(he(e,new et(i,r,t),1));break;case Ne:n.push(he(e,new st(i,r,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=i.skins[e.readInt(!0)];for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readInt(!0);for(let i=0,a=e.readInt(!0);i<a;i++){let i=e.readStringRef();if(!i)throw new Error("attachmentName must not be null.");let a=t.getAttachment(s,i),o=e.readByte(),h=e.readInt(!0),c=h-1;switch(o){case Ce:{let t=a,i=t.bones,o=t.vertices,d=i?o.length/3*2:o.length,u=e.readInt(!0),m=new L(h,u,s,t),f=e.readFloat();for(let t=0,s=0;;t++){let n,a=e.readInt(!0);if(0==a)n=i?l.newFloatArray(d):o;else{n=l.newFloatArray(d);let t=e.readInt(!0);if(a+=t,1==r)for(let s=t;s<a;s++)n[s]=e.readFloat();else for(let s=t;s<a;s++)n[s]=e.readFloat()*r;if(!i)for(let t=0,e=n.length;t<e;t++)n[t]+=o[t]}if(m.setFrame(t,f,n),t==c)break;let h=e.readFloat();switch(e.readByte()){case qe:m.setStepped(t);break;case Ue:de(e,m,s++,t,0,f,h,0,1,1)}f=h}n.push(m);break}case Fe:{let t=new nt(h,s,a);for(let s=0;s<h;s++){let i=e.readFloat(),n=e.readInt32();t.setFrame(s,i,p[15&n],n>>4,e.readFloat())}n.push(t);break}}}}}let a=e.readInt(!0);if(a>0){let t=new U(a),s=i.slots.length;for(let i=0;i<a;i++){let n=e.readFloat(),r=e.readInt(!0),a=l.newArray(s,0);for(let t=s-1;t>=0;t--)a[t]=-1;let o=l.newArray(s-r,0),h=0,c=0;for(let t=0;t<r;t++){let t=e.readInt(!0);for(;h!=t;)o[c++]=h++;a[h+e.readInt(!0)]=h++}for(;h<s;)o[c++]=h++;for(let t=s-1;t>=0;t--)-1==a[t]&&(a[t]=o[--c]);t.setFrame(i,n,a)}n.push(t)}let o=e.readInt(!0);if(o>0){let t=new q(o);for(let s=0;s<o;s++){let n=e.readFloat(),r=i.events[e.readInt(!0)],a=new Ut(n,r);a.intValue=e.readInt(!1),a.floatValue=e.readFloat(),a.stringValue=e.readString(),null==a.stringValue&&(a.stringValue=r.stringValue),a.data.audioPath&&(a.volume=e.readFloat(),a.balance=e.readFloat()),t.setFrame(s,a)}n.push(t)}let h=0;for(let t=0,e=n.length;t<e;t++)h=Math.max(h,n[t].getDuration());return new g(s,n,h)}}class ae{strings;index;buffer;constructor(t,e=new Array,s=0,i=new DataView(t instanceof ArrayBuffer?t:t.buffer)){this.strings=e,this.index=s,this.buffer=i}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){let t=this.buffer.getInt16(this.index);return this.index+=2,t}readInt32(){let t=this.buffer.getInt32(this.index);return this.index+=4,t}readInt(t){let e=this.readByte(),s=127&e;return 128&e&&(e=this.readByte(),s|=(127&e)<<7,128&e&&(e=this.readByte(),s|=(127&e)<<14,128&e&&(e=this.readByte(),s|=(127&e)<<21,128&e&&(e=this.readByte(),s|=(127&e)<<28)))),t?s:s>>>1^-(1&s)}readStringRef(){let t=this.readInt(!0);return 0==t?null:this.strings[t-1]}readString(){let t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;let e="";for(let s=0;s<t;){let t=this.readUnsignedByte();switch(t>>4){case 12:case 13:e+=String.fromCharCode((31&t)<<6|63&this.readByte()),s+=2;break;case 14:e+=String.fromCharCode((15&t)<<12|(63&this.readByte())<<6|63&this.readByte()),s+=3;break;default:e+=String.fromCharCode(t),s++}}return e}readFloat(){let t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return 0!=this.readByte()}}class oe{parent;skinIndex;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,n){this.mesh=t,this.skinIndex=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=n}}class le{bones;vertices;length;constructor(t=null,e=null,s=0){this.bones=t,this.vertices=e,this.length=s}}function he(t,e,s){let i=t.readFloat(),n=t.readFloat()*s;for(let r=0,a=0,o=e.getFrameCount()-1;e.setFrame(r,i,n),r!=o;r++){let o=t.readFloat(),l=t.readFloat()*s;switch(t.readByte()){case qe:e.setStepped(r);break;case Ue:de(t,e,a++,r,0,i,o,n,l,s)}i=o,n=l}return e}function ce(t,e,s){let i=t.readFloat(),n=t.readFloat()*s,r=t.readFloat()*s;for(let a=0,o=0,l=e.getFrameCount()-1;e.setFrame(a,i,n,r),a!=l;a++){let l=t.readFloat(),h=t.readFloat()*s,c=t.readFloat()*s;switch(t.readByte()){case qe:e.setStepped(a);break;case Ue:de(t,e,o++,a,0,i,l,n,h,s),de(t,e,o++,a,1,i,l,r,c,s)}i=l,n=h,r=c}return e}function de(t,e,s,i,n,r,a,o,l,h){e.setBezier(s,i,n,r,o,t.readFloat(),t.readFloat()*h,t.readFloat(),t.readFloat()*h,a,l)}!function(t){t[t.Region=0]="Region",t[t.BoundingBox=1]="BoundingBox",t[t.Mesh=2]="Mesh",t[t.LinkedMesh=3]="LinkedMesh",t[t.Path=4]="Path",t[t.Point=5]="Point",t[t.Clipping=6]="Clipping"}(Bt||(Bt={}));const ue=0,me=1,fe=2,pe=3,ge=4,xe=5,we=6,be=7,ye=8,Me=9,Se=10,ve=0,ke=1,Ie=2,Ae=3,Te=4,Be=5,Ce=0,Fe=1,Ee=0,Ye=1,Re=2,Pe=0,Xe=1,_e=2,Ve=4,De=5,Oe=6,Ne=7,Le=8,qe=1,Ue=2;class We{convexPolygons=new Array;convexPolygonsIndices=new Array;indicesArray=new Array;isConcaveArray=new Array;triangles=new Array;polygonPool=new h((()=>new Array));polygonIndicesPool=new h((()=>new Array));triangulate(t){let e=t,s=t.length>>1,i=this.indicesArray;i.length=0;for(let t=0;t<s;t++)i[t]=t;let n=this.isConcaveArray;n.length=0;for(let t=0,r=s;t<r;++t)n[t]=We.isConcave(t,s,e,i);let r=this.triangles;for(r.length=0;s>3;){let t=s-1,a=0,o=1;for(;;){t:if(!n[a]){let r=i[t]<<1,l=i[a]<<1,h=i[o]<<1,c=e[r],d=e[r+1],u=e[l],m=e[l+1],f=e[h],p=e[h+1];for(let r=(o+1)%s;r!=t;r=(r+1)%s){if(!n[r])continue;let t=i[r]<<1,s=e[t],a=e[t+1];if(We.positiveArea(f,p,c,d,s,a)&&We.positiveArea(c,d,u,m,s,a)&&We.positiveArea(u,m,f,p,s,a))break t}break}if(0==o){do{if(!n[a])break;a--}while(a>0);break}t=a,a=o,o=(o+1)%s}r.push(i[(s+a-1)%s]),r.push(i[a]),r.push(i[(a+1)%s]),i.splice(a,1),n.splice(a,1),s--;let l=(s+a-1)%s,h=a==s?0:a;n[l]=We.isConcave(l,s,e,i),n[h]=We.isConcave(h,s,e,i)}return 3==s&&(r.push(i[2]),r.push(i[0]),r.push(i[1])),r}decompose(t,e){let s=t,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;let n=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(n),n.length=0;let r=this.polygonIndicesPool.obtain();r.length=0;let a=this.polygonPool.obtain();a.length=0;let o=-1,l=0;for(let t=0,h=e.length;t<h;t+=3){let h=e[t]<<1,c=e[t+1]<<1,d=e[t+2]<<1,u=s[h],m=s[h+1],f=s[c],p=s[c+1],g=s[d],x=s[d+1],w=!1;if(o==h){let t=a.length-4,e=We.winding(a[t],a[t+1],a[t+2],a[t+3],g,x),s=We.winding(g,x,a[0],a[1],a[2],a[3]);e==l&&s==l&&(a.push(g),a.push(x),r.push(d),w=!0)}w||(a.length>0?(i.push(a),n.push(r)):(this.polygonPool.free(a),this.polygonIndicesPool.free(r)),a=this.polygonPool.obtain(),a.length=0,a.push(u),a.push(m),a.push(f),a.push(p),a.push(g),a.push(x),r=this.polygonIndicesPool.obtain(),r.length=0,r.push(h),r.push(c),r.push(d),l=We.winding(u,m,f,p,g,x),o=h)}a.length>0&&(i.push(a),n.push(r));for(let t=0,e=i.length;t<e;t++){if(r=n[t],0==r.length)continue;let s=r[0],o=r[r.length-1];a=i[t];let l=a.length-4,h=a[l],c=a[l+1],d=a[l+2],u=a[l+3],m=a[0],f=a[1],p=a[2],g=a[3],x=We.winding(h,c,d,u,m,f);for(let l=0;l<e;l++){if(l==t)continue;let e=n[l];if(3!=e.length)continue;let w=e[0],b=e[1],y=e[2],M=i[l],S=M[M.length-2],v=M[M.length-1];if(w!=s||b!=o)continue;let k=We.winding(h,c,d,u,S,v),I=We.winding(S,v,m,f,p,g);k==x&&I==x&&(M.length=0,e.length=0,a.push(S),a.push(v),r.push(y),h=d,c=u,d=S,u=v,l=0)}}for(let t=i.length-1;t>=0;t--)a=i[t],0==a.length&&(i.splice(t,1),this.polygonPool.free(a),r=n[t],n.splice(t,1),this.polygonIndicesPool.free(r));return i}static isConcave(t,e,s,i){let n=i[(e+t-1)%e]<<1,r=i[t]<<1,a=i[(t+1)%e]<<1;return!this.positiveArea(s[n],s[n+1],s[r],s[r+1],s[a],s[a+1])}static positiveArea(t,e,s,i,n,r){return t*(r-i)+s*(e-r)+n*(i-e)>=0}static winding(t,e,s,i,n,r){let a=s-t,o=i-e;return n*o-r*a+a*e-t*o>=0?1:-1}}class ze{triangulator=new We;clippingPolygon=new Array;clipOutput=new Array;clippedVertices=new Array;clippedUVs=new Array;clippedTriangles=new Array;scratch=new Array;clipAttachment=null;clippingPolygons=null;clipStart(t,e){if(this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=l.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;ze.makeClockwise(n);let r=this.clippingPolygons=this.triangulator.decompose(n,this.triangulator.triangulate(n));for(let t=0,e=r.length;t<e;t++){let e=r[t];ze.makeClockwise(e),e.push(e[0]),e.push(e[1])}return r.length}clipEndWithSlot(t){this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,s,i,n,r,a,o){let l,h,c,d,u,m;"number"==typeof e?(l=s,h=i,c=n,d=r,u=a,m=o):(l=e,h=s,c=i,d=n,u=r,m=a),c&&d&&u&&"boolean"==typeof m?this.clipTrianglesRender(t,l,h,c,d,u,m):this.clipTrianglesNoRender(t,l,h)}clipTrianglesNoRender(t,e,s){let i=this.clipOutput,n=this.clippedVertices,r=this.clippedTriangles,a=this.clippingPolygons,o=a.length,h=0;n.length=0,r.length=0;for(let c=0;c<s;c+=3){let s=e[c]<<1,d=t[s],u=t[s+1];s=e[c+1]<<1;let m=t[s],f=t[s+1];s=e[c+2]<<1;let p=t[s],g=t[s+1];for(let t=0;t<o;t++){let e=n.length;if(!this.clip(d,u,m,f,p,g,a[t],i)){let t=l.setArraySize(n,e+6);t[e]=d,t[e+1]=u,t[e+2]=m,t[e+3]=f,t[e+4]=p,t[e+5]=g,e=r.length;let s=l.setArraySize(r,e+3);s[e]=h,s[e+1]=h+1,s[e+2]=h+2,h+=3;break}{let t=i.length;if(0==t)continue;let s=t>>1,a=this.clipOutput,o=l.setArraySize(n,e+2*s);for(let s=0;s<t;s+=2,e+=2){let t=a[s],i=a[s+1];o[e]=t,o[e+1]=i}e=r.length;let c=l.setArraySize(r,e+3*(s-2));s--;for(let t=1;t<s;t++,e+=3)c[e]=h,c[e+1]=h+t,c[e+2]=h+t+1;h+=s+1}}}}clipTrianglesRender(t,e,s,i,n,r,a){let o=this.clipOutput,h=this.clippedVertices,c=this.clippedTriangles,d=this.clippingPolygons,u=d.length,m=a?12:8,f=0;h.length=0,c.length=0;for(let p=0;p<s;p+=3){let s=e[p]<<1,g=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[p+1]<<1;let y=t[s],M=t[s+1],S=i[s],v=i[s+1];s=e[p+2]<<1;let k=t[s],I=t[s+1],A=i[s],T=i[s+1];for(let t=0;t<u;t++){let e=h.length;if(!this.clip(g,x,y,M,k,I,d[t],o)){let t=l.setArraySize(h,e+3*m);t[e]=g,t[e+1]=x,t[e+2]=n.r,t[e+3]=n.g,t[e+4]=n.b,t[e+5]=n.a,a?(t[e+6]=w,t[e+7]=b,t[e+8]=r.r,t[e+9]=r.g,t[e+10]=r.b,t[e+11]=r.a,t[e+12]=y,t[e+13]=M,t[e+14]=n.r,t[e+15]=n.g,t[e+16]=n.b,t[e+17]=n.a,t[e+18]=S,t[e+19]=v,t[e+20]=r.r,t[e+21]=r.g,t[e+22]=r.b,t[e+23]=r.a,t[e+24]=k,t[e+25]=I,t[e+26]=n.r,t[e+27]=n.g,t[e+28]=n.b,t[e+29]=n.a,t[e+30]=A,t[e+31]=T,t[e+32]=r.r,t[e+33]=r.g,t[e+34]=r.b,t[e+35]=r.a):(t[e+6]=w,t[e+7]=b,t[e+8]=y,t[e+9]=M,t[e+10]=n.r,t[e+11]=n.g,t[e+12]=n.b,t[e+13]=n.a,t[e+14]=S,t[e+15]=v,t[e+16]=k,t[e+17]=I,t[e+18]=n.r,t[e+19]=n.g,t[e+20]=n.b,t[e+21]=n.a,t[e+22]=A,t[e+23]=T),e=c.length;let s=l.setArraySize(c,e+3);s[e]=f,s[e+1]=f+1,s[e+2]=f+2,f+=3;break}{let t=o.length;if(0==t)continue;let s=M-I,i=k-y,d=g-k,u=I-x,p=1/(s*d+i*(x-I)),B=t>>1,C=this.clipOutput,F=l.setArraySize(h,e+B*m);for(let o=0;o<t;o+=2,e+=m){let t=C[o],l=C[o+1];F[e]=t,F[e+1]=l,F[e+2]=n.r,F[e+3]=n.g,F[e+4]=n.b,F[e+5]=n.a;let h=t-k,c=l-I,m=(s*h+i*c)*p,f=(u*h+d*c)*p,g=1-m-f;F[e+6]=w*m+S*f+A*g,F[e+7]=b*m+v*f+T*g,a&&(F[e+8]=r.r,F[e+9]=r.g,F[e+10]=r.b,F[e+11]=r.a)}e=c.length;let E=l.setArraySize(c,e+3*(B-2));B--;for(let t=1;t<B;t++,e+=3)E[e]=f,E[e+1]=f+t,E[e+2]=f+t+1;f+=B+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,r=this.clippedVertices,a=this.clippedUVs,o=this.clippedTriangles,h=this.clippingPolygons,c=h.length,d=0;r.length=0,a.length=0,o.length=0;for(let u=0;u<s;u+=3){let s=e[u]<<1,m=t[s],f=t[s+1],p=i[s],g=i[s+1];s=e[u+1]<<1;let x=t[s],w=t[s+1],b=i[s],y=i[s+1];s=e[u+2]<<1;let M=t[s],S=t[s+1],v=i[s],k=i[s+1];for(let t=0;t<c;t++){let e=r.length;if(!this.clip(m,f,x,w,M,S,h[t],n)){let t=l.setArraySize(r,e+6);t[e]=m,t[e+1]=f,t[e+2]=x,t[e+3]=w,t[e+4]=M,t[e+5]=S;let s=l.setArraySize(a,e+6);s[e]=p,s[e+1]=g,s[e+2]=b,s[e+3]=y,s[e+4]=v,s[e+5]=k,e=o.length;let i=l.setArraySize(o,e+3);i[e]=d,i[e+1]=d+1,i[e+2]=d+2,d+=3;break}{let t=n.length;if(0==t)continue;let s=w-S,i=M-x,h=m-M,c=S-f,u=1/(s*h+i*(f-S)),I=t>>1,A=this.clipOutput,T=l.setArraySize(r,e+2*I),B=l.setArraySize(a,e+2*I);for(let n=0;n<t;n+=2,e+=2){let t=A[n],r=A[n+1];T[e]=t,T[e+1]=r;let a=t-M,o=r-S,l=(s*a+i*o)*u,d=(c*a+h*o)*u,m=1-l-d;B[e]=p*l+b*d+v*m,B[e+1]=g*l+y*d+k*m}e=o.length;let C=l.setArraySize(o,e+3*(I-2));I--;for(let t=1;t<I;t++,e+=3)C[e]=d,C[e+1]=d+t,C[e+2]=d+t+1;d+=I+1}}}}clip(t,e,s,i,n,r,a,o){let l,h=o,c=!1;a.length%4>=2?(l=o,o=this.scratch):l=this.scratch,l.length=0,l.push(t),l.push(e),l.push(s),l.push(i),l.push(n),l.push(r),l.push(t),l.push(e),o.length=0;let d=a.length-4,u=a;for(let t=0;;t+=2){let e=u[t],s=u[t+1],i=e-u[t+2],n=s-u[t+3],r=o.length,a=l;for(let t=0,r=l.length-2;t<r;){let r=a[t],l=a[t+1];t+=2;let h=a[t],d=a[t+1],u=n*(e-h)>i*(s-d),m=n*(e-r)-i*(s-l);if(m>0){if(u){o.push(h),o.push(d);continue}let t=h-r,e=d-l,s=m/(t*n-e*i);if(!(s>=0&&s<=1)){o.push(h),o.push(d);continue}o.push(r+t*s),o.push(l+e*s)}else if(u){let t=h-r,e=d-l,s=m/(t*n-e*i);if(!(s>=0&&s<=1)){o.push(h),o.push(d);continue}o.push(r+t*s),o.push(l+e*s),o.push(h),o.push(d)}c=!0}if(r==o.length)return h.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==d)break;let m=o;(o=l).length=0,l=m}if(h!=o){h.length=0;for(let t=0,e=o.length-2;t<e;t++)h[t]=o[t]}else h.length=h.length-2;return c}static makeClockwise(t){let e=t,s=t.length,i=e[s-2]*e[1]-e[0]*e[s-1],n=0,r=0,a=0,o=0;for(let t=0,l=s-3;t<l;t+=2)n=e[t],r=e[t+1],a=e[t+2],o=e[t+3],i+=n*o-a*r;if(!(i<0))for(let t=0,i=s-2,n=s>>1;t<n;t+=2){let s=e[t],n=e[t+1],r=i-t;e[t]=e[r],e[t+1]=e[r+1],e[r]=s,e[r+1]=n}}}class Ge{attachmentLoader;scale=1;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new te,r="string"==typeof e?JSON.parse(e):e,a=r.skeleton;if(a&&(i.hash=a.hash,i.version=a.spine,i.x=a.x,i.y=a.y,i.width=a.width,i.height=a.height,i.referenceScale=Ke(a,"referenceScale",100)*s,i.fps=a.fps,i.imagesPath=a.images??null,i.audioPath=a.audio??null),r.bones)for(let e=0;e<r.bones.length;e++){let n=r.bones[e],a=null,o=Ke(n,"parent",null);o&&(a=i.findBone(o));let h=new Ot(i.bones.length,n.name,a);h.length=Ke(n,"length",0)*s,h.x=Ke(n,"x",0)*s,h.y=Ke(n,"y",0)*s,h.rotation=Ke(n,"rotation",0),h.scaleX=Ke(n,"scaleX",1),h.scaleY=Ke(n,"scaleY",1),h.shearX=Ke(n,"shearX",0),h.shearY=Ke(n,"shearY",0),h.inherit=l.enumValue(t.Inherit,Ke(n,"inherit","Normal")),h.skinRequired=Ke(n,"skin",!1);let c=Ke(n,"color",null);c&&h.color.setFromString(c),i.bones.push(h)}if(r.slots)for(let e=0;e<r.slots.length;e++){let s=r.slots[e],a=s.name,o=i.findBone(s.bone);if(!o)throw new Error(`Couldn't find bone ${s.bone} for slot ${a}`);let h=new ie(i.slots.length,a,o),c=Ke(s,"color",null);c&&h.color.setFromString(c);let d=Ke(s,"dark",null);d&&(h.darkColor=n.fromString(d)),h.attachmentName=Ke(s,"attachment",null),h.blendMode=l.enumValue(t.BlendMode,Ke(s,"blend","normal")),h.visible=Ke(s,"visible",!0),i.slots.push(h)}if(r.ik)for(let t=0;t<r.ik.length;t++){let e=r.ik[t],n=new Gt(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=i.findBone(e.bones[t]);if(!s)throw new Error(`Couldn't find bone ${e.bones[t]} for IK constraint ${e.name}.`);n.bones.push(s)}let a=i.findBone(e.target);if(!a)throw new Error(`Couldn't find target bone ${e.target} for IK constraint ${e.name}.`);n.target=a,n.mix=Ke(e,"mix",1),n.softness=Ke(e,"softness",0)*s,n.bendDirection=Ke(e,"bendPositive",!0)?1:-1,n.compress=Ke(e,"compress",!1),n.stretch=Ke(e,"stretch",!1),n.uniform=Ke(e,"uniform",!1),i.ikConstraints.push(n)}if(r.transform)for(let t=0;t<r.transform.length;t++){let e=r.transform[t],n=new ne(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=e.bones[t],r=i.findBone(s);if(!r)throw new Error(`Couldn't find bone ${s} for transform constraint ${e.name}.`);n.bones.push(r)}let a=e.target,o=i.findBone(a);if(!o)throw new Error(`Couldn't find target bone ${a} for transform constraint ${e.name}.`);n.target=o,n.local=Ke(e,"local",!1),n.relative=Ke(e,"relative",!1),n.offsetRotation=Ke(e,"rotation",0),n.offsetX=Ke(e,"x",0)*s,n.offsetY=Ke(e,"y",0)*s,n.offsetScaleX=Ke(e,"scaleX",0),n.offsetScaleY=Ke(e,"scaleY",0),n.offsetShearY=Ke(e,"shearY",0),n.mixRotate=Ke(e,"mixRotate",1),n.mixX=Ke(e,"mixX",1),n.mixY=Ke(e,"mixY",n.mixX),n.mixScaleX=Ke(e,"mixScaleX",1),n.mixScaleY=Ke(e,"mixScaleY",n.mixScaleX),n.mixShearY=Ke(e,"mixShearY",1),i.transformConstraints.push(n)}if(r.path)for(let e=0;e<r.path.length;e++){let n=r.path[e],a=new $t(n.name);a.order=Ke(n,"order",0),a.skinRequired=Ke(n,"skin",!1);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],s=i.findBone(e);if(!s)throw new Error(`Couldn't find bone ${e} for path constraint ${n.name}.`);a.bones.push(s)}let o=n.target,h=i.findSlot(o);if(!h)throw new Error(`Couldn't find target slot ${o} for path constraint ${n.name}.`);a.target=h,a.positionMode=l.enumValue(t.PositionMode,Ke(n,"positionMode","Percent")),a.spacingMode=l.enumValue(t.SpacingMode,Ke(n,"spacingMode","Length")),a.rotateMode=l.enumValue(t.RotateMode,Ke(n,"rotateMode","Tangent")),a.offsetRotation=Ke(n,"rotation",0),a.position=Ke(n,"position",0),a.positionMode==t.PositionMode.Fixed&&(a.position*=s),a.spacing=Ke(n,"spacing",0),a.spacingMode!=t.SpacingMode.Length&&a.spacingMode!=t.SpacingMode.Fixed||(a.spacing*=s),a.mixRotate=Ke(n,"mixRotate",1),a.mixX=Ke(n,"mixX",1),a.mixY=Ke(n,"mixY",a.mixX),i.pathConstraints.push(a)}if(r.physics)for(let t=0;t<r.physics.length;t++){const e=r.physics[t],n=new Zt(e.name);n.order=Ke(e,"order",0),n.skinRequired=Ke(e,"skin",!1);const a=e.bone,o=i.findBone(a);if(null==o)throw new Error("Physics bone not found: "+a);n.bone=o,n.x=Ke(e,"x",0),n.y=Ke(e,"y",0),n.rotate=Ke(e,"rotate",0),n.scaleX=Ke(e,"scaleX",0),n.shearX=Ke(e,"shearX",0),n.limit=Ke(e,"limit",5e3)*s,n.step=1/Ke(e,"fps",60),n.inertia=Ke(e,"inertia",1),n.strength=Ke(e,"strength",100),n.damping=Ke(e,"damping",1),n.massInverse=1/Ke(e,"mass",1),n.wind=Ke(e,"wind",0),n.gravity=Ke(e,"gravity",0),n.mix=Ke(e,"mix",1),n.inertiaGlobal=Ke(e,"inertiaGlobal",!1),n.strengthGlobal=Ke(e,"strengthGlobal",!1),n.dampingGlobal=Ke(e,"dampingGlobal",!1),n.massGlobal=Ke(e,"massGlobal",!1),n.windGlobal=Ke(e,"windGlobal",!1),n.gravityGlobal=Ke(e,"gravityGlobal",!1),n.mixGlobal=Ke(e,"mixGlobal",!1),i.physicsConstraints.push(n)}if(r.skins)for(let t=0;t<r.skins.length;t++){let e=r.skins[t],s=new se(e.name);if(e.bones)for(let t=0;t<e.bones.length;t++){let n=e.bones[t],r=i.findBone(n);if(!r)throw new Error(`Couldn't find bone ${n} for skin ${e.name}.`);s.bones.push(r)}if(e.ik)for(let t=0;t<e.ik.length;t++){let n=e.ik[t],r=i.findIkConstraint(n);if(!r)throw new Error(`Couldn't find IK constraint ${n} for skin ${e.name}.`);s.constraints.push(r)}if(e.transform)for(let t=0;t<e.transform.length;t++){let n=e.transform[t],r=i.findTransformConstraint(n);if(!r)throw new Error(`Couldn't find transform constraint ${n} for skin ${e.name}.`);s.constraints.push(r)}if(e.path)for(let t=0;t<e.path.length;t++){let n=e.path[t],r=i.findPathConstraint(n);if(!r)throw new Error(`Couldn't find path constraint ${n} for skin ${e.name}.`);s.constraints.push(r)}if(e.physics)for(let t=0;t<e.physics.length;t++){let n=e.physics[t],r=i.findPhysicsConstraint(n);if(!r)throw new Error(`Couldn't find physics constraint ${n} for skin ${e.name}.`);s.constraints.push(r)}for(let t in e.attachments){let n=i.findSlot(t);if(!n)throw new Error(`Couldn't find slot ${t} for skin ${e.name}.`);let r=e.attachments[t];for(let t in r){let e=this.readAttachment(r[t],s,n.index,t,i);e&&s.setAttachment(n.index,t,e)}}i.skins.push(s),"default"==s.name&&(i.defaultSkin=s)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],s=e.skin?i.findSkin(e.skin):i.defaultSkin;if(!s)throw new Error(`Skin not found: ${e.skin}`);let n=s.getAttachment(e.slotIndex,e.parent);if(!n)throw new Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?n:e.mesh,e.mesh.setParentMesh(n),null!=e.mesh.region&&e.mesh.updateRegion()}if(this.linkedMeshes.length=0,r.events)for(let t in r.events){let e=r.events[t],s=new Wt(t);s.intValue=Ke(e,"int",0),s.floatValue=Ke(e,"float",0),s.stringValue=Ke(e,"string",""),s.audioPath=Ke(e,"audio",null),s.audioPath&&(s.volume=Ke(e,"volume",1),s.balance=Ke(e,"balance",0)),i.events.push(s)}if(r.animations)for(let t in r.animations){let e=r.animations[t];this.readAnimation(e,t,i)}return i}readAttachment(t,e,s,i,n){let r=this.scale;switch(i=Ke(t,"name",i),Ke(t,"type","region")){case"region":{let s=Ke(t,"path",i),n=this.readSequence(Ke(t,"sequence",null)),a=this.attachmentLoader.newRegionAttachment(e,i,s,n);if(!a)return null;a.path=s,a.x=Ke(t,"x",0)*r,a.y=Ke(t,"y",0)*r,a.scaleX=Ke(t,"scaleX",1),a.scaleY=Ke(t,"scaleY",1),a.rotation=Ke(t,"rotation",0),a.width=t.width*r,a.height=t.height*r,a.sequence=n;let o=Ke(t,"color",null);return o&&a.color.setFromString(o),null!=a.region&&a.updateRegion(),a}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(!s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=Ke(t,"color",null);return n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=Ke(t,"path",i),a=this.readSequence(Ke(t,"sequence",null)),o=this.attachmentLoader.newMeshAttachment(e,i,n,a);if(!o)return null;o.path=n;let l=Ke(t,"color",null);l&&o.color.setFromString(l),o.width=Ke(t,"width",0)*r,o.height=Ke(t,"height",0)*r,o.sequence=a;let h=Ke(t,"parent",null);if(h)return this.linkedMeshes.push(new $e(o,Ke(t,"skin",null),s,h,Ke(t,"timelines",!0))),o;let c=t.uvs;return this.readVertices(t,o,c.length),o.triangles=t.triangles,o.regionUVs=c,null!=o.region&&o.updateRegion(),o.edges=Ke(t,"edges",null),o.hullLength=2*Ke(t,"hull",0),o}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(!s)return null;s.closed=Ke(t,"closed",!1),s.constantSpeed=Ke(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let a=l.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)a[e]=t.lengths[e]*r;s.lengths=a;let o=Ke(t,"color",null);return o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(!s)return null;s.x=Ke(t,"x",0)*r,s.y=Ke(t,"y",0)*r,s.rotation=Ke(t,"rotation",0);let n=Ke(t,"color",null);return n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(!s)return null;let r=Ke(t,"end",null);r&&(s.endSlot=n.findSlot(r));let a=t.vertexCount;this.readVertices(t,s,a<<1);let o=Ke(t,"color",null);return o&&s.color.setFromString(o),s}}return null}readSequence(t){if(null==t)return null;let e=new m(Ke(t,"count",0));return e.start=Ke(t,"start",1),e.digits=Ke(t,"digits",0),e.setupIndex=Ke(t,"setup",0),e}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=l.toFloatArray(n);if(1!=i)for(let e=0,s=n.length;e<s;e++)t[e]*=i;return void(e.vertices=t)}let r=new Array,a=new Array;for(let t=0,e=n.length;t<e;){let e=n[t++];a.push(e);for(let s=t+4*e;t<s;t+=4)a.push(n[t]),r.push(n[t+1]*i),r.push(n[t+2]*i),r.push(n[t+3])}e.bones=a,e.vertices=l.toFloatArray(r)}readAnimation(e,s,i){let r=this.scale,a=new Array;if(e.slots)for(let t in e.slots){let s=e.slots[t],r=i.findSlot(t);if(!r)throw new Error("Slot not found: "+t);let o=r.index;for(let t in s){let e=s[t];if(!e)continue;let i=e.length;if("attachment"==t){let t=new N(i,o);for(let s=0;s<i;s++){let i=e[s];t.setFrame(s,Ke(i,"time",0),Ke(i,"name",null))}a.push(t)}else if("rgba"==t){let t=new X(i,i<<2,o),s=e[0],r=Ke(s,"time",0),l=n.fromString(s.color);for(let i=0,a=0;;i++){t.setFrame(i,r,l.r,l.g,l.b,l.a);let o=e[i+1];if(!o){t.shrink(a);break}let h=Ke(o,"time",0),c=n.fromString(o.color),d=s.curve;d&&(a=Je(d,t,a,i,0,r,h,l.r,c.r,1),a=Je(d,t,a,i,1,r,h,l.g,c.g,1),a=Je(d,t,a,i,2,r,h,l.b,c.b,1),a=Je(d,t,a,i,3,r,h,l.a,c.a,1)),r=h,l=c,s=o}a.push(t)}else if("rgb"==t){let t=new _(i,3*i,o),s=e[0],r=Ke(s,"time",0),l=n.fromString(s.color);for(let i=0,a=0;;i++){t.setFrame(i,r,l.r,l.g,l.b);let o=e[i+1];if(!o){t.shrink(a);break}let h=Ke(o,"time",0),c=n.fromString(o.color),d=s.curve;d&&(a=Je(d,t,a,i,0,r,h,l.r,c.r,1),a=Je(d,t,a,i,1,r,h,l.g,c.g,1),a=Je(d,t,a,i,2,r,h,l.b,c.b,1)),r=h,l=c,s=o}a.push(t)}else if("alpha"==t)a.push(je(e,new V(i,i,o),0,1));else if("rgba2"==t){let t=new D(i,7*i,o),s=e[0],r=Ke(s,"time",0),l=n.fromString(s.light),h=n.fromString(s.dark);for(let i=0,a=0;;i++){t.setFrame(i,r,l.r,l.g,l.b,l.a,h.r,h.g,h.b);let o=e[i+1];if(!o){t.shrink(a);break}let c=Ke(o,"time",0),d=n.fromString(o.light),u=n.fromString(o.dark),m=s.curve;m&&(a=Je(m,t,a,i,0,r,c,l.r,d.r,1),a=Je(m,t,a,i,1,r,c,l.g,d.g,1),a=Je(m,t,a,i,2,r,c,l.b,d.b,1),a=Je(m,t,a,i,3,r,c,l.a,d.a,1),a=Je(m,t,a,i,4,r,c,h.r,u.r,1),a=Je(m,t,a,i,5,r,c,h.g,u.g,1),a=Je(m,t,a,i,6,r,c,h.b,u.b,1)),r=c,l=d,h=u,s=o}a.push(t)}else if("rgb2"==t){let t=new O(i,6*i,o),s=e[0],r=Ke(s,"time",0),l=n.fromString(s.light),h=n.fromString(s.dark);for(let i=0,a=0;;i++){t.setFrame(i,r,l.r,l.g,l.b,h.r,h.g,h.b);let o=e[i+1];if(!o){t.shrink(a);break}let c=Ke(o,"time",0),d=n.fromString(o.light),u=n.fromString(o.dark),m=s.curve;m&&(a=Je(m,t,a,i,0,r,c,l.r,d.r,1),a=Je(m,t,a,i,1,r,c,l.g,d.g,1),a=Je(m,t,a,i,2,r,c,l.b,d.b,1),a=Je(m,t,a,i,3,r,c,h.r,u.r,1),a=Je(m,t,a,i,4,r,c,h.g,u.g,1),a=Je(m,t,a,i,5,r,c,h.b,u.b,1)),r=c,l=d,h=u,s=o}a.push(t)}}}if(e.bones)for(let s in e.bones){let n=e.bones[s],o=i.findBone(s);if(!o)throw new Error("Bone not found: "+s);let h=o.index;for(let e in n){let s=n[e],i=s.length;if(0!=i)if("rotate"===e)a.push(je(s,new k(i,i,h),0,1));else if("translate"===e){let t=new I(i,i<<1,h);a.push(He(s,t,"x","y",0,r))}else if("translatex"===e){let t=new A(i,i,h);a.push(je(s,t,0,r))}else if("translatey"===e){let t=new T(i,i,h);a.push(je(s,t,0,r))}else if("scale"===e){let t=new B(i,i<<1,h);a.push(He(s,t,"x","y",1,1))}else if("scalex"===e){let t=new C(i,i,h);a.push(je(s,t,1,1))}else if("scaley"===e){let t=new F(i,i,h);a.push(je(s,t,1,1))}else if("shear"===e){let t=new E(i,i<<1,h);a.push(He(s,t,"x","y",0,1))}else if("shearx"===e){let t=new Y(i,i,h);a.push(je(s,t,0,1))}else if("sheary"===e){let t=new R(i,i,h);a.push(je(s,t,0,1))}else if("inherit"===e){let e=new P(i,o.index);for(let i=0;i<s.length;i++){let n=s[i];e.setFrame(i,Ke(n,"time",0),l.enumValue(t.Inherit,Ke(n,"inherit","Normal")))}a.push(e)}}}if(e.ik)for(let t in e.ik){let s=e.ik[t],n=s[0];if(!n)continue;let o=i.findIkConstraint(t);if(!o)throw new Error("IK Constraint not found: "+t);let l=i.ikConstraints.indexOf(o),h=new W(s.length,s.length<<1,l),c=Ke(n,"time",0),d=Ke(n,"mix",1),u=Ke(n,"softness",0)*r;for(let t=0,e=0;;t++){h.setFrame(t,c,d,u,Ke(n,"bendPositive",!0)?1:-1,Ke(n,"compress",!1),Ke(n,"stretch",!1));let i=s[t+1];if(!i){h.shrink(e);break}let a=Ke(i,"time",0),o=Ke(i,"mix",1),l=Ke(i,"softness",0)*r,m=n.curve;m&&(e=Je(m,h,e,t,0,c,a,d,o,1),e=Je(m,h,e,t,1,c,a,u,l,r)),c=a,d=o,u=l,n=i}a.push(h)}if(e.transform)for(let t in e.transform){let s=e.transform[t],n=s[0];if(!n)continue;let r=i.findTransformConstraint(t);if(!r)throw new Error("Transform constraint not found: "+t);let o=i.transformConstraints.indexOf(r),l=new z(s.length,6*s.length,o),h=Ke(n,"time",0),c=Ke(n,"mixRotate",1),d=Ke(n,"mixX",1),u=Ke(n,"mixY",d),m=Ke(n,"mixScaleX",1),f=Ke(n,"mixScaleY",m),p=Ke(n,"mixShearY",1);for(let t=0,e=0;;t++){l.setFrame(t,h,c,d,u,m,f,p);let i=s[t+1];if(!i){l.shrink(e);break}let r=Ke(i,"time",0),a=Ke(i,"mixRotate",1),o=Ke(i,"mixX",1),g=Ke(i,"mixY",o),x=Ke(i,"mixScaleX",1),w=Ke(i,"mixScaleY",x),b=Ke(i,"mixShearY",1),y=n.curve;y&&(e=Je(y,l,e,t,0,h,r,c,a,1),e=Je(y,l,e,t,1,h,r,d,o,1),e=Je(y,l,e,t,2,h,r,u,g,1),e=Je(y,l,e,t,3,h,r,m,x,1),e=Je(y,l,e,t,4,h,r,f,w,1),e=Je(y,l,e,t,5,h,r,p,b,1)),h=r,c=a,d=o,u=g,m=x,f=w,m=x,n=i}a.push(l)}if(e.path)for(let s in e.path){let n=e.path[s],o=i.findPathConstraint(s);if(!o)throw new Error("Path constraint not found: "+s);let l=i.pathConstraints.indexOf(o);for(let e in n){let s=n[e],i=s[0];if(!i)continue;let h=s.length;if("position"===e){let e=new G(h,h,l);a.push(je(s,e,0,o.positionMode==t.PositionMode.Fixed?r:1))}else if("spacing"===e){let e=new $(h,h,l);a.push(je(s,e,0,o.spacingMode==t.SpacingMode.Length||o.spacingMode==t.SpacingMode.Fixed?r:1))}else if("mix"===e){let t=new j(h,3*h,l),e=Ke(i,"time",0),n=Ke(i,"mixRotate",1),r=Ke(i,"mixX",1),o=Ke(i,"mixY",r);for(let a=0,l=0;;a++){t.setFrame(a,e,n,r,o);let h=s[a+1];if(!h){t.shrink(l);break}let c=Ke(h,"time",0),d=Ke(h,"mixRotate",1),u=Ke(h,"mixX",1),m=Ke(h,"mixY",u),f=i.curve;f&&(l=Je(f,t,l,a,0,e,c,n,d,1),l=Je(f,t,l,a,1,e,c,r,u,1),l=Je(f,t,l,a,2,e,c,o,m,1)),e=c,n=d,r=u,o=m,i=h}a.push(t)}}}if(e.physics)for(let t in e.physics){let s=e.physics[t],n=-1;if(t.length>0){let e=i.findPhysicsConstraint(t);if(!e)throw new Error("Physics constraint not found: "+t);n=i.physicsConstraints.indexOf(e)}for(let t in s){let e=s[t],i=e[0];if(!i)continue;let r,o=e.length;if("reset"!=t){if("inertia"==t)r=new J(o,o,n);else if("strength"==t)r=new K(o,o,n);else if("damping"==t)r=new Q(o,o,n);else if("mass"==t)r=new Z(o,o,n);else if("wind"==t)r=new tt(o,o,n);else if("gravity"==t)r=new et(o,o,n);else{if("mix"!=t)continue;r=new st(o,o,n)}a.push(je(e,r,0,1))}else{const t=new it(o,n);for(let s=0;null!=i;i=e[s+1],s++)t.setFrame(s,Ke(i,"time",0));a.push(t)}}}if(e.attachments)for(let t in e.attachments){let s=e.attachments[t],n=i.findSkin(t);if(!n)throw new Error("Skin not found: "+t);for(let t in s){let e=s[t],o=i.findSlot(t);if(!o)throw new Error("Slot not found: "+t);let h=o.index;for(let t in e){let s=e[t],i=n.getAttachment(h,t);for(let t in s){let e=s[t],n=e[0];if(n)if("deform"==t){let t=i.bones,s=i.vertices,o=t?s.length/3*2:s.length,c=new L(e.length,e.length,h,i),d=Ke(n,"time",0);for(let i=0,a=0;;i++){let h,u=Ke(n,"vertices",null);if(u){h=l.newFloatArray(o);let e=Ke(n,"offset",0);if(l.arrayCopy(u,0,h,e,u.length),1!=r)for(let t=e,s=t+u.length;t<s;t++)h[t]*=r;if(!t)for(let t=0;t<o;t++)h[t]+=s[t]}else h=t?l.newFloatArray(o):s;c.setFrame(i,d,h);let m=e[i+1];if(!m){c.shrink(a);break}let f=Ke(m,"time",0),p=n.curve;p&&(a=Je(p,c,a,i,0,d,f,0,1,1)),d=f,n=m}a.push(c)}else if("sequence"==t){let t=new nt(e.length,h,i),s=0;for(let i=0;i<e.length;i++){let r=Ke(n,"delay",s),a=Ke(n,"time",0),o=f[Ke(n,"mode","hold")],l=Ke(n,"index",0);t.setFrame(i,a,o,l,r),s=r,n=e[i+1]}a.push(t)}}}}}if(e.drawOrder){let t=new U(e.drawOrder.length),s=i.slots.length,n=0;for(let r=0;r<e.drawOrder.length;r++,n++){let a=e.drawOrder[r],o=null,h=Ke(a,"offsets",null);if(h){o=l.newArray(s,-1);let t=l.newArray(s-h.length,0),e=0,n=0;for(let s=0;s<h.length;s++){let r=h[s],a=i.findSlot(r.slot);if(!a)throw new Error("Slot not found: "+a);let l=a.index;for(;e!=l;)t[n++]=e++;o[e+r.offset]=e++}for(;e<s;)t[n++]=e++;for(let e=s-1;e>=0;e--)-1==o[e]&&(o[e]=t[--n])}t.setFrame(n,Ke(a,"time",0),o)}a.push(t)}if(e.events){let t=new q(e.events.length),s=0;for(let n=0;n<e.events.length;n++,s++){let r=e.events[n],a=i.findEvent(r.name);if(!a)throw new Error("Event not found: "+r.name);let o=new Ut(l.toSinglePrecision(Ke(r,"time",0)),a);o.intValue=Ke(r,"int",a.intValue),o.floatValue=Ke(r,"float",a.floatValue),o.stringValue=Ke(r,"string",a.stringValue),o.data.audioPath&&(o.volume=Ke(r,"volume",1),o.balance=Ke(r,"balance",0)),t.setFrame(s,o)}a.push(t)}let o=0;for(let t=0,e=a.length;t<e;t++)o=Math.max(o,a[t].getDuration());i.animations.push(new g(s,a,o))}}class $e{parent;skin;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,n){this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=n}}function je(t,e,s,i){let n=t[0],r=Ke(n,"time",0),a=Ke(n,"value",s)*i,o=0;for(let l=0;;l++){e.setFrame(l,r,a);let h=t[l+1];if(!h)return e.shrink(o),e;let c=Ke(h,"time",0),d=Ke(h,"value",s)*i;n.curve&&(o=Je(n.curve,e,o,l,0,r,c,a,d,i)),r=c,a=d,n=h}}function He(t,e,s,i,n,r){let a=t[0],o=Ke(a,"time",0),l=Ke(a,s,n)*r,h=Ke(a,i,n)*r,c=0;for(let d=0;;d++){e.setFrame(d,o,l,h);let u=t[d+1];if(!u)return e.shrink(c),e;let m=Ke(u,"time",0),f=Ke(u,s,n)*r,p=Ke(u,i,n)*r,g=a.curve;g&&(c=Je(g,e,c,d,0,o,m,l,f,r),c=Je(g,e,c,d,1,o,m,h,p,r)),o=m,l=f,h=p,a=u}}function Je(t,e,s,i,n,r,a,o,l,h){if("stepped"==t)return e.setStepped(i),s;let c=n<<2,d=t[c],u=t[c+1]*h,m=t[c+2],f=t[c+3]*h;return e.setBezier(s,i,n,r,o,d,u,m,f,a,l),s+1}function Ke(t,e,s){return void 0!==t[e]?t[e]:s}var Qe;function Ze(t,e,s){const i=new Dt(t);return"json"===s?new Ge(i).readSkeletonData(e):new re(i).readSkeletonData(new Uint8Array(e))}async function ts(t,s,i){let n;const r=t.map(((t,n)=>{const r=s[n];let a=e.AssetType.Texture2D;return"ktx"===r?a=e.AssetType.KTX:"ktx2"===r&&(a=e.AssetType.KTX2),is(t,i,a)}));try{n=await Promise.all(r)}catch(t){throw t}return n}async function es(t,s){const i=function(t){const e=new URL(t),s=e.origin+e.pathname;return s.endsWith("/")?s:s.substring(0,s.lastIndexOf("/")+1)}(t);let n,r;try{n=await e.request(t,{type:"text"})}catch(e){throw new Error(`Spine Atlas: ${t} load error: ${e}`)}let a=new Ft(n);const o=[];for(let t of a.pages){const e=i+t.name;o.push(is(e,s))}try{r=await Promise.all(o)}catch(t){throw new Error(`Spine Texture: load error: ${t}`)}return a=ss(n,r),a}function ss(t,e){const s=new Ft(t);return s.pages.forEach(((t,s)=>{const i=function(t){return new ns(new Image,t)}(e.find((e=>e.name===t.name))||e[s]);t.setTexture(i)})),s}function is(t,s,i=e.AssetType.Texture2D){return s.resourceManager.load({url:t,type:i})}void 0===Math.fround&&(Math.fround=(Qe=new Float32Array(1),function(t){return Qe[0]=t,Qe[0]}));class ns extends bt{constructor(t,e){super(t),this.texture=e,this.texture.generateMipmaps()}getImage(){return this.texture}setFilters(s,i){s===t.TextureFilter.Nearest?this.texture.filterMode=e.TextureFilterMode.Point:i===t.TextureFilter.MipMapLinearLinear?this.texture.filterMode=e.TextureFilterMode.Trilinear:this.texture.filterMode=e.TextureFilterMode.Bilinear}setWraps(t,e){this.texture.wrapModeU=this._convertWrapMode(t),this.texture.wrapModeV=this._convertWrapMode(e)}dispose(){}_convertWrapMode(s){switch(s){case t.TextureWrap.ClampToEdge:return e.TextureWrapMode.Clamp;case t.TextureWrap.Repeat:return e.TextureWrapMode.Repeat;case t.TextureWrap.MirroredRepeat:return e.TextureWrapMode.Mirror;default:throw new Error("Unsupported texture wrap mode.")}}}class rs{constructor(t,e=1){this._type=t,this._lastElementIndex=e-1;const s=this._elements=new Array(e);for(let i=0;i<e;++i)s[i]=new t}get(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]}return(t){this._elements[++this._lastElementIndex]=t}}class as{constructor(t){this._usedElementCount=0,this._type=t,this._elements=[]}get(){const{_usedElementCount:t,_elements:e}=this;if(this._usedElementCount++,e.length===t){const t=new this._type;return e.push(t),t}return e[t]}clear(){this._usedElementCount=0}}const{SourceAlpha:os,One:ls,DestinationColor:hs,Zero:cs,OneMinusSourceColor:ds,OneMinusSourceAlpha:us}=e.BlendFactor,{Add:ms}=e.BlendOperation;function fs(e,s){const i=e.renderState.blendState.targetBlendState;switch(s){case t.BlendMode.Additive:i.sourceColorBlendFactor=os,i.destinationColorBlendFactor=ls,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=ls,i.colorBlendOperation=i.alphaBlendOperation=ms;break;case t.BlendMode.Multiply:i.sourceColorBlendFactor=hs,i.destinationColorBlendFactor=us,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=us,i.colorBlendOperation=i.alphaBlendOperation=ms;break;case t.BlendMode.Screen:i.sourceColorBlendFactor=ls,i.destinationColorBlendFactor=ds,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=ds,i.colorBlendOperation=i.alphaBlendOperation=ms;break;default:i.sourceColorBlendFactor=os,i.destinationColorBlendFactor=us,i.sourceAlphaBlendFactor=ls,i.destinationAlphaBlendFactor=us,i.colorBlendOperation=i.alphaBlendOperation=ms}}class ps{}const gs=1/0,xs=-1/0;class ws{static{this.QUAD_TRIANGLES=[0,1,2,2,3,0]}static{this.VERTEX_SIZE=8}static{this.VERTEX_STRIDE=9}static{this.tempDark=new n}static{this.tempColor=new n}static{this.tempVerts=new Array(8)}static{this.tempBlendMode=null}static{this.tempTexture=null}static{this.subPrimitivePool=new rs(e.SubPrimitive)}static{this.subRenderItemPool=new as(ps)}static{this.bounds=new e.BoundingBox(new e.Vector3(gs,gs,gs),new e.Vector3(xs,xs,xs))}getMaxVertexCount(t){const e=new Set,{skins:s}=t,i=s.length;for(let t=0;t<i;t++){const i=s[t];this._collectUniqueAttachments(i,e)}return this._calculateTotalVertexCount(e)}buildPrimitive(e,s){const{useClipping:i=!0,zSpacing:n=.01}=s.setting,{_clipper:r,_separateSlots:a,_subRenderItems:o,_separateSlotTextureMap:l}=this,{bounds:h}=ws;h.min.set(gs,gs,gs),h.max.set(xs,xs,xs);let c=0,d=0;const u=e.drawOrder,m=u.length,{engine:f,_indices:p,_vertices:g,_subPrimitives:x}=s;let{tempVerts:w,tempTexture:b,tempBlendMode:y,subRenderItemPool:M,subPrimitivePool:S}=ws;o.length=0,M.clear();let v,k,I=s._vertices,A=0,T=0,B=t.BlendMode.Normal,C=null,F=0;ws.tempBlendMode=null,ws.tempTexture=null;for(let t=0;t<m;++t){const e=u[t];if(!e.bone.active){r.clipEndWithSlot(e);continue}const s=e.getAttachment();let h=null;const m=n*t;let f=0;const E=r.isClipping();let Y=E?2:ws.VERTEX_SIZE;if(s){switch(s.constructor){case Vt:const t=s;h=t.color,f=4*Y,t.computeWorldVertices(e,w,0,Y),v=ws.QUAD_TRIANGLES,k=t.uvs,C=t.region.texture;break;case Pt:const n=s;h=n.color,f=(n.worldVerticesLength>>1)*Y,f>I.length&&(ws.tempVerts=new Array(f)),n.computeWorldVertices(e,0,n.worldVerticesLength,w,0,Y),v=n.triangles,k=n.uvs,C=n.region.texture;break;case wt:if(i){let t=s;r.clipStart(e,t)}continue;default:i&&r.clipEndWithSlot(e);continue}if(null!=C){let t,s,i,n,u=e.bone.skeleton.color,I=e.color,R=u.a*I.a*h.a,P=ws.tempColor,X=ws.tempDark;if(P.set(u.r*I.r*h.r,u.g*I.g*h.g,u.b*I.b*h.b,R),E)r.clipTriangles(w,v,v.length,k,P,X,!1),t=r.clippedVertices,s=t.length,i=r.clippedTriangles,n=i.length;else{let e=w;const{r:r,g:a,b:o,a:l}=P;for(let t=2,s=0,i=f;t<i;t+=Y,s+=2)e[t]=r,e[t+1]=a,e[t+2]=o,e[t+3]=l,e[t+4]=k[s],e[t+5]=k[s+1];t=w,s=f,i=v,n=v.length}if(0==s||0==n){r.clipEndWithSlot(e);continue}let _=c/ws.VERTEX_STRIDE,V=g,D=c,O=0;for(;O<s;){let e=t[O++],s=t[O++];V[D++]=e,V[D++]=s,V[D++]=m,V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],V[D++]=t[O++],this._expandByPoint(e,s,m)}c=D;let N=p;for(D=d,O=0;O<n;D++,O++)N[D]=i[O]+_;d+=n;const L=e.data,q=L.name;B=L.blendMode;const U=null!==y&&y!==L.blendMode,W=null!==b&&b!==C,z=a.get(q);if(z||U||W){if(T>0){const t=x[F];t&&F++;const e=t||S.get();e.start=A,e.count=T;const s=M.get();s.subPrimitive=e,s.texture=b,s.blendMode=y,o.push(s),A+=T,T=0}if(z){const t=l.get(q);if(t){const e=C.texture;t.filterMode=e.filterMode,t.wrapModeU=e.wrapModeU,t.wrapModeV=e.wrapModeV}const e=x[F];e&&F++;const s=e||S.get();s.start=A,s.count=n;const i=M.get();i.blendMode=B,i.subPrimitive=s,i.texture=C,i.slotName=q,o.push(i),A+=n,T=0}else T+=n}else T+=n;b=C,y=B}r.clipEndWithSlot(e)}else i&&r.clipEndWithSlot(e)}if(T>0){const t=x[F];t&&F++;const e=t||S.get();e.start=A,e.count=T;const s=M.get();s.blendMode=B,s.subPrimitive=e,s.texture=C,o.push(s),T=0}r.clipEnd();const E=x.length,Y=o.length;if(Y<E)for(let t=Y;t<E;t++){const e=x[t];S.return(e)}s._clearSubPrimitives();for(let t=0,e=Y;t<e;++t){const e=o[t],{slotName:i,blendMode:n,texture:r}=e;s._addSubPrimitive(e.subPrimitive);let a=r.texture;l.has(i)&&(a=l.get(i));const h=`${a.instanceId}_${n}`;let c=ys._materialCache.get(h);c||(c=this._createMaterialForTexture(a,f,n),ys._materialCache.set(h,c)),s.setMaterial(t,c)}s._vertexBuffer.setData(g),s._indexBuffer.setData(p)}addSeparateSlot(t){this._separateSlots.set(t,t)}addSeparateSlotTexture(t,e){this._separateSlotTextureMap.set(t,e)}_createMaterialForTexture(t,e,s){const i=ys._getDefaultMaterial(e);return i.shaderData.setTexture("material_SpineTexture",t),fs(i,s),i}_expandByPoint(t,e,s){const{bounds:{min:i,max:n}}=ws,r=Math.min(i.x,t),a=Math.min(i.y,e),o=Math.min(i.z,s),l=Math.max(n.x,t),h=Math.max(n.y,e),c=Math.max(n.z,s);i.set(r,a,o),n.set(l,h,c)}_collectUniqueAttachments(t,e){const{attachments:s}=t;for(let t=0,i=s.length;t<i;t++){const i=s[t];for(let t in i){const s=i[t];s&&!e.has(s)&&e.add(s)}}}_calculateTotalVertexCount(t){let e=0;const s=ws.QUAD_TRIANGLES.length;return t.forEach((t=>{t instanceof Vt?e+=s:t instanceof Pt&&(e+=t.triangles.length)})),e}constructor(){this._clipper=new ze,this._subRenderItems=[],this._separateSlots=new Map,this._separateSlotTextureMap=new Map}}class bs extends e.Material{static{this._spineVS="\n uniform mat4 renderer_MVPMat;\n\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec4 COLOR_0;\n \n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n \n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n }\n "}static{this._spineFS="\n uniform sampler2D material_SpineTexture;\n\n varying vec2 v_uv;\n varying vec4 v_color;\n \n void main()\n {\n vec4 baseColor = texture2D(material_SpineTexture, v_uv);\n gl_FragColor = baseColor * v_color;\n }\n "}constructor(s){super(s,e.Shader.find("galacean-spine-shader")||e.Shader.create("galacean-spine-shader",bs._spineVS,bs._spineFS));const i=this.renderState;i.blendState.targetBlendState.enabled=!0,fs(this,t.BlendMode.Normal),i.depthState.writeEnabled=!1,i.rasterState.cullMode=e.CullMode.Off,i.renderQueueType=e.RenderQueueType.Transparent}}class ys extends e.Renderer{static{this._spineGenerator=new ws}static{this._positionVertexElement=new e.VertexElement("POSITION",0,e.VertexElementFormat.Vector3,0)}static{this._colorVertexElement=new e.VertexElement("COLOR_0",12,e.VertexElementFormat.Vector4,0)}static{this._uvVertexElement=new e.VertexElement("TEXCOORD_0",28,e.VertexElementFormat.Vector2,0)}static{this._materialCache=new Map}static{this._animationDataCache=new Map}static _getDefaultMaterial(t){let e=this._defaultMaterial;if(e){if(e.engine===t)return e.clone();e.destroy(!0),e=null}return e=new bs(t),e.isGCIgnored=!0,this._defaultMaterial=e,e.clone()}get resource(){return this._resource}set resource(t){if(!t)return this._state=null,this._skeleton=null,void(this._resource=null);this._resource=t,this._addResourceReferCount(t,1);const{skeletonData:e}=t;this._skeleton=new Qt(e);let s=ys._animationDataCache.get(e);s||(s=new gt(e),ys._animationDataCache.set(e,s)),this._state=new rt(s);const i=ys._spineGenerator.getMaxVertexCount(e);this._createBuffer(i),this._initializeDefaultState(),this._dirtyUpdateFlag|=4,this._state.addListener({start:()=>{this._onAnimationStart()},complete:t=>{this._onAnimationComplete(t)}})}get state(){return this._state}get skeleton(){return this._skeleton}constructor(t){super(t),this.setting=new Ms,this.defaultState=new Ss,this._subPrimitives=[],this._needResizeBuffer=!1,this._vertexCount=0;const s=new e.Primitive(this._engine);this._primitive=s,s.addVertexElement(ys._positionVertexElement),s.addVertexElement(ys._colorVertexElement),s.addVertexElement(ys._uvVertexElement)}addSeparateSlot(t){this._skeleton||console.error("Skeleton not found!");this._skeleton.findSlot(t)?ys._spineGenerator.addSeparateSlot(t):console.warn(`Slot: ${t} not find.`)}_onEnable(){this._initializeDefaultState()}update(e){const{_state:s,_skeleton:i}=this;s&&i&&(s.update(e),s.apply(i),i.update(e),i.updateWorldTransform(t.Physics.update),ys._spineGenerator.buildPrimitive(this._skeleton,this),this._isContainDirtyFlag(4)&&(this._onWorldVolumeChanged(),this._setDirtyFlagFalse(4)),this._isContainDirtyFlag(2)&&this._calculateGeneratorBounds(this.bounds))}_render(t){const{_primitive:e,_subPrimitives:s}=this,{_materials:i,_engine:n}=this,r=n._renderElementPool.get();r.set(this.priority,this._distanceForSort);const a=n._subRenderElementPool;if(s){for(let t=0,n=s.length;t<n;t++){let n=i[t];if(!n)continue;(n.destroyed||n.shader.destroyed)&&(n=this.engine._meshMagentaMaterial);const o=a.get();o.set(this,n,e,s[t]),r.addSubRenderElement(o)}t.camera._renderPipeline.pushRenderElement(t,r)}}_updateBounds(t){this._calculateGeneratorBounds(t)}_calculateGeneratorBounds(t){const{bounds:s}=ws;e.BoundingBox.transform(s,this.entity.transform.worldMatrix,t)}_cloneTo(t){t.resource=this._resource}_onDestroy(){const{_primitive:t,_subPrimitives:e,_resource:s}=this;e.length=0,t&&t.destroy(),s&&this._addResourceReferCount(s,-1),this._clearMaterialCache(),this._primitive=null,this._resource=null,this._skeleton=null,this._state=null,this.setting=null,super._onDestroy()}_createBuffer(t){const{_engine:s,_primitive:i}=this;this._vertices=new Float32Array(t*ws.VERTEX_STRIDE),this._indices=new Uint16Array(t);const n=4*ws.VERTEX_STRIDE,r=new e.Buffer(s,e.BufferBindFlag.VertexBuffer,this._vertices,e.BufferUsage.Dynamic),a=new e.Buffer(s,e.BufferBindFlag.IndexBuffer,this._indices,e.BufferUsage.Dynamic);this._indexBuffer=a,this._vertexBuffer=r;const o=new e.VertexBufferBinding(r,n);this._primitive.setVertexBufferBinding(0,o);const l=new e.IndexBufferBinding(a,e.IndexFormat.UInt16);i.setIndexBufferBinding(l)}_addSubPrimitive(t){this._subPrimitives.push(t)}_clearSubPrimitives(){this._subPrimitives.length=0}_isContainDirtyFlag(t){return!!(this._dirtyUpdateFlag&t)}_setDirtyFlagFalse(t){this._dirtyUpdateFlag&=~t}_onWorldVolumeChanged(){this._dirtyUpdateFlag|=1}_onAnimationStart(){this._dirtyUpdateFlag|=2}_onAnimationComplete(t){t.loop||this._setDirtyFlagFalse(2)}_clearMaterialCache(){this._materials.forEach((e=>{const s=e.shaderData.getTexture("material_SpineTexture"),i=function(e){const s=e.renderState.blendState.targetBlendState;return s.sourceColorBlendFactor===os&&s.destinationColorBlendFactor===ls&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===ls&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Additive:s.sourceColorBlendFactor===hs&&s.destinationColorBlendFactor===cs&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===cs&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Multiply:s.sourceColorBlendFactor===ls&&s.destinationColorBlendFactor===ds&&s.sourceAlphaBlendFactor===ls&&s.destinationAlphaBlendFactor===ds&&s.colorBlendOperation===ms&&s.alphaBlendOperation===ms?t.BlendMode.Screen:t.BlendMode.Normal}(e),n=`${s.instanceId}_${i}`;ys._materialCache.delete(n)}))}_initializeDefaultState(){const{skeleton:t,state:e}=this;if(t&&e){const{animationName:s,skinName:i,loop:n,scale:r}=this.defaultState;t.scaleX=r,t.scaleY=r,"default"!==i&&(t.setSkinByName(i),t.setToSetupPose()),s&&e.setAnimation(0,s,n)}}}s([e.deepClone],ys.prototype,"setting",void 0),s([e.deepClone],ys.prototype,"defaultState",void 0),s([e.ignoreClone],ys.prototype,"_primitive",void 0),s([e.ignoreClone],ys.prototype,"_subPrimitives",void 0),s([e.ignoreClone],ys.prototype,"_indexBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertexBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertices",void 0),s([e.ignoreClone],ys.prototype,"_indices",void 0),s([e.ignoreClone],ys.prototype,"_needResizeBuffer",void 0),s([e.ignoreClone],ys.prototype,"_vertexCount",void 0),s([e.ignoreClone],ys.prototype,"_resource",void 0),s([e.ignoreClone],ys.prototype,"_skeleton",void 0),s([e.ignoreClone],ys.prototype,"_state",void 0);class Ms{constructor(t=.01,e=!0){this.zSpacing=t,this.useClipping=e}}class Ss{constructor(t=1,e=!0,s=null,i="default"){this.scale=t,this.loop=e,this.animationName=s,this.skinName=i}}class vs extends e.ReferResource{get skeletonData(){return this._skeletonData}constructor(t,e){super(t),this.textures=[],this._skeletonData=e,this._associationTextureInSkeletonData(e)}_onDestroy(){super._onDestroy();const{textures:t,_skeletonData:e}=this;t&&this._disassociationSuperResource(t),this._clearAttachmentTextures(e),ys._animationDataCache.delete(e),this._skeletonData=null}_disassociationSuperResource(t){for(let e=0,s=t.length;e<s;e++)t[e]._disassociationSuperResource(this)}_associationTextureInSkeletonData(t){const{skins:e}=t;e.forEach((t=>{const{attachments:e}=t;e.forEach((t=>{const e=Object.values(t)[0],s=e?.region?.texture.texture;s&&!this.textures.find((t=>t.instanceId===s.instanceId))&&(this.textures.push(s),s._associationSuperResource(this))}))}))}_clearAttachmentTextures(t){const{skins:e}=t;e.forEach((t=>{const{attachments:e}=t;e.forEach((t=>{const e=Object.values(t)[0];e?.region?.texture&&(e.region.texture.texture=null)}))}))}}class ks{constructor(t,e=0,s){this.data=t,this._dataView=new DataView(t.buffer,t.byteOffset+e,s??t.byteLength-e),this._position=0}nextUint16(){const t=this._dataView.getUint16(this._position,!0);return this._position+=2,t}nextStr(){const t=this.nextUint16(),e=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,t);return this._position+=t,this.decodeText(e)}nextImageData(){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)}decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let s=0,i=t.length;s<i;s++)e+=String.fromCharCode(t[s]);return decodeURIComponent(encodeURIComponent(e))}}class Is extends e.Loader{static{this.imageExtensions=["png","jpg","webp","jpeg","ktx","ktx2"]}static{this.skeletonExtensions=["skel","json","bin"]}static parseAndAssignSpineAsset(t,e,s){const{imageExtensions:i,skeletonExtensions:n}=Is,r=Is.getUrlExtension(t,e);r&&(n.includes(r)&&(s.skeletonPath=t,s.skeletonExtension=r),"atlas"===r&&(s.atlasPath=t),i.includes(r)&&(s.imagePaths.push(t),s.imageExtensions.push(r)))}static deriveAndAssignSpineAsset(t,e,s){const i=Is.getUrlExtension(t,e);if(!i)return;s.skeletonPath=t,s.skeletonExtension=i;const n=/(\.(json|bin|skel))$/;let r;if(n.test(t)&&(r=t.replace(n,"")),r){const t=r+".atlas";s.atlasPath=t}}static verifyFileExtensions(t,e){return t?e&&!Array.isArray(t)?(console.error("Expect fileExtensions to be an array."),[]):e||"string"==typeof t?t:(console.error("Expect fileExtensions to be a string."),null):null}static getUrlExtension(t,e){if(e)return e;const s=t.match(/\/([^\/?#]+)\.([a-zA-Z0-9]+)(\?|#|$)|\?[^#]*\.([a-zA-Z0-9]+)(\?|#|$)/);return s?s[2]||s[4]:null}load(t,s){return new e.AssetPromise((async(e,i)=>{let n;try{if(t.urls)n=await this._handleOriginAsset(t,s);else{const e=await this.request(t.url,{type:"arraybuffer"}),i=new ks(new Uint8Array(e)),r=i.nextStr();n=r.startsWith("spine")?await this._handleEditorAsset(e,i,r,s):await this._handleOriginAsset(t,s,e)}}catch(t){i(t)}e(n)}))}async _handleEditorAsset(t,e,s,i){let n,r;const a=s.startsWith("spine:skel")?"skel":"json",{engine:o}=i;if("skel"===a)r=e.nextStr(),n=e.nextImageData();else{const e=new TextDecoder("utf-8").decode(new Uint8Array(t)),{data:s,atlas:i}=JSON.parse(e);r=i.refId,n=s}let l;try{l=await i.getResourceByRef({refId:r})}catch(t){throw t}const h=Ze(l,n,a);return new vs(o,h)}async _handleOriginAsset(t,e,s){let{fileExtensions:i}=t.params||{},n={skeletonPath:"",skeletonExtension:"",atlasPath:"",imagePaths:[],imageExtensions:[]};const{engine:r}=e;if(s){const e=Is.verifyFileExtensions(i,!1);Is.deriveAndAssignSpineAsset(t.url,e,n);const{skeletonPath:a,atlasPath:o}=n;if(!a||!o)throw new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");let l;try{l=await es(o,r)}catch(t){throw t}const{data:h,type:c}=this._determineSkeletonDataType(s),d=Ze(l,h,c);return new vs(r,d)}{i=Is.verifyFileExtensions(i,!0);for(let e=0;e<t.urls.length;e+=1){const s=t.urls[e],r=i&&i[e]||null;Is.parseAndAssignSpineAsset(s,r,n)}const{skeletonPath:e,atlasPath:s,imagePaths:a,skeletonExtension:o,imageExtensions:l}=n;if(!e||!s)throw new Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");const h="json"===o?"json":"skel";let c,d;try{let t=["json"===o?this.request(e,{type:"text"}):this.request(e,{type:"arraybuffer"})];if(a.length>0){let e,i;t=t.concat([this.request(s,{type:"text"}),ts(a,l,r)]),[d,e,i]=await Promise.all(t),c=ss(e,i)}else t.push(es(s,r)),[d,c]=await Promise.all(t)}catch(t){throw t}const u=Ze(c,d,h);return new vs(r,u)}}_determineSkeletonDataType(t){let e,s;try{const i=new TextDecoder("utf-8").decode(t);JSON.parse(i),e=i,s="json"}catch(i){e=t,s="skel"}return{data:e,type:s}}}Is=s([e.resourceLoader("spine",["json","bin","skel"])],Is);class As extends e.Loader{load(t,s){return new e.AssetPromise((async e=>{const i=await this.request(t.url,{type:"text"}),{data:n,textures:r}=JSON.parse(i),a=r.map((t=>s.getResourceByRef({refId:t.refId})));e(ss(n,await Promise.all(a)))}))}}As=s([e.resourceLoader("EditorSpineAtlas",["atlas"])],As);const Ts="0.0.0-experimental-engine-spine-caifu.0";e.Loader.registerClass("SpineAnimationRenderer",ys),console.log(`Galacean spine version: ${Ts}`),t.AlphaTimeline=V,t.Animation=g,t.AnimationState=rt,t.AnimationStateAdapter=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},t.AnimationStateData=gt,t.AssetManagerBase=class{pathPrefix="";textureLoader;downloader;assets={};errors={};toLoad=0;loaded=0;constructor(t,e="",s=new qt){this.textureLoader=t,this.pathPrefix=e,this.downloader=s}start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,s){this.toLoad--,this.loaded++,this.assets[e]=s,t&&t(e,s)}error(t,e,s){this.toLoad--,this.loaded++,this.errors[e]=s,t&&t(e,s)}loadAll(){return new Promise(((t,e)=>{let s=()=>{this.isLoadingComplete()?this.hasErrors()?e(this.errors):t(this):requestAnimationFrame(s)};requestAnimationFrame(s)}))}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadBinary(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load binary ${t}: status ${e}, ${i}`)}))}loadText(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadText(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load text ${t}: status ${e}, ${i}`)}))}loadJson(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadJson(t,(s=>{this.success(e,t,s)}),((e,i)=>{this.error(s,t,`Couldn't load JSON ${t}: status ${e}, ${i}`)}))}loadTexture(t,e=()=>{},s=()=>{}){if(t=this.start(t),!!("undefined"==typeof window||"undefined"==typeof navigator||!window.document))fetch(t,{mode:"cors"}).then((e=>e.ok?e.blob():(this.error(s,t,`Couldn't load image: ${t}`),null))).then((t=>t?createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null)).then((s=>{s&&this.success(e,t,this.textureLoader(s))}));else{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>{this.success(e,t,this.textureLoader(i))},i.onerror=()=>{this.error(s,t,`Couldn't load image: ${t}`)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),i.src=t}}loadTextureAtlas(t,e=()=>{},s=()=>{},i){let n=t.lastIndexOf("/"),r=n>=0?t.substring(0,n+1):"";t=this.start(t),this.downloader.downloadText(t,(n=>{try{let a=new Ft(n),o=a.pages.length,l=!1;for(let n of a.pages)this.loadTexture(i?i[n.name]:r+n.name,((s,i)=>{l||(n.setTexture(i),0==--o&&this.success(e,t,a))}),((e,i)=>{l||this.error(s,t,`Couldn't load texture atlas ${t} page image: ${e}`),l=!0}))}catch(e){this.error(s,t,`Couldn't parse texture atlas ${t}: ${e.message}`)}}),((e,i)=>{this.error(s,t,`Couldn't load texture atlas ${t}: status ${e}, ${i}`)}))}get(t){return this.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;let e=this.assets[t];if(e)return e;let s=this.errors[t];throw Error("Asset not found: "+t+(s?"\n"+s:""))}remove(t){t=this.pathPrefix+t;let e=this.assets[t];return e.dispose&&e.dispose(),delete this.assets[t],e}removeAll(){for(let t in this.assets){let e=this.assets[t];e.dispose&&e.dispose()}this.assets={}}isLoadingComplete(){return 0==this.toLoad}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},t.AtlasAttachmentLoader=Dt,t.Attachment=d,t.AttachmentTimeline=N,t.BinaryInput=ae,t.Bone=Nt,t.BoneData=Ot,t.BoundingBoxAttachment=xt,t.CURRENT=pt,t.ClippingAttachment=wt,t.Color=n,t.ConstraintData=Lt,t.CurveTimeline=M,t.CurveTimeline1=S,t.CurveTimeline2=v,t.DebugUtils=class{static logBones(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e];console.log(s.data.name+", "+s.a+", "+s.b+", "+s.c+", "+s.d+", "+s.worldX+", "+s.worldY)}}},t.DeformTimeline=L,t.Downloader=qt,t.DrawOrderTimeline=U,t.Event=Ut,t.EventData=Wt,t.EventQueue=ot,t.EventTimeline=q,t.FIRST=ct,t.FakeTexture=class extends bt{setFilters(t,e){}setWraps(t,e){}dispose(){}},t.HOLD_FIRST=ut,t.HOLD_MIX=mt,t.HOLD_SUBSEQUENT=dt,t.IkConstraint=zt,t.IkConstraintData=Gt,t.IkConstraintTimeline=W,t.InheritTimeline=P,t.IntSet=class{array=new Array;add(t){let e=this.contains(t);return this.array[0|t]=0|t,!e}contains(t){return null!=this.array[0|t]}remove(t){this.array[0|t]=void 0}clear(){this.array.length=0}},t.Interpolation=a,t.MathUtils=r,t.MeshAttachment=Pt,t.PathAttachment=Xt,t.PathConstraint=jt,t.PathConstraintData=$t,t.PathConstraintMixTimeline=j,t.PathConstraintPositionTimeline=G,t.PathConstraintSpacingTimeline=$,t.PhysicsConstraintDampingTimeline=Q,t.PhysicsConstraintGravityTimeline=et,t.PhysicsConstraintInertiaTimeline=J,t.PhysicsConstraintMassTimeline=Z,t.PhysicsConstraintMixTimeline=st,t.PhysicsConstraintResetTimeline=it,t.PhysicsConstraintStrengthTimeline=K,t.PhysicsConstraintTimeline=H,t.PhysicsConstraintWindTimeline=tt,t.PointAttachment=_t,t.Pool=h,t.Pow=o,t.PowOut=class extends o{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}},t.RGB2Timeline=O,t.RGBA2Timeline=D,t.RGBATimeline=X,t.RGBTimeline=_,t.RegionAttachment=Vt,t.RotateTimeline=k,t.SETUP=ft,t.SUBSEQUENT=ht,t.ScaleTimeline=B,t.ScaleXTimeline=C,t.ScaleYTimeline=F,t.SequenceTimeline=nt,t.ShearTimeline=E,t.ShearXTimeline=Y,t.ShearYTimeline=R,t.Skeleton=Qt,t.SkeletonBinary=re,t.SkeletonBounds=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=new Array;polygons=new Array;polygonPool=new h((()=>l.newFloatArray(16)));update(t,e){if(!t)throw new Error("skeleton cannot be null.");let s=this.boundingBoxes,i=this.polygons,n=this.polygonPool,r=t.slots,a=r.length;s.length=0,n.freeAll(i),i.length=0;for(let t=0;t<a;t++){let e=r[t];if(!e.bone.active)continue;let a=e.getAttachment();if(a instanceof xt){let t=a;s.push(t);let r=n.obtain();r.length!=t.worldVerticesLength&&(r=l.newFloatArray(t.worldVerticesLength)),i.push(r),t.computeWorldVertices(e,0,t.worldVerticesLength,r,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=this.polygons;for(let r=0,a=n.length;r<a;r++){let a=n[r],o=a;for(let n=0,r=a.length;n<r;n+=2){let r=o[n],a=o[n+1];t=Math.min(t,r),e=Math.min(e,a),s=Math.max(s,r),i=Math.max(i,a)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,i){let n=this.minX,r=this.minY,a=this.maxX,o=this.maxY;if(t<=n&&s<=n||e<=r&&i<=r||t>=a&&s>=a||e>=o&&i>=o)return!1;let l=(i-e)/(s-t),h=l*(n-t)+e;if(h>r&&h<o)return!0;if(h=l*(a-t)+e,h>r&&h<o)return!0;let c=(r-e)/l+t;return c>n&&c<a||(c=(o-e)/l+t,c>n&&c<a)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){let s=this.polygons;for(let i=0,n=s.length;i<n;i++)if(this.containsPointPolygon(s[i],t,e))return this.boundingBoxes[i];return null}containsPointPolygon(t,e,s){let i=t,n=t.length,r=n-2,a=!1;for(let t=0;t<n;t+=2){let n=i[t+1],o=i[r+1];if(n<s&&o>=s||o<s&&n>=s){let l=i[t];l+(s-n)/(o-n)*(i[r]-l)<e&&(a=!a)}r=t}return a}intersectsSegment(t,e,s,i){let n=this.polygons;for(let r=0,a=n.length;r<a;r++)if(this.intersectsSegmentPolygon(n[r],t,e,s,i))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(t,e,s,i,n){let r=t,a=t.length,o=e-i,l=s-n,h=e*n-s*i,c=r[a-2],d=r[a-1];for(let t=0;t<a;t+=2){let a=r[t],u=r[t+1],m=c*u-d*a,f=c-a,p=d-u,g=o*p-l*f,x=(h*f-o*m)/g;if((x>=c&&x<=a||x>=a&&x<=c)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*p-l*m)/g;if((t>=d&&t<=u||t>=u&&t<=d)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}c=a,d=u}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return-1==e?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},t.SkeletonClipping=ze,t.SkeletonData=te,t.SkeletonDataResource=vs,t.SkeletonJson=Ge,t.Skin=se,t.SkinEntry=ee,t.Slot=Jt,t.SlotData=ie,t.SpineAnimationRenderer=ys,t.StringSet=i,t.Texture=bt,t.TextureAtlas=Ft,t.TextureAtlasPage=Yt,t.TextureAtlasRegion=Rt,t.TextureRegion=Ct,t.TimeKeeper=class{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){let t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}},t.Timeline=y,t.TrackEntry=at,t.TransformConstraint=Kt,t.TransformConstraintData=ne,t.TransformConstraintTimeline=z,t.TranslateTimeline=I,t.TranslateXTimeline=A,t.TranslateYTimeline=T,t.Triangulator=We,t.Utils=l,t.Vector2=c,t.VertexAttachment=u,t.WindowedMean=class{values;addedValues=0;lastValue=0;mean=0;dirty=!0;constructor(t=32){this.values=new Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0}},t.createTextureAtlas=ss,t.version=Ts,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
var t,e;t=this,e=function(t,e){"use strict";var s,i,a,r,n,l,o,h,d,c,u,f,m,g,p;function x(t,e,s,i){var a,r=arguments.length,n=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,s,i);else for(var l=t.length-1;l>=0;l--)(a=t[l])&&(n=(r<3?a(n):r>3?a(e,s,n):a(e,s))||n);return r>3&&n&&Object.defineProperty(e,s,n),n}"function"==typeof SuppressedError&&SuppressedError;class b{entries={};size=0;add(t){let e=this.entries[t];return this.entries[t]=!0,!e&&(this.size++,!0)}addAll(t){let e=this.size;for(var s=0,i=t.length;s<i;s++)this.add(t[s]);return e!=this.size}contains(t){return this.entries[t]}clear(){this.entries={},this.size=0}}class y{r;g;b;a;static WHITE=new y(1,1,1,1);static RED=new y(1,0,0,1);static GREEN=new y(0,1,0,1);static BLUE=new y(0,0,1,1);static MAGENTA=new y(1,0,1,1);constructor(t=0,e=0,s=0,i=0){this.r=t,this.g=e,this.b=s,this.a=i}set(t,e,s,i){return this.r=t,this.g=e,this.b=s,this.a=i,this.clamp()}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t="#"==t.charAt(0)?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=8!=t.length?1:parseInt(t.substr(6,2),16)/255,this}add(t,e,s,i){return this.r+=t,this.g+=e,this.b+=s,this.a+=i,this.clamp()}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(t,e){t.r=((0xff000000&e)>>>24)/255,t.g=((0xff0000&e)>>>16)/255,t.b=((65280&e)>>>8)/255,t.a=(255&e)/255}static rgb888ToColor(t,e){t.r=((0xff0000&e)>>>16)/255,t.g=((65280&e)>>>8)/255,t.b=(255&e)/255}toRgb888(){let t=t=>("0"+(255*t).toString(16)).slice(-2);return Number("0x"+t(this.r)+t(this.g)+t(this.b))}static fromString(t){return new y().setFromString(t)}}class w{static PI=3.1415927;static PI2=2*w.PI;static invPI2=1/w.PI2;static radiansToDegrees=180/w.PI;static radDeg=w.radiansToDegrees;static degreesToRadians=w.PI/180;static degRad=w.degreesToRadians;static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(t){return Math.cos(t*w.degRad)}static sinDeg(t){return Math.sin(t*w.degRad)}static atan2Deg(t,e){return Math.atan2(t,e)*w.degRad}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){let e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(t,e){return w.randomTriangularWith(t,e,(t+e)*.5)}static randomTriangularWith(t,e,s){let i=Math.random(),a=e-t;return i<=(s-t)/a?t+Math.sqrt(i*a*(s-t)):e-Math.sqrt((1-i)*a*(e-s))}static isPowerOfTwo(t){return t&&(t&t-1)==0}}class M{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class S extends M{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(2*t,this.power)/2:Math.pow((t-1)*2,this.power)/(this.power%2==0?-2:2)+1}}class k{static SUPPORTS_TYPED_ARRAYS="undefined"!=typeof Float32Array;static arrayCopy(t,e,s,i,a){for(let r=e,n=i;r<e+a;r++,n++)s[n]=t[r]}static arrayFill(t,e,s,i){for(let a=e;a<s;a++)t[a]=i}static setArraySize(t,e,s=0){let i=t.length;if(i==e)return t;if(t.length=e,i<e)for(let a=i;a<e;a++)t[a]=s;return t}static ensureArrayCapacity(t,e,s=0){return t.length>=e?t:k.setArraySize(t,e,s)}static newArray(t,e){let s=Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(t){if(k.SUPPORTS_TYPED_ARRAYS)return new Float32Array(t);{let e=Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static newShortArray(t){if(k.SUPPORTS_TYPED_ARRAYS)return new Int16Array(t);{let e=Array(t);for(let t=0;t<e.length;t++)e[t]=0;return e}}static toFloatArray(t){return k.SUPPORTS_TYPED_ARRAYS?new Float32Array(t):t}static toSinglePrecision(t){return k.SUPPORTS_TYPED_ARRAYS?Math.fround(t):t}static webkit602BugfixHelper(t,e){}static contains(t,e,s=!0){for(var i=0;i<t.length;i++)if(t[i]==e)return!0;return!1}static enumValue(t,e){return t[e[0].toUpperCase()+e.slice(1)]}}class I{items=[];instantiator;constructor(t){this.instantiator=t}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(t){t.reset&&t.reset(),this.items.push(t)}freeAll(t){for(let e=0;e<t.length;e++)this.free(t[e])}clear(){this.items.length=0}}class v{x;y;constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}length(){let t=this.x,e=this.y;return Math.sqrt(t*t+e*e)}normalize(){let t=this.length();return 0!=t&&(this.x/=t,this.y/=t),this}}class T{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){let t=Date.now()/1e3;this.delta=t-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=t,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}}class B{name;constructor(t){if(!t)throw Error("name cannot be null.");this.name=t}}class A extends B{static nextID=0;id=A.nextID++;bones=null;vertices=[];worldVerticesLength=0;timelineAttachment=this;constructor(t){super(t)}computeWorldVertices(t,e,s,i,a,r){s=a+(s>>1)*r;let n=t.bone.skeleton,l=t.deform,o=this.vertices,h=this.bones;if(!h){l.length>0&&(o=l);let n=t.bone,h=n.worldX,d=n.worldY,c=n.a,u=n.b,f=n.c,m=n.d;for(let t=e,n=a;n<s;t+=2,n+=r){let e=o[t],s=o[t+1];i[n]=e*c+s*u+h,i[n+1]=e*f+s*m+d}return}let d=0,c=0;for(let t=0;t<e;t+=2){let t=h[d];d+=t+1,c+=t}let u=n.bones;if(0==l.length)for(let t=a,e=3*c;t<s;t+=r){let s=0,a=0,r=h[d++];for(r+=d;d<r;d++,e+=3){let t=u[h[d]],i=o[e],r=o[e+1],n=o[e+2];s+=(i*t.a+r*t.b+t.worldX)*n,a+=(i*t.c+r*t.d+t.worldY)*n}i[t]=s,i[t+1]=a}else for(let t=a,e=3*c,n=c<<1;t<s;t+=r){let s=0,a=0,r=h[d++];for(r+=d;d<r;d++,e+=3,n+=2){let t=u[h[d]],i=o[e]+l[n],r=o[e+1]+l[n+1],c=o[e+2];s+=(i*t.a+r*t.b+t.worldX)*c,a+=(i*t.c+r*t.d+t.worldY)*c}i[t]=s,i[t+1]=a}}copyTo(t){this.bones?(t.bones=Array(this.bones.length),k.arrayCopy(this.bones,0,t.bones,0,this.bones.length)):t.bones=null,this.vertices&&(t.vertices=k.newFloatArray(this.vertices.length),k.arrayCopy(this.vertices,0,t.vertices,0,this.vertices.length)),t.worldVerticesLength=this.worldVerticesLength,t.timelineAttachment=this.timelineAttachment}}class F{static _nextID=0;id=F.nextID();regions;start=0;digits=0;setupIndex=0;constructor(t){this.regions=Array(t)}copy(){let t=new F(this.regions.length);return k.arrayCopy(this.regions,0,t.regions,0,this.regions.length),t.start=this.start,t.digits=this.digits,t.setupIndex=this.setupIndex,t}apply(t,e){let s=t.sequenceIndex;-1==s&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1);let i=this.regions[s];e.region!=i&&(e.region=i,e.updateRegion())}getPath(t,e){let s=t,i=(this.start+e).toString();for(let t=this.digits-i.length;t>0;t--)s+="0";return s+i}static nextID(){return F._nextID++}}(a=s||(s={}))[a.hold=0]="hold",a[a.once=1]="once",a[a.loop=2]="loop",a[a.pingpong=3]="pingpong",a[a.onceReverse=4]="onceReverse",a[a.loopReverse=5]="loopReverse",a[a.pingpongReverse=6]="pingpongReverse";let C=[s.hold,s.once,s.loop,s.pingpong,s.onceReverse,s.loopReverse,s.pingpongReverse];class E{name;timelines=[];timelineIds=new b;duration;constructor(t,e,s){if(!t)throw Error("name cannot be null.");this.name=t,this.setTimelines(e),this.duration=s}setTimelines(t){if(!t)throw Error("timelines cannot be null.");this.timelines=t,this.timelineIds.clear();for(var e=0;e<t.length;e++)this.timelineIds.addAll(t[e].getPropertyIds())}hasTimeline(t){for(let e=0;e<t.length;e++)if(this.timelineIds.contains(t[e]))return!0;return!1}apply(t,e,s,i,a,r,n,l){if(!t)throw Error("skeleton cannot be null.");i&&0!=this.duration&&(s%=this.duration,e>0&&(e%=this.duration));let o=this.timelines;for(let i=0,h=o.length;i<h;i++)o[i].apply(t,e,s,a,r,n,l)}}t.MixBlend=void 0,(r=t.MixBlend||(t.MixBlend={}))[r.setup=0]="setup",r[r.first=1]="first",r[r.replace=2]="replace",r[r.add=3]="add",t.MixDirection=void 0,(n=t.MixDirection||(t.MixDirection={}))[n.mixIn=0]="mixIn",n[n.mixOut=1]="mixOut";class R{propertyIds;frames;constructor(t,e){this.propertyIds=e,this.frames=k.newFloatArray(t*this.getFrameEntries())}getPropertyIds(){return this.propertyIds}getFrameEntries(){return 1}getFrameCount(){return this.frames.length/this.getFrameEntries()}getDuration(){return this.frames[this.frames.length-this.getFrameEntries()]}static search1(t,e){let s=t.length;for(let i=1;i<s;i++)if(t[i]>e)return i-1;return s-1}static search(t,e,s){let i=t.length;for(let a=s;a<i;a+=s)if(t[a]>e)return a-s;return i-s}}class Y extends R{curves;constructor(t,e,s){super(t,s),this.curves=k.newFloatArray(t+18*e),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){let e=this.getFrameCount()+18*t;if(this.curves.length>e){let t=k.newFloatArray(e);k.arrayCopy(this.curves,0,t,0,e),this.curves=t}}setBezier(t,e,s,i,a,r,n,l,o,h,d){let c=this.curves,u=this.getFrameCount()+18*t;0==s&&(c[e]=2+u);let f=(i-2*r+l)*.03,m=(a-2*n+o)*.03,g=((r-l)*3-i+h)*.006,p=((n-o)*3-a+d)*.006,x=2*f+g,b=2*m+p,y=(r-i)*.3+f+.16666667*g,w=(n-a)*.3+m+.16666667*p,M=i+y,S=a+w;for(let t=u+18;u<t;u+=2)c[u]=M,c[u+1]=S,y+=x,w+=b,x+=g,b+=p,M+=y,S+=w}getBezierValue(t,e,s,i){let a=this.curves;if(a[i]>t){let r=this.frames[e],n=this.frames[e+s];return n+(t-r)/(a[i]-r)*(a[i+1]-n)}let r=i+18;for(i+=2;i<r;i+=2)if(a[i]>=t){let e=a[i-2],s=a[i-1];return s+(t-e)/(a[i]-e)*(a[i+1]-s)}e+=this.getFrameEntries();let n=a[r-2],l=a[r-1];return l+(t-n)/(this.frames[e]-n)*(this.frames[e+s]-l)}}class P extends Y{constructor(t,e,s){super(t,e,[s])}getFrameEntries(){return 2}setFrame(t,e,s){t<<=1,this.frames[t]=e,this.frames[t+1]=s}getCurveValue(t){let e=this.frames,s=e.length-2;for(let i=2;i<=s;i+=2)if(e[i]>t){s=i-2;break}let i=this.curves[s>>1];switch(i){case 0:let a=e[s],r=e[s+1];return r+(t-a)/(e[s+2]-a)*(e[s+2+1]-r);case 1:return e[s+1]}return this.getBezierValue(t,s,1,i-2)}getRelativeValue(e,s,i,a,r){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return r;case t.MixBlend.first:return a+(r-a)*s}return a}let n=this.getCurveValue(e);switch(i){case t.MixBlend.setup:return r+n*s;case t.MixBlend.first:case t.MixBlend.replace:n+=r-a}return a+n*s}getAbsoluteValue(e,s,i,a,r){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return r;case t.MixBlend.first:return a+(r-a)*s}return a}let n=this.getCurveValue(e);return i==t.MixBlend.setup?r+(n-r)*s:a+(n-a)*s}getAbsoluteValue2(e,s,i,a,r,n){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return r;case t.MixBlend.first:return a+(r-a)*s}return a}return i==t.MixBlend.setup?r+(n-r)*s:a+(n-a)*s}getScaleValue(e,s,i,a,r,n){if(e<this.frames[0]){switch(i){case t.MixBlend.setup:return n;case t.MixBlend.first:return r+(n-r)*s}return r}let l=this.getCurveValue(e)*n;if(1==s)return i==t.MixBlend.add?r+l-n:l;if(a==t.MixDirection.mixOut)switch(i){case t.MixBlend.setup:return n+(Math.abs(l)*w.signum(n)-n)*s;case t.MixBlend.first:case t.MixBlend.replace:return r+(Math.abs(l)*w.signum(r)-r)*s}else{let e=0;switch(i){case t.MixBlend.setup:return(e=Math.abs(n)*w.signum(l))+(l-e)*s;case t.MixBlend.first:case t.MixBlend.replace:return(e=Math.abs(r)*w.signum(l))+(l-e)*s}}return r+(l-n)*s}}class X extends Y{constructor(t,e,s,i){super(t,e,[s,i])}getFrameEntries(){return 3}setFrame(t,e,s,i){t*=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i}}class _ extends P{boneIndex=0;constructor(t,e,s){super(t,e,"0|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.rotation=this.getRelativeValue(s,a,r,l.rotation,l.data.rotation))}}class V extends X{boneIndex=0;constructor(t,e,s){super(t,e,"1|"+s,"2|"+s),this.boneIndex=s}apply(e,s,i,a,r,n,l){let o=e.bones[this.boneIndex];if(!o.active)return;let h=this.frames;if(i<h[0]){switch(n){case t.MixBlend.setup:o.x=o.data.x,o.y=o.data.y;break;case t.MixBlend.first:o.x+=(o.data.x-o.x)*r,o.y+=(o.data.y-o.y)*r}return}let d=0,c=0,u=R.search(h,i,3),f=this.curves[u/3];switch(f){case 0:let m=h[u];d=h[u+1],c=h[u+2];let g=(i-m)/(h[u+3]-m);d+=(h[u+3+1]-d)*g,c+=(h[u+3+2]-c)*g;break;case 1:d=h[u+1],c=h[u+2];break;default:d=this.getBezierValue(i,u,1,f-2),c=this.getBezierValue(i,u,2,f+18-2)}switch(n){case t.MixBlend.setup:o.x=o.data.x+d*r,o.y=o.data.y+c*r;break;case t.MixBlend.first:case t.MixBlend.replace:o.x+=(o.data.x+d-o.x)*r,o.y+=(o.data.y+c-o.y)*r;break;case t.MixBlend.add:o.x+=d*r,o.y+=c*r}}}class D extends P{boneIndex=0;constructor(t,e,s){super(t,e,"1|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.x=this.getRelativeValue(s,a,r,l.x,l.data.x))}}class O extends P{boneIndex=0;constructor(t,e,s){super(t,e,"2|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.y=this.getRelativeValue(s,a,r,l.y,l.data.y))}}class N extends X{boneIndex=0;constructor(t,e,s){super(t,e,"3|"+s,"4|"+s),this.boneIndex=s}apply(e,s,i,a,r,n,l){let o,h,d=e.bones[this.boneIndex];if(!d.active)return;let c=this.frames;if(i<c[0]){switch(n){case t.MixBlend.setup:d.scaleX=d.data.scaleX,d.scaleY=d.data.scaleY;break;case t.MixBlend.first:d.scaleX+=(d.data.scaleX-d.scaleX)*r,d.scaleY+=(d.data.scaleY-d.scaleY)*r}return}let u=R.search(c,i,3),f=this.curves[u/3];switch(f){case 0:let m=c[u];o=c[u+1],h=c[u+2];let g=(i-m)/(c[u+3]-m);o+=(c[u+3+1]-o)*g,h+=(c[u+3+2]-h)*g;break;case 1:o=c[u+1],h=c[u+2];break;default:o=this.getBezierValue(i,u,1,f-2),h=this.getBezierValue(i,u,2,f+18-2)}if(o*=d.data.scaleX,h*=d.data.scaleY,1==r)n==t.MixBlend.add?(d.scaleX+=o-d.data.scaleX,d.scaleY+=h-d.data.scaleY):(d.scaleX=o,d.scaleY=h);else{let e=0,s=0;if(l==t.MixDirection.mixOut)switch(n){case t.MixBlend.setup:e=d.data.scaleX,s=d.data.scaleY,d.scaleX=e+(Math.abs(o)*w.signum(e)-e)*r,d.scaleY=s+(Math.abs(h)*w.signum(s)-s)*r;break;case t.MixBlend.first:case t.MixBlend.replace:e=d.scaleX,s=d.scaleY,d.scaleX=e+(Math.abs(o)*w.signum(e)-e)*r,d.scaleY=s+(Math.abs(h)*w.signum(s)-s)*r;break;case t.MixBlend.add:d.scaleX+=(o-d.data.scaleX)*r,d.scaleY+=(h-d.data.scaleY)*r}else switch(n){case t.MixBlend.setup:e=Math.abs(d.data.scaleX)*w.signum(o),s=Math.abs(d.data.scaleY)*w.signum(h),d.scaleX=e+(o-e)*r,d.scaleY=s+(h-s)*r;break;case t.MixBlend.first:case t.MixBlend.replace:e=Math.abs(d.scaleX)*w.signum(o),s=Math.abs(d.scaleY)*w.signum(h),d.scaleX=e+(o-e)*r,d.scaleY=s+(h-s)*r;break;case t.MixBlend.add:d.scaleX+=(o-d.data.scaleX)*r,d.scaleY+=(h-d.data.scaleY)*r}}}}class L extends P{boneIndex=0;constructor(t,e,s){super(t,e,"3|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.scaleX=this.getScaleValue(s,a,r,n,l.scaleX,l.data.scaleX))}}class q extends P{boneIndex=0;constructor(t,e,s){super(t,e,"4|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.scaleY=this.getScaleValue(s,a,r,n,l.scaleY,l.data.scaleY))}}class U extends X{boneIndex=0;constructor(t,e,s){super(t,e,"5|"+s,"6|"+s),this.boneIndex=s}apply(e,s,i,a,r,n,l){let o=e.bones[this.boneIndex];if(!o.active)return;let h=this.frames;if(i<h[0]){switch(n){case t.MixBlend.setup:o.shearX=o.data.shearX,o.shearY=o.data.shearY;break;case t.MixBlend.first:o.shearX+=(o.data.shearX-o.shearX)*r,o.shearY+=(o.data.shearY-o.shearY)*r}return}let d=0,c=0,u=R.search(h,i,3),f=this.curves[u/3];switch(f){case 0:let m=h[u];d=h[u+1],c=h[u+2];let g=(i-m)/(h[u+3]-m);d+=(h[u+3+1]-d)*g,c+=(h[u+3+2]-c)*g;break;case 1:d=h[u+1],c=h[u+2];break;default:d=this.getBezierValue(i,u,1,f-2),c=this.getBezierValue(i,u,2,f+18-2)}switch(n){case t.MixBlend.setup:o.shearX=o.data.shearX+d*r,o.shearY=o.data.shearY+c*r;break;case t.MixBlend.first:case t.MixBlend.replace:o.shearX+=(o.data.shearX+d-o.shearX)*r,o.shearY+=(o.data.shearY+c-o.shearY)*r;break;case t.MixBlend.add:o.shearX+=d*r,o.shearY+=c*r}}}class W extends P{boneIndex=0;constructor(t,e,s){super(t,e,"5|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.shearX=this.getRelativeValue(s,a,r,l.shearX,l.data.shearX))}}class z extends P{boneIndex=0;constructor(t,e,s){super(t,e,"6|"+s),this.boneIndex=s}apply(t,e,s,i,a,r,n){let l=t.bones[this.boneIndex];l.active&&(l.shearY=this.getRelativeValue(s,a,r,l.shearY,l.data.shearY))}}class G extends R{boneIndex=0;constructor(t,e){super(t,["7|"+e]),this.boneIndex=e}getFrameEntries(){return 2}setFrame(t,e,s){t*=2,this.frames[t]=e,this.frames[t+1]=s}apply(e,s,i,a,r,n,l){let o=e.bones[this.boneIndex];if(!o.active)return;if(l==t.MixDirection.mixOut){n==t.MixBlend.setup&&(o.inherit=o.data.inherit);return}let h=this.frames;if(i<h[0]){(n==t.MixBlend.setup||n==t.MixBlend.first)&&(o.inherit=o.data.inherit);return}o.inherit=this.frames[R.search(h,i,2)+1]}}class $ extends Y{slotIndex=0;constructor(t,e,s){super(t,e,["8|"+s,"9|"+s]),this.slotIndex=s}getFrameEntries(){return 5}setFrame(t,e,s,i,a,r){t*=5,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=a,this.frames[t+4]=r}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(!o.bone.active)return;let h=this.frames,d=o.color;if(i<h[0]){let e=o.data.color;switch(n){case t.MixBlend.setup:d.setFromColor(e);break;case t.MixBlend.first:d.add((e.r-d.r)*r,(e.g-d.g)*r,(e.b-d.b)*r,(e.a-d.a)*r)}return}let c=0,u=0,f=0,m=0,g=R.search(h,i,5),p=this.curves[g/5];switch(p){case 0:let x=h[g];c=h[g+1],u=h[g+2],f=h[g+3],m=h[g+4];let b=(i-x)/(h[g+5]-x);c+=(h[g+5+1]-c)*b,u+=(h[g+5+2]-u)*b,f+=(h[g+5+3]-f)*b,m+=(h[g+5+4]-m)*b;break;case 1:c=h[g+1],u=h[g+2],f=h[g+3],m=h[g+4];break;default:c=this.getBezierValue(i,g,1,p-2),u=this.getBezierValue(i,g,2,p+18-2),f=this.getBezierValue(i,g,3,p+36-2),m=this.getBezierValue(i,g,4,p+54-2)}1==r?d.set(c,u,f,m):(n==t.MixBlend.setup&&d.setFromColor(o.data.color),d.add((c-d.r)*r,(u-d.g)*r,(f-d.b)*r,(m-d.a)*r))}}class j extends Y{slotIndex=0;constructor(t,e,s){super(t,e,["8|"+s]),this.slotIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,a){t<<=2,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=a}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(!o.bone.active)return;let h=this.frames,d=o.color;if(i<h[0]){let e=o.data.color;switch(n){case t.MixBlend.setup:d.r=e.r,d.g=e.g,d.b=e.b;break;case t.MixBlend.first:d.r+=(e.r-d.r)*r,d.g+=(e.g-d.g)*r,d.b+=(e.b-d.b)*r}return}let c=0,u=0,f=0,m=R.search(h,i,4),g=this.curves[m>>2];switch(g){case 0:let p=h[m];c=h[m+1],u=h[m+2],f=h[m+3];let x=(i-p)/(h[m+4]-p);c+=(h[m+4+1]-c)*x,u+=(h[m+4+2]-u)*x,f+=(h[m+4+3]-f)*x;break;case 1:c=h[m+1],u=h[m+2],f=h[m+3];break;default:c=this.getBezierValue(i,m,1,g-2),u=this.getBezierValue(i,m,2,g+18-2),f=this.getBezierValue(i,m,3,g+36-2)}if(1==r)d.r=c,d.g=u,d.b=f;else{if(n==t.MixBlend.setup){let t=o.data.color;d.r=t.r,d.g=t.g,d.b=t.b}d.r+=(c-d.r)*r,d.g+=(u-d.g)*r,d.b+=(f-d.b)*r}}}class H extends P{slotIndex=0;constructor(t,e,s){super(t,e,"9|"+s),this.slotIndex=s}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(!o.bone.active)return;let h=o.color;if(i<this.frames[0]){let e=o.data.color;switch(n){case t.MixBlend.setup:h.a=e.a;break;case t.MixBlend.first:h.a+=(e.a-h.a)*r}return}let d=this.getCurveValue(i);1==r?h.a=d:(n==t.MixBlend.setup&&(h.a=o.data.color.a),h.a+=(d-h.a)*r)}}class J extends Y{slotIndex=0;constructor(t,e,s){super(t,e,["8|"+s,"9|"+s,"10|"+s]),this.slotIndex=s}getFrameEntries(){return 8}setFrame(t,e,s,i,a,r,n,l,o){t<<=3,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=a,this.frames[t+4]=r,this.frames[t+5]=n,this.frames[t+6]=l,this.frames[t+7]=o}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(!o.bone.active)return;let h=this.frames,d=o.color,c=o.darkColor;if(i<h[0]){let e=o.data.color,s=o.data.darkColor;switch(n){case t.MixBlend.setup:d.setFromColor(e),c.r=s.r,c.g=s.g,c.b=s.b;break;case t.MixBlend.first:d.add((e.r-d.r)*r,(e.g-d.g)*r,(e.b-d.b)*r,(e.a-d.a)*r),c.r+=(s.r-c.r)*r,c.g+=(s.g-c.g)*r,c.b+=(s.b-c.b)*r}return}let u=0,f=0,m=0,g=0,p=0,x=0,b=0,y=R.search(h,i,8),w=this.curves[y>>3];switch(w){case 0:let M=h[y];u=h[y+1],f=h[y+2],m=h[y+3],g=h[y+4],p=h[y+5],x=h[y+6],b=h[y+7];let S=(i-M)/(h[y+8]-M);u+=(h[y+8+1]-u)*S,f+=(h[y+8+2]-f)*S,m+=(h[y+8+3]-m)*S,g+=(h[y+8+4]-g)*S,p+=(h[y+8+5]-p)*S,x+=(h[y+8+6]-x)*S,b+=(h[y+8+7]-b)*S;break;case 1:u=h[y+1],f=h[y+2],m=h[y+3],g=h[y+4],p=h[y+5],x=h[y+6],b=h[y+7];break;default:u=this.getBezierValue(i,y,1,w-2),f=this.getBezierValue(i,y,2,w+18-2),m=this.getBezierValue(i,y,3,w+36-2),g=this.getBezierValue(i,y,4,w+54-2),p=this.getBezierValue(i,y,5,w+72-2),x=this.getBezierValue(i,y,6,w+90-2),b=this.getBezierValue(i,y,7,w+108-2)}if(1==r)d.set(u,f,m,g),c.r=p,c.g=x,c.b=b;else{if(n==t.MixBlend.setup){d.setFromColor(o.data.color);let t=o.data.darkColor;c.r=t.r,c.g=t.g,c.b=t.b}d.add((u-d.r)*r,(f-d.g)*r,(m-d.b)*r,(g-d.a)*r),c.r+=(p-c.r)*r,c.g+=(x-c.g)*r,c.b+=(b-c.b)*r}}}class K extends Y{slotIndex=0;constructor(t,e,s){super(t,e,["8|"+s,"10|"+s]),this.slotIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,a,r,n,l){t*=7,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=a,this.frames[t+4]=r,this.frames[t+5]=n,this.frames[t+6]=l}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(!o.bone.active)return;let h=this.frames,d=o.color,c=o.darkColor;if(i<h[0]){let e=o.data.color,s=o.data.darkColor;switch(n){case t.MixBlend.setup:d.r=e.r,d.g=e.g,d.b=e.b,c.r=s.r,c.g=s.g,c.b=s.b;break;case t.MixBlend.first:d.r+=(e.r-d.r)*r,d.g+=(e.g-d.g)*r,d.b+=(e.b-d.b)*r,c.r+=(s.r-c.r)*r,c.g+=(s.g-c.g)*r,c.b+=(s.b-c.b)*r}return}let u=0,f=0,m=0,g=0,p=0,x=0,b=R.search(h,i,7),y=this.curves[b/7];switch(y){case 0:let w=h[b];u=h[b+1],f=h[b+2],m=h[b+3],g=h[b+4],p=h[b+5],x=h[b+6];let M=(i-w)/(h[b+7]-w);u+=(h[b+7+1]-u)*M,f+=(h[b+7+2]-f)*M,m+=(h[b+7+3]-m)*M,g+=(h[b+7+4]-g)*M,p+=(h[b+7+5]-p)*M,x+=(h[b+7+6]-x)*M;break;case 1:u=h[b+1],f=h[b+2],m=h[b+3],g=h[b+4],p=h[b+5],x=h[b+6];break;default:u=this.getBezierValue(i,b,1,y-2),f=this.getBezierValue(i,b,2,y+18-2),m=this.getBezierValue(i,b,3,y+36-2),g=this.getBezierValue(i,b,4,y+54-2),p=this.getBezierValue(i,b,5,y+72-2),x=this.getBezierValue(i,b,6,y+90-2)}if(1==r)d.r=u,d.g=f,d.b=m,c.r=g,c.g=p,c.b=x;else{if(n==t.MixBlend.setup){let t=o.data.color,e=o.data.darkColor;d.r=t.r,d.g=t.g,d.b=t.b,c.r=e.r,c.g=e.g,c.b=e.b}d.r+=(u-d.r)*r,d.g+=(f-d.g)*r,d.b+=(m-d.b)*r,c.r+=(g-c.r)*r,c.g+=(p-c.g)*r,c.b+=(x-c.b)*r}}}class Q extends R{slotIndex=0;attachmentNames;constructor(t,e){super(t,["11|"+e]),this.slotIndex=e,this.attachmentNames=Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(o.bone.active){if(l==t.MixDirection.mixOut){n==t.MixBlend.setup&&this.setAttachment(e,o,o.data.attachmentName);return}if(i<this.frames[0]){(n==t.MixBlend.setup||n==t.MixBlend.first)&&this.setAttachment(e,o,o.data.attachmentName);return}this.setAttachment(e,o,this.attachmentNames[R.search1(this.frames,i)])}}setAttachment(t,e,s){e.setAttachment(s?t.getAttachment(this.slotIndex,s):null)}}class Z extends Y{slotIndex=0;attachment;vertices;constructor(t,e,s,i){super(t,e,["12|"+s+"|"+i.id]),this.slotIndex=s,this.attachment=i,this.vertices=Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.vertices[t]=s}setBezier(t,e,s,i,a,r,n,l,o,h,d){let c=this.curves,u=this.getFrameCount()+18*t;0==s&&(c[e]=2+u);let f=(i-2*r+l)*.03,m=.03*o-.06*n,g=((r-l)*3-i+h)*.006,p=(n-o+.33333333)*.018,x=2*f+g,b=2*m+p,y=(r-i)*.3+f+.16666667*g,w=.3*n+m+.16666667*p,M=i+y,S=w;for(let t=u+18;u<t;u+=2)c[u]=M,c[u+1]=S,y+=x,w+=b,x+=g,b+=p,M+=y,S+=w}getCurvePercent(t,e){let s=this.curves,i=s[e];switch(i){case 0:let a=this.frames[e];return(t-a)/(this.frames[e+this.getFrameEntries()]-a);case 1:return 0}if(s[i-=2]>t){let a=this.frames[e];return s[i+1]*(t-a)/(s[i]-a)}let r=i+18;for(i+=2;i<r;i+=2)if(s[i]>=t){let e=s[i-2],a=s[i-1];return a+(t-e)/(s[i]-e)*(s[i+1]-a)}let n=s[r-2],l=s[r-1];return l+(1-l)*(t-n)/(this.frames[e+this.getFrameEntries()]-n)}apply(e,s,i,a,r,n,l){let o=e.slots[this.slotIndex];if(!o.bone.active)return;let h=o.getAttachment();if(!h||!(h instanceof A)||h.timelineAttachment!=this.attachment)return;let d=o.deform;0==d.length&&(n=t.MixBlend.setup);let c=this.vertices,u=c[0].length,f=this.frames;if(i<f[0]){switch(n){case t.MixBlend.setup:d.length=0;break;case t.MixBlend.first:if(1==r){d.length=0;break}if(d.length=u,h.bones){r=1-r;for(var m=0;m<u;m++)d[m]*=r}else{let t=h.vertices;for(var m=0;m<u;m++)d[m]+=(t[m]-d[m])*r}}return}if(d.length=u,i>=f[f.length-1]){let e=c[f.length-1];if(1==r){if(n==t.MixBlend.add){if(h.bones)for(let t=0;t<u;t++)d[t]+=e[t];else{let t=h.vertices;for(let s=0;s<u;s++)d[s]+=e[s]-t[s]}}else k.arrayCopy(e,0,d,0,u)}else switch(n){case t.MixBlend.setup:if(h.bones)for(let t=0;t<u;t++)d[t]=e[t]*r;else{let t=h.vertices;for(let s=0;s<u;s++){let i=t[s];d[s]=i+(e[s]-i)*r}}break;case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<u;t++)d[t]+=(e[t]-d[t])*r;break;case t.MixBlend.add:if(h.bones)for(let t=0;t<u;t++)d[t]+=e[t]*r;else{let t=h.vertices;for(let s=0;s<u;s++)d[s]+=(e[s]-t[s])*r}}return}let g=R.search1(f,i),p=this.getCurvePercent(i,g),x=c[g],b=c[g+1];if(1==r){if(n==t.MixBlend.add){if(h.bones)for(let t=0;t<u;t++){let e=x[t];d[t]+=e+(b[t]-e)*p}else{let t=h.vertices;for(let e=0;e<u;e++){let s=x[e];d[e]+=s+(b[e]-s)*p-t[e]}}}else for(let t=0;t<u;t++){let e=x[t];d[t]=e+(b[t]-e)*p}}else switch(n){case t.MixBlend.setup:if(h.bones)for(let t=0;t<u;t++){let e=x[t];d[t]=(e+(b[t]-e)*p)*r}else{let t=h.vertices;for(let e=0;e<u;e++){let s=x[e],i=t[e];d[e]=i+(s+(b[e]-s)*p-i)*r}}break;case t.MixBlend.first:case t.MixBlend.replace:for(let t=0;t<u;t++){let e=x[t];d[t]+=(e+(b[t]-e)*p-d[t])*r}break;case t.MixBlend.add:if(h.bones)for(let t=0;t<u;t++){let e=x[t];d[t]+=(e+(b[t]-e)*p)*r}else{let t=h.vertices;for(let e=0;e<u;e++){let s=x[e];d[e]+=(s+(b[e]-s)*p-t[e])*r}}}}}class tt extends R{static propertyIds=["13"];events;constructor(t){super(t,tt.propertyIds),this.events=Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e.time,this.events[t]=e}apply(t,e,s,i,a,r,n){if(!i)return;let l=this.frames,o=this.frames.length;if(e>s)this.apply(t,e,Number.MAX_VALUE,i,a,r,n),e=-1;else if(e>=l[o-1])return;if(s<l[0])return;let h=0;if(e<l[0])h=0;else{h=R.search1(l,e)+1;let t=l[h];for(;h>0&&l[h-1]==t;)h--}for(;h<o&&s>=l[h];h++)i.push(this.events[h])}}class te extends R{static propertyIds=["14"];drawOrders;constructor(t){super(t,te.propertyIds),this.drawOrders=Array(t)}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(e,s,i,a,r,n,l){if(l==t.MixDirection.mixOut){n==t.MixBlend.setup&&k.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length);return}if(i<this.frames[0]){(n==t.MixBlend.setup||n==t.MixBlend.first)&&k.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length);return}let o=R.search1(this.frames,i),h=this.drawOrders[o];if(h){let t=e.drawOrder,s=e.slots;for(let e=0,i=h.length;e<i;e++)t[e]=s[h[e]]}else k.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length)}}class ts extends Y{constraintIndex=0;constructor(t,e,s){super(t,e,["15|"+s]),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(t,e,s,i,a,r,n){t*=6,this.frames[t]=e,this.frames[t+1]=s,this.frames[t+2]=i,this.frames[t+3]=a,this.frames[t+4]=r?1:0,this.frames[t+5]=n?1:0}apply(e,s,i,a,r,n,l){let o=e.ikConstraints[this.constraintIndex];if(!o.active)return;let h=this.frames;if(i<h[0]){switch(n){case t.MixBlend.setup:o.mix=o.data.mix,o.softness=o.data.softness,o.bendDirection=o.data.bendDirection,o.compress=o.data.compress,o.stretch=o.data.stretch;break;case t.MixBlend.first:o.mix+=(o.data.mix-o.mix)*r,o.softness+=(o.data.softness-o.softness)*r,o.bendDirection=o.data.bendDirection,o.compress=o.data.compress,o.stretch=o.data.stretch}return}let d=0,c=0,u=R.search(h,i,6),f=this.curves[u/6];switch(f){case 0:let m=h[u];d=h[u+1],c=h[u+2];let g=(i-m)/(h[u+6]-m);d+=(h[u+6+1]-d)*g,c+=(h[u+6+2]-c)*g;break;case 1:d=h[u+1],c=h[u+2];break;default:d=this.getBezierValue(i,u,1,f-2),c=this.getBezierValue(i,u,2,f+18-2)}n==t.MixBlend.setup?(o.mix=o.data.mix+(d-o.data.mix)*r,o.softness=o.data.softness+(c-o.data.softness)*r,l==t.MixDirection.mixOut?(o.bendDirection=o.data.bendDirection,o.compress=o.data.compress,o.stretch=o.data.stretch):(o.bendDirection=h[u+3],o.compress=0!=h[u+4],o.stretch=0!=h[u+5])):(o.mix+=(d-o.mix)*r,o.softness+=(c-o.softness)*r,l==t.MixDirection.mixIn&&(o.bendDirection=h[u+3],o.compress=0!=h[u+4],o.stretch=0!=h[u+5]))}}class ti extends Y{constraintIndex=0;constructor(t,e,s){super(t,e,["16|"+s]),this.constraintIndex=s}getFrameEntries(){return 7}setFrame(t,e,s,i,a,r,n,l){let o=this.frames;o[t*=7]=e,o[t+1]=s,o[t+2]=i,o[t+3]=a,o[t+4]=r,o[t+5]=n,o[t+6]=l}apply(e,s,i,a,r,n,l){let o,h,d,c,u,f,m=e.transformConstraints[this.constraintIndex];if(!m.active)return;let g=this.frames;if(i<g[0]){let e=m.data;switch(n){case t.MixBlend.setup:m.mixRotate=e.mixRotate,m.mixX=e.mixX,m.mixY=e.mixY,m.mixScaleX=e.mixScaleX,m.mixScaleY=e.mixScaleY,m.mixShearY=e.mixShearY;break;case t.MixBlend.first:m.mixRotate+=(e.mixRotate-m.mixRotate)*r,m.mixX+=(e.mixX-m.mixX)*r,m.mixY+=(e.mixY-m.mixY)*r,m.mixScaleX+=(e.mixScaleX-m.mixScaleX)*r,m.mixScaleY+=(e.mixScaleY-m.mixScaleY)*r,m.mixShearY+=(e.mixShearY-m.mixShearY)*r}return}let p=R.search(g,i,7),x=this.curves[p/7];switch(x){case 0:let b=g[p];o=g[p+1],h=g[p+2],d=g[p+3],c=g[p+4],u=g[p+5],f=g[p+6];let y=(i-b)/(g[p+7]-b);o+=(g[p+7+1]-o)*y,h+=(g[p+7+2]-h)*y,d+=(g[p+7+3]-d)*y,c+=(g[p+7+4]-c)*y,u+=(g[p+7+5]-u)*y,f+=(g[p+7+6]-f)*y;break;case 1:o=g[p+1],h=g[p+2],d=g[p+3],c=g[p+4],u=g[p+5],f=g[p+6];break;default:o=this.getBezierValue(i,p,1,x-2),h=this.getBezierValue(i,p,2,x+18-2),d=this.getBezierValue(i,p,3,x+36-2),c=this.getBezierValue(i,p,4,x+54-2),u=this.getBezierValue(i,p,5,x+72-2),f=this.getBezierValue(i,p,6,x+90-2)}if(n==t.MixBlend.setup){let t=m.data;m.mixRotate=t.mixRotate+(o-t.mixRotate)*r,m.mixX=t.mixX+(h-t.mixX)*r,m.mixY=t.mixY+(d-t.mixY)*r,m.mixScaleX=t.mixScaleX+(c-t.mixScaleX)*r,m.mixScaleY=t.mixScaleY+(u-t.mixScaleY)*r,m.mixShearY=t.mixShearY+(f-t.mixShearY)*r}else m.mixRotate+=(o-m.mixRotate)*r,m.mixX+=(h-m.mixX)*r,m.mixY+=(d-m.mixY)*r,m.mixScaleX+=(c-m.mixScaleX)*r,m.mixScaleY+=(u-m.mixScaleY)*r,m.mixShearY+=(f-m.mixShearY)*r}}class ta extends P{constraintIndex=0;constructor(t,e,s){super(t,e,"17|"+s),this.constraintIndex=s}apply(t,e,s,i,a,r,n){let l=t.pathConstraints[this.constraintIndex];l.active&&(l.position=this.getAbsoluteValue(s,a,r,l.position,l.data.position))}}class tr extends P{constraintIndex=0;constructor(t,e,s){super(t,e,"18|"+s),this.constraintIndex=s}apply(t,e,s,i,a,r,n){let l=t.pathConstraints[this.constraintIndex];l.active&&(l.spacing=this.getAbsoluteValue(s,a,r,l.spacing,l.data.spacing))}}class tn extends Y{constraintIndex=0;constructor(t,e,s){super(t,e,["19|"+s]),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(t,e,s,i,a){let r=this.frames;r[t<<=2]=e,r[t+1]=s,r[t+2]=i,r[t+3]=a}apply(e,s,i,a,r,n,l){let o,h,d,c=e.pathConstraints[this.constraintIndex];if(!c.active)return;let u=this.frames;if(i<u[0]){switch(n){case t.MixBlend.setup:c.mixRotate=c.data.mixRotate,c.mixX=c.data.mixX,c.mixY=c.data.mixY;break;case t.MixBlend.first:c.mixRotate+=(c.data.mixRotate-c.mixRotate)*r,c.mixX+=(c.data.mixX-c.mixX)*r,c.mixY+=(c.data.mixY-c.mixY)*r}return}let f=R.search(u,i,4),m=this.curves[f>>2];switch(m){case 0:let g=u[f];o=u[f+1],h=u[f+2],d=u[f+3];let p=(i-g)/(u[f+4]-g);o+=(u[f+4+1]-o)*p,h+=(u[f+4+2]-h)*p,d+=(u[f+4+3]-d)*p;break;case 1:o=u[f+1],h=u[f+2],d=u[f+3];break;default:o=this.getBezierValue(i,f,1,m-2),h=this.getBezierValue(i,f,2,m+18-2),d=this.getBezierValue(i,f,3,m+36-2)}if(n==t.MixBlend.setup){let t=c.data;c.mixRotate=t.mixRotate+(o-t.mixRotate)*r,c.mixX=t.mixX+(h-t.mixX)*r,c.mixY=t.mixY+(d-t.mixY)*r}else c.mixRotate+=(o-c.mixRotate)*r,c.mixX+=(h-c.mixX)*r,c.mixY+=(d-c.mixY)*r}}class tl extends P{constraintIndex=0;constructor(t,e,s,i){super(t,e,i+"|"+s),this.constraintIndex=s}apply(t,e,s,i,a,r,n){let l;if(-1==this.constraintIndex){let e=s>=this.frames[0]?this.getCurveValue(s):0;for(let i of t.physicsConstraints)i.active&&this.global(i.data)&&this.set(i,this.getAbsoluteValue2(s,a,r,this.get(i),this.setup(i),e))}else(l=t.physicsConstraints[this.constraintIndex]).active&&this.set(l,this.getAbsoluteValue(s,a,r,this.get(l),this.setup(l)))}}class to extends tl{constructor(t,e,s){super(t,e,s,20)}setup(t){return t.data.inertia}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}}class th extends tl{constructor(t,e,s){super(t,e,s,21)}setup(t){return t.data.strength}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}}class td extends tl{constructor(t,e,s){super(t,e,s,22)}setup(t){return t.data.damping}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}}class tc extends tl{constructor(t,e,s){super(t,e,s,23)}setup(t){return 1/t.data.massInverse}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}}class tu extends tl{constructor(t,e,s){super(t,e,s,24)}setup(t){return t.data.wind}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}}class tf extends tl{constructor(t,e,s){super(t,e,s,25)}setup(t){return t.data.gravity}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}}class tm extends tl{constructor(t,e,s){super(t,e,s,26)}setup(t){return t.data.mix}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}}class tg extends R{static propertyIds=["27"];constraintIndex;constructor(t,e){super(t,tg.propertyIds),this.constraintIndex=e}getFrameCount(){return this.frames.length}setFrame(t,e){this.frames[t]=e}apply(t,e,s,i,a,r,n){let l;if(-1!=this.constraintIndex&&!(l=t.physicsConstraints[this.constraintIndex]).active)return;let o=this.frames;if(e>s)this.apply(t,e,Number.MAX_VALUE,[],a,r,n),e=-1;else if(e>=o[o.length-1])return;if(!(s<o[0])&&(e<o[0]||s>=o[R.search1(o,e)+1])){if(null!=l)l.reset();else for(let e of t.physicsConstraints)e.active&&e.reset()}}}class tp extends R{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(t,e,s){super(t,["28|"+e+"|"+s.sequence.id]),this.slotIndex=e,this.attachment=s}getFrameEntries(){return tp.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(t,e,s,i,a){let r=this.frames;r[t*=tp.ENTRIES]=e,r[t+tp.MODE]=s|i<<4,r[t+tp.DELAY]=a}apply(e,i,a,r,n,l,o){let h=e.slots[this.slotIndex];if(!h.bone.active)return;let d=h.attachment,c=this.attachment;if(d!=c&&(!(d instanceof A)||d.timelineAttachment!=c))return;if(o==t.MixDirection.mixOut){l==t.MixBlend.setup&&(h.sequenceIndex=-1);return}let u=this.frames;if(a<u[0]){(l==t.MixBlend.setup||l==t.MixBlend.first)&&(h.sequenceIndex=-1);return}let f=R.search(u,a,tp.ENTRIES),m=u[f],g=u[f+tp.MODE],p=u[f+tp.DELAY];if(!this.attachment.sequence)return;let x=g>>4,b=this.attachment.sequence.regions.length,y=C[15&g];if(y!=s.hold)switch(x+=(a-m)/p+1e-5|0,y){case s.once:x=Math.min(b-1,x);break;case s.loop:x%=b;break;case s.pingpong:{let t=(b<<1)-2;(x=0==t?0:x%t)>=b&&(x=t-x);break}case s.onceReverse:x=Math.max(b-1-x,0);break;case s.loopReverse:x=b-1-x%b;break;case s.pingpongReverse:{let t=(b<<1)-2;(x=0==t?0:(x+b-1)%t)>=b&&(x=t-x)}}h.sequenceIndex=x}}class tx{static _emptyAnimation=new E("<empty>",[],0);static emptyAnimation(){return tx._emptyAnimation}data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new ty(this);propertyIDs=new b;animationsChanged=!1;trackEntryPool=new I(()=>new tb);constructor(t){this.data=t}update(t){t*=this.timeScale;let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(!i)continue;i.animationLast=i.nextAnimationLast,i.trackLast=i.nextTrackLast;let a=t*i.timeScale;if(i.delay>0){if(i.delay-=a,i.delay>0)continue;a=-i.delay,i.delay=0}let r=i.next;if(r){let e=i.trackLast-r.delay;if(e>=0){for(r.delay=0,r.trackTime+=0==i.timeScale?0:(e/i.timeScale+t)*r.timeScale,i.trackTime+=a,this.setCurrent(s,r,!0);r.mixingFrom;)r.mixTime+=t,r=r.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&!i.mixingFrom){e[s]=null,this.queue.end(i),this.clearNext(i);continue}if(i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null,t&&(t.mixingTo=null);t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=a}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(!s)return!0;let i=this.updateMixingFrom(s,e);return(s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,t.mixTime>0&&t.mixTime>=t.mixDuration)?((0==s.totalAlpha||0==t.mixDuration)&&(t.mixingFrom=s.mixingFrom,s.mixingFrom&&(s.mixingFrom.mixingTo=t),t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e,!1)}apply(e){if(!e)throw Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,a=!1;for(let n=0,l=i.length;n<l;n++){let l=i[n];if(!l||l.delay>0)continue;a=!0;let o=0==n?t.MixBlend.first:l.mixBlend,h=l.alpha;l.mixingFrom?h*=this.applyMixingFrom(l,e,o):l.trackTime>=l.trackEnd&&!l.next&&(h=0);let d=h>=l.alphaAttachmentThreshold,c=l.animationLast,u=l.getAnimationTime(),f=u,m=s;l.reverse&&(f=l.animation.duration-f,m=null);let g=l.animation.timelines,p=g.length;if(0==n&&1==h||o==t.MixBlend.add){0==n&&(d=!0);for(let s=0;s<p;s++){k.webkit602BugfixHelper(h,o);var r=g[s];r instanceof Q?this.applyAttachmentTimeline(r,e,f,o,d):r.apply(e,c,f,m,h,o,t.MixDirection.mixIn)}}else{let s=l.timelineMode,i=l.shortestRotation,a=!i&&l.timelinesRotation.length!=p<<1;a&&(l.timelinesRotation.length=p<<1);for(let r=0;r<p;r++){let n=g[r],u=s[r]==tw?o:t.MixBlend.setup;!i&&n instanceof _?this.applyRotateTimeline(n,e,f,h,u,l.timelinesRotation,r<<1,a):n instanceof Q?this.applyAttachmentTimeline(n,e,f,o,d):(k.webkit602BugfixHelper(h,o),n.apply(e,c,f,m,h,u,t.MixDirection.mixIn))}}this.queueEvents(l,u),s.length=0,l.nextAnimationLast=u,l.nextTrackLast=l.trackTime}for(var n=this.unkeyedState+tv,l=e.slots,o=0,h=e.slots.length;o<h;o++){var d=l[o];if(d.attachmentState==n){var c=d.data.attachmentName;d.setAttachment(c?e.getAttachment(d.data.index,c):null)}}return this.unkeyedState+=2,this.queue.drain(),a}applyMixingFrom(e,s,i){let a=e.mixingFrom;a.mixingFrom&&this.applyMixingFrom(a,s,i);let r=0;0==e.mixDuration?(r=1,i==t.MixBlend.first&&(i=t.MixBlend.setup)):((r=e.mixTime/e.mixDuration)>1&&(r=1),i!=t.MixBlend.first&&(i=a.mixBlend));let n=r<a.mixAttachmentThreshold,l=r<a.mixDrawOrderThreshold,o=a.animation.timelines,h=o.length,d=a.alpha*e.interruptAlpha,c=d*(1-r),u=a.animationLast,f=a.getAnimationTime(),m=f,g=null;if(a.reverse?m=a.animation.duration-m:r<a.eventThreshold&&(g=this.events),i==t.MixBlend.add)for(let e=0;e<h;e++)o[e].apply(s,u,m,g,c,i,t.MixDirection.mixOut);else{let e=a.timelineMode,r=a.timelineHoldMix,f=a.shortestRotation,p=!f&&a.timelinesRotation.length!=h<<1;p&&(a.timelinesRotation.length=h<<1),a.totalAlpha=0;for(let x=0;x<h;x++){let h,b=o[x],y=t.MixDirection.mixOut,w=0;switch(e[x]){case tw:if(!l&&b instanceof te)continue;h=i,w=c;break;case tM:h=t.MixBlend.setup,w=c;break;case tS:h=i,w=d;break;case tk:h=t.MixBlend.setup,w=d;break;default:h=t.MixBlend.setup;let M=r[x];w=d*Math.max(0,1-M.mixTime/M.mixDuration)}a.totalAlpha+=w,!f&&b instanceof _?this.applyRotateTimeline(b,s,m,w,h,a.timelinesRotation,x<<1,p):b instanceof Q?this.applyAttachmentTimeline(b,s,m,h,n&&w>=a.alphaAttachmentThreshold):(k.webkit602BugfixHelper(w,i),l&&b instanceof te&&h==t.MixBlend.setup&&(y=t.MixDirection.mixIn),b.apply(s,u,m,g,w,h,y))}}return e.mixDuration>0&&this.queueEvents(a,f),this.events.length=0,a.nextAnimationLast=f,a.nextTrackLast=a.trackTime,r}applyAttachmentTimeline(e,s,i,a,r){var n=s.slots[e.slotIndex];n.bone.active&&(i<e.frames[0]?(a==t.MixBlend.setup||a==t.MixBlend.first)&&this.setAttachment(s,n,n.data.attachmentName,r):this.setAttachment(s,n,e.attachmentNames[R.search1(e.frames,i)],r),n.attachmentState<=this.unkeyedState&&(n.attachmentState=this.unkeyedState+tv))}setAttachment(t,e,s,i){e.setAttachment(s?t.getAttachment(e.data.index,s):null),i&&(e.attachmentState=this.unkeyedState+tT)}applyRotateTimeline(e,s,i,a,r,n,l,o){if(o&&(n[l]=0),1==a){e.apply(s,0,i,null,1,r,t.MixDirection.mixIn);return}let h=s.bones[e.boneIndex];if(!h.active)return;let d=e.frames,c=0,u=0;if(i<d[0])switch(r){case t.MixBlend.setup:h.rotation=h.data.rotation;default:return;case t.MixBlend.first:c=h.rotation,u=h.data.rotation}else c=r==t.MixBlend.setup?h.data.rotation:h.rotation,u=h.data.rotation+e.getCurveValue(i);let f=0,m=u-c;if(0==(m-=360*Math.ceil(m/360-.5)))f=n[l];else{let t=0,e=0;o?(t=0,e=m):(t=n[l],e=n[l+1]);let s=t-t%360;f=m+s;let i=m>=0,a=t>=0;90>=Math.abs(e)&&w.signum(e)!=w.signum(m)&&(Math.abs(t-s)>180?(f+=360*w.signum(t),a=i):0!=s?f-=360*w.signum(t):a=i),a!=i&&(f+=360*w.signum(t)),n[l]=f}n[l+1]=m,h.rotation=c+f*a}queueEvents(t,e){let s=t.animationStart,i=t.animationEnd,a=i-s,r=t.trackLast%a,n=this.events,l=0,o=n.length;for(;l<o;l++){let e=n[l];if(e.time<r)break;e.time>i||this.queue.event(t,e)}let h=!1;if(t.loop){if(0==a)h=!0;else{let e=Math.floor(t.trackTime/a);h=e>0&&e>Math.floor(t.trackLast/a)}}else h=e>=i&&t.animationLast<i;for(h&&this.queue.complete(t);l<o;l++){let e=n[l];e.time<s||this.queue.event(t,e)}}clearTracks(){let t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let t=0,e=this.tracks.length;t<e;t++)this.clearTrack(t);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t>=this.tracks.length)return;let e=this.tracks[t];if(!e)return;this.queue.end(e),this.clearNext(e);let s=e;for(;;){let t=s.mixingFrom;if(!t)break;this.queue.end(t),s.mixingFrom=null,s.mixingTo=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,e.previous=null,i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,i.mixingTo=e,e.mixTime=0,i.mixingFrom&&i.mixDuration>0&&(e.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(e)}setAnimation(t,e,s=!1){let i=this.data.skeletonData.findAnimation(e);if(!i)throw Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s=!1){if(!e)throw Error("animation cannot be null.");let i=!0,a=this.expandToIndex(t);a&&(-1==a.nextTrackLast?(this.tracks[t]=a.mixingFrom,this.queue.interrupt(a),this.queue.end(a),this.clearNext(a),a=a.mixingFrom,i=!1):this.clearNext(a));let r=this.trackEntry(t,e,s,a);return this.setCurrent(t,r,i),this.queue.drain(),r}addAnimation(t,e,s=!1,i=0){let a=this.data.skeletonData.findAnimation(e);if(!a)throw Error("Animation not found: "+e);return this.addAnimationWith(t,a,s,i)}addAnimationWith(t,e,s=!1,i=0){if(!e)throw Error("animation cannot be null.");let a=this.expandToIndex(t);if(a)for(;a.next;)a=a.next;let r=this.trackEntry(t,e,s,a);return a?(a.next=r,r.previous=a,i<=0&&(i+=a.getTrackComplete()-r.mixDuration)):(this.setCurrent(t,r,!0),this.queue.drain()),r.delay=i,r}setEmptyAnimation(t,e=0){let s=this.setAnimationWith(t,tx.emptyAnimation(),!1);return s.mixDuration=e,s.trackEnd=e,s}addEmptyAnimation(t,e=0,s=0){let i=this.addAnimationWith(t,tx.emptyAnimation(),!1,s);return s<=0&&(i.delay+=i.mixDuration-e),i.mixDuration=e,i.trackEnd=e,i}setEmptyAnimations(t=0){let e=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let e=0,s=this.tracks.length;e<s;e++){let s=this.tracks[e];s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(k.ensureArrayCapacity(this.tracks,t+1,null),this.tracks.length=t+1,null)}trackEntry(e,s,i,a){let r=this.trackEntryPool.obtain();return r.reset(),r.trackIndex=e,r.animation=s,r.loop=i,r.holdPrevious=!1,r.reverse=!1,r.shortestRotation=!1,r.eventThreshold=0,r.alphaAttachmentThreshold=0,r.mixAttachmentThreshold=0,r.mixDrawOrderThreshold=0,r.animationStart=0,r.animationEnd=s.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.mixTime=0,r.mixDuration=a?this.data.getMix(a.animation,s):0,r.interruptAlpha=1,r.totalAlpha=0,r.mixBlend=t.MixBlend.replace,r}clearNext(t){let e=t.next;for(;e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1,this.propertyIDs.clear();let e=this.tracks;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i){for(;i.mixingFrom;)i=i.mixingFrom;do i.mixingTo&&i.mixBlend==t.MixBlend.add||this.computeHold(i),i=i.mixingTo;while(i)}}}computeHold(t){let e=t.mixingTo,s=t.animation.timelines,i=t.animation.timelines.length,a=t.timelineMode;a.length=i;let r=t.timelineHoldMix;r.length=0;let n=this.propertyIDs;if(e&&e.holdPrevious){for(let t=0;t<i;t++)a[t]=n.addAll(s[t].getPropertyIds())?tk:tS;return}t:for(let l=0;l<i;l++){let i=s[l],o=i.getPropertyIds();if(n.addAll(o)){if(!e||i instanceof Q||i instanceof te||i instanceof tt||!e.animation.hasTimeline(o))a[l]=tM;else{for(let s=e.mixingTo;s;s=s.mixingTo)if(!s.animation.hasTimeline(o)){if(t.mixDuration>0){a[l]=tI,r[l]=s;continue t}break}a[l]=tk}}else a[l]=tw}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(!t)throw Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>=0&&this.listeners.splice(e,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}}class tb{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;holdPrevious=!1;reverse=!1;shortestRotation=!1;eventThreshold=0;mixAttachmentThreshold=0;alphaAttachmentThreshold=0;mixDrawOrderThreshold=0;animationStart=0;animationEnd=0;animationLast=0;nextAnimationLast=0;delay=0;trackTime=0;trackLast=0;nextTrackLast=0;trackEnd=0;timeScale=0;alpha=0;mixTime=0;_mixDuration=0;interruptAlpha=0;totalAlpha=0;get mixDuration(){return this._mixDuration}set mixDuration(t){this._mixDuration=t}setMixDurationWithDelay(t,e){this._mixDuration=t,null!=this.previous&&e<=0&&(e+=this.previous.getTrackComplete()-t),this.delay=e}mixBlend=t.MixBlend.replace;timelineMode=[];timelineHoldMix=[];timelinesRotation=[];reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return 0==t?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){let t=this.animationEnd-this.animationStart;if(0!=t){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime<t)return t}return this.trackTime}wasApplied(){return -1!=this.nextTrackLast}isNextReady(){return null!=this.next&&this.nextTrackLast-this.next.delay>=0}}class ty{objects=[];drainDisabled=!1;animState;constructor(t){this.animState=t}start(e){this.objects.push(t.EventType.start),this.objects.push(e),this.animState.animationsChanged=!0}interrupt(e){this.objects.push(t.EventType.interrupt),this.objects.push(e)}end(e){this.objects.push(t.EventType.end),this.objects.push(e),this.animState.animationsChanged=!0}dispose(e){this.objects.push(t.EventType.dispose),this.objects.push(e)}complete(e){this.objects.push(t.EventType.complete),this.objects.push(e)}event(e,s){this.objects.push(t.EventType.event),this.objects.push(e),this.objects.push(s)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let e=this.objects,s=this.animState.listeners;for(let i=0;i<e.length;i+=2){let a=e[i],r=e[i+1];switch(a){case t.EventType.start:r.listener&&r.listener.start&&r.listener.start(r);for(let t=0;t<s.length;t++){let e=s[t];e.start&&e.start(r)}break;case t.EventType.interrupt:r.listener&&r.listener.interrupt&&r.listener.interrupt(r);for(let t=0;t<s.length;t++){let e=s[t];e.interrupt&&e.interrupt(r)}break;case t.EventType.end:r.listener&&r.listener.end&&r.listener.end(r);for(let t=0;t<s.length;t++){let e=s[t];e.end&&e.end(r)}case t.EventType.dispose:r.listener&&r.listener.dispose&&r.listener.dispose(r);for(let t=0;t<s.length;t++){let e=s[t];e.dispose&&e.dispose(r)}this.animState.trackEntryPool.free(r);break;case t.EventType.complete:r.listener&&r.listener.complete&&r.listener.complete(r);for(let t=0;t<s.length;t++){let e=s[t];e.complete&&e.complete(r)}break;case t.EventType.event:let n=e[i+++2];r.listener&&r.listener.event&&r.listener.event(r,n);for(let t=0;t<s.length;t++){let e=s[t];e.event&&e.event(r,n)}}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}t.EventType=void 0,(l=t.EventType||(t.EventType={}))[l.start=0]="start",l[l.interrupt=1]="interrupt",l[l.end=2]="end",l[l.dispose=3]="dispose",l[l.complete=4]="complete",l[l.event=5]="event";let tw=0,tM=1,tS=2,tk=3,tI=4,tv=1,tT=2;class tB{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(!i)throw Error("Animation not found: "+t);let a=this.skeletonData.findAnimation(e);if(!a)throw Error("Animation not found: "+e);this.setMixWith(i,a,s)}setMixWith(t,e,s){if(!t)throw Error("from cannot be null.");if(!e)throw Error("to cannot be null.");let i=t.name+"."+e.name;this.animationToMixTime[i]=s}getMix(t,e){let s=t.name+"."+e.name,i=this.animationToMixTime[s];return void 0===i?this.defaultMix:i}}class tA extends A{color=new y(1,1,1,1);constructor(t){super(t)}copy(){let t=new tA(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t}}class tF extends A{endSlot=null;color=new y(.2275,.2275,.8078,1);constructor(t){super(t)}copy(){let t=new tF(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.color.setFromColor(this.color),t}}class tC{_image;constructor(t){this._image=t}getImage(){return this._image}}t.TextureFilter=void 0,(o=t.TextureFilter||(t.TextureFilter={}))[o.Nearest=9728]="Nearest",o[o.Linear=9729]="Linear",o[o.MipMap=9987]="MipMap",o[o.MipMapNearestNearest=9984]="MipMapNearestNearest",o[o.MipMapLinearNearest=9985]="MipMapLinearNearest",o[o.MipMapNearestLinear=9986]="MipMapNearestLinear",o[o.MipMapLinearLinear=9987]="MipMapLinearLinear",t.TextureWrap=void 0,(h=t.TextureWrap||(t.TextureWrap={}))[h.MirroredRepeat=33648]="MirroredRepeat",h[h.ClampToEdge=33071]="ClampToEdge",h[h.Repeat=10497]="Repeat";class tE{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0}class tR{pages=[];regions=[];constructor(e){let s=new tY(e),i=[,,,,],a={};a.size=t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},a.format=()=>{},a.filter=e=>{e.minFilter=k.enumValue(t.TextureFilter,i[1]),e.magFilter=k.enumValue(t.TextureFilter,i[2])},a.repeat=e=>{-1!=i[1].indexOf("x")&&(e.uWrap=t.TextureWrap.Repeat),-1!=i[1].indexOf("y")&&(e.vWrap=t.TextureWrap.Repeat)},a.pma=t=>{t.pma="true"==i[1]};var r={};r.xy=t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2])},r.size=t=>{t.width=parseInt(i[1]),t.height=parseInt(i[2])},r.bounds=t=>{t.x=parseInt(i[1]),t.y=parseInt(i[2]),t.width=parseInt(i[3]),t.height=parseInt(i[4])},r.offset=t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2])},r.orig=t=>{t.originalWidth=parseInt(i[1]),t.originalHeight=parseInt(i[2])},r.offsets=t=>{t.offsetX=parseInt(i[1]),t.offsetY=parseInt(i[2]),t.originalWidth=parseInt(i[3]),t.originalHeight=parseInt(i[4])},r.rotate=t=>{let e=i[1];"true"==e?t.degrees=90:"false"!=e&&(t.degrees=parseInt(e))},r.index=t=>{t.index=parseInt(i[1])};let n=s.readLine();for(;n&&0==n.trim().length;)n=s.readLine();for(;n&&0!=n.trim().length&&0!=s.readEntry(i,n);)n=s.readLine();let l=null,o=null,h=null;for(;null!==n;)if(0==n.trim().length)l=null,n=s.readLine();else if(l){let t=new tX(l,n);for(;;){let e=s.readEntry(i,n=s.readLine());if(0==e)break;let a=r[i[0]];if(a)a(t);else{o||(o=[]),h||(h=[]),o.push(i[0]);let t=[];for(let s=0;s<e;s++)t.push(parseInt(i[s+1]));h.push(t)}}0==t.originalWidth&&0==t.originalHeight&&(t.originalWidth=t.width,t.originalHeight=t.height),o&&o.length>0&&h&&h.length>0&&(t.names=o,t.values=h,o=null,h=null),t.u=t.x/l.width,t.v=t.y/l.height,90==t.degrees?(t.u2=(t.x+t.height)/l.width,t.v2=(t.y+t.width)/l.height):(t.u2=(t.x+t.width)/l.width,t.v2=(t.y+t.height)/l.height),this.regions.push(t)}else{for(l=new tP(n.trim());0!=s.readEntry(i,n=s.readLine());){let t=a[i[0]];t&&t(l)}this.pages.push(l)}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}setTextures(t,e=""){for(let s of this.pages)s.setTexture(t.get(e+s.name))}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture?.dispose()}}class tY{lines;index=0;constructor(t){this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readEntry(t,e){if(!e||0==(e=e.trim()).length)return 0;let s=e.indexOf(":");if(-1==s)return 0;t[0]=e.substr(0,s).trim();for(let i=1,a=s+1;;i++){let s=e.indexOf(",",a);if(-1==s)return t[i]=e.substr(a).trim(),i;if(t[i]=e.substr(a,s-a).trim(),a=s+1,4==i)return 4}}}class tP{name;minFilter=t.TextureFilter.Nearest;magFilter=t.TextureFilter.Nearest;uWrap=t.TextureWrap.ClampToEdge;vWrap=t.TextureWrap.ClampToEdge;texture=null;width=0;height=0;pma=!1;regions=[];constructor(t){this.name=t}setTexture(t){for(let e of(this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap),this.regions))e.texture=t}}class tX extends tE{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(t,e){super(),this.page=t,this.name=e,t.regions.push(this)}}class t_ extends A{region=null;path;regionUVs=[];uvs=[];triangles=[];color=new y(1,1,1,1);width=0;height=0;hullLength=0;edges=[];parentMesh=null;sequence=null;tempColor=new y(0,0,0,0);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw Error("Region not set.");let t=this.regionUVs;this.uvs&&this.uvs.length==t.length||(this.uvs=k.newFloatArray(t.length));let e=this.uvs,s=this.uvs.length,i=this.region.u,a=this.region.v,r=0,n=0;if(this.region instanceof tX){let l=this.region,o=l.page,h=o.width,d=o.height;switch(l.degrees){case 90:i-=(l.originalHeight-l.offsetY-l.height)/h,a-=(l.originalWidth-l.offsetX-l.width)/d,r=l.originalHeight/h,n=l.originalWidth/d;for(let l=0;l<s;l+=2)e[l]=i+t[l+1]*r,e[l+1]=a+(1-t[l])*n;return;case 180:i-=(l.originalWidth-l.offsetX-l.width)/h,a-=l.offsetY/d,r=l.originalWidth/h,n=l.originalHeight/d;for(let l=0;l<s;l+=2)e[l]=i+(1-t[l])*r,e[l+1]=a+(1-t[l+1])*n;return;case 270:i-=l.offsetY/h,a-=l.offsetX/d,r=l.originalHeight/h,n=l.originalWidth/d;for(let l=0;l<s;l+=2)e[l]=i+(1-t[l+1])*r,e[l+1]=a+t[l]*n;return}i-=l.offsetX/h,a-=(l.originalHeight-l.offsetY-l.height)/d,r=l.originalWidth/h,n=l.originalHeight/d}else this.region?(r=this.region.u2-i,n=this.region.v2-a):(i=a=0,r=n=1);for(let l=0;l<s;l+=2)e[l]=i+t[l]*r,e[l+1]=a+t[l+1]*n}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength)}copy(){if(this.parentMesh)return this.newLinkedMesh();let t=new t_(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),this.copyTo(t),t.regionUVs=Array(this.regionUVs.length),k.arrayCopy(this.regionUVs,0,t.regionUVs,0,this.regionUVs.length),t.uvs=Array(this.uvs.length),k.arrayCopy(this.uvs,0,t.uvs,0,this.uvs.length),t.triangles=Array(this.triangles.length),k.arrayCopy(this.triangles,0,t.triangles,0,this.triangles.length),t.hullLength=this.hullLength,t.sequence=null!=this.sequence?this.sequence.copy():null,this.edges&&(t.edges=Array(this.edges.length),k.arrayCopy(this.edges,0,t.edges,0,this.edges.length)),t.width=this.width,t.height=this.height,t}computeWorldVertices(t,e,s,i,a,r){null!=this.sequence&&this.sequence.apply(t,this),super.computeWorldVertices(t,e,s,i,a,r)}newLinkedMesh(){let t=new t_(this.name,this.path);return t.region=this.region,t.color.setFromColor(this.color),t.timelineAttachment=this.timelineAttachment,t.setParentMesh(this.parentMesh?this.parentMesh:this),null!=t.region&&t.updateRegion(),t}}class tV extends A{lengths=[];closed=!1;constantSpeed=!1;color=new y(1,1,1,1);constructor(t){super(t)}copy(){let t=new tV(this.name);return this.copyTo(t),t.lengths=Array(this.lengths.length),k.arrayCopy(this.lengths,0,t.lengths,0,this.lengths.length),t.closed=closed,t.constantSpeed=this.constantSpeed,t.color.setFromColor(this.color),t}}class tD extends A{x=0;y=0;rotation=0;color=new y(.38,.94,0,1);constructor(t){super(t)}computeWorldPosition(t,e){return e.x=this.x*t.a+this.y*t.b+t.worldX,e.y=this.x*t.c+this.y*t.d+t.worldY,e}computeWorldRotation(t){let e=this.rotation*w.degRad,s=Math.cos(e),i=Math.sin(e),a=s*t.a+i*t.b,r=s*t.c+i*t.d;return w.atan2Deg(r,a)}copy(){let t=new tD(this.name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t}}class tO extends B{x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;color=new y(1,1,1,1);path;region=null;sequence=null;offset=k.newFloatArray(8);uvs=k.newFloatArray(8);tempColor=new y(1,1,1,1);constructor(t,e){super(t),this.path=e}updateRegion(){if(!this.region)throw Error("Region not set.");let t=this.region,e=this.uvs;if(null==t){e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=1,e[5]=1,e[6]=1,e[7]=0;return}let s=this.width/this.region.originalWidth*this.scaleX,i=this.height/this.region.originalHeight*this.scaleY,a=-this.width/2*this.scaleX+this.region.offsetX*s,r=-this.height/2*this.scaleY+this.region.offsetY*i,n=a+this.region.width*s,l=r+this.region.height*i,o=this.rotation*w.degRad,h=Math.cos(o),d=Math.sin(o),c=this.x,u=this.y,f=a*h+c,m=a*d,g=r*h+u,p=r*d,x=n*h+c,b=n*d,y=l*h+u,M=l*d,S=this.offset;S[0]=f-p,S[1]=g+m,S[2]=f-M,S[3]=y+m,S[4]=x-M,S[5]=y+b,S[6]=x-p,S[7]=g+b,90==t.degrees?(e[0]=t.u2,e[1]=t.v2,e[2]=t.u,e[3]=t.v2,e[4]=t.u,e[5]=t.v,e[6]=t.u2,e[7]=t.v):(e[0]=t.u,e[1]=t.v2,e[2]=t.u,e[3]=t.v,e[4]=t.u2,e[5]=t.v,e[6]=t.u2,e[7]=t.v2)}computeWorldVertices(t,e,s,i){null!=this.sequence&&this.sequence.apply(t,this);let a=t.bone,r=this.offset,n=a.worldX,l=a.worldY,o=a.a,h=a.b,d=a.c,c=a.d,u=0,f=0;u=r[0],f=r[1],e[s]=u*o+f*h+n,e[s+1]=u*d+f*c+l,s+=i,u=r[2],f=r[3],e[s]=u*o+f*h+n,e[s+1]=u*d+f*c+l,s+=i,u=r[4],f=r[5],e[s]=u*o+f*h+n,e[s+1]=u*d+f*c+l,s+=i,u=r[6],f=r[7],e[s]=u*o+f*h+n,e[s+1]=u*d+f*c+l}copy(){let t=new tO(this.name,this.path);return t.region=this.region,t.x=this.x,t.y=this.y,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.rotation=this.rotation,t.width=this.width,t.height=this.height,k.arrayCopy(this.uvs,0,t.uvs,0,8),k.arrayCopy(this.offset,0,t.offset,0,8),t.color.setFromColor(this.color),t.sequence=null!=this.sequence?this.sequence.copy():null,t}static X1=0;static Y1=1;static C1R=2;static C1G=3;static C1B=4;static C1A=5;static U1=6;static V1=7;static X2=8;static Y2=9;static C2R=10;static C2G=11;static C2B=12;static C2A=13;static U2=14;static V2=15;static X3=16;static Y3=17;static C3R=18;static C3G=19;static C3B=20;static C3A=21;static U3=22;static V3=23;static X4=24;static Y4=25;static C4R=26;static C4G=27;static C4B=28;static C4A=29;static U4=30;static V4=31}class tN{atlas;constructor(t){this.atlas=t}loadSequence(t,e,s){let i=s.regions;for(let a=0,r=i.length;a<r;a++){let r=s.getPath(e,a),n=this.atlas.findRegion(r);if(null==n)throw Error("Region not found in atlas: "+r+" (sequence: "+t+")");i[a]=n}}newRegionAttachment(t,e,s,i){let a=new tO(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw Error("Region not found in atlas: "+s+" (region attachment: "+e+")");a.region=t}return a}newMeshAttachment(t,e,s,i){let a=new t_(e,s);if(null!=i)this.loadSequence(e,s,i);else{let t=this.atlas.findRegion(s);if(!t)throw Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");a.region=t}return a}newBoundingBoxAttachment(t,e){return new tA(e)}newPathAttachment(t,e){return new tV(e)}newPointAttachment(t,e){return new tD(e)}newClippingAttachment(t,e){return new tF(e)}}class tL{index=0;name;parent=null;length=0;x=0;y=0;rotation=0;scaleX=1;scaleY=1;shearX=0;shearY=0;inherit=t.Inherit.Normal;skinRequired=!1;color=new y;icon;visible=!1;constructor(t,e,s){if(t<0)throw Error("index must be >= 0.");if(!e)throw Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}t.Inherit=void 0,(d=t.Inherit||(t.Inherit={}))[d.Normal=0]="Normal",d[d.OnlyTranslation=1]="OnlyTranslation",d[d.NoRotationOrReflection=2]="NoRotationOrReflection",d[d.NoScale=3]="NoScale",d[d.NoScaleOrReflection=4]="NoScaleOrReflection";class tq{data;skeleton;parent=null;children=[];x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;ax=0;ay=0;arotation=0;ascaleX=0;ascaleY=0;ashearX=0;ashearY=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;inherit=t.Inherit.Normal;sorted=!1;active=!1;constructor(t,e,s){if(!t)throw Error("data cannot be null.");if(!e)throw Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}isActive(){return this.active}update(t){this.updateWorldTransformWith(this.ax,this.ay,this.arotation,this.ascaleX,this.ascaleY,this.ashearX,this.ashearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(e,s,i,a,r,n,l){this.ax=e,this.ay=s,this.arotation=i,this.ascaleX=a,this.ascaleY=r,this.ashearX=n,this.ashearY=l;let o=this.parent;if(!o){let t=this.skeleton,o=t.scaleX,h=t.scaleY,d=(i+n)*w.degRad,c=(i+90+l)*w.degRad;this.a=Math.cos(d)*a*o,this.b=Math.cos(c)*r*o,this.c=Math.sin(d)*a*h,this.d=Math.sin(c)*r*h,this.worldX=e*o+t.x,this.worldY=s*h+t.y;return}let h=o.a,d=o.b,c=o.c,u=o.d;switch(this.worldX=h*e+d*s+o.worldX,this.worldY=c*e+u*s+o.worldY,this.inherit){case t.Inherit.Normal:{let t=(i+n)*w.degRad,e=(i+90+l)*w.degRad,s=Math.cos(t)*a,o=Math.cos(e)*r,f=Math.sin(t)*a,m=Math.sin(e)*r;this.a=h*s+d*f,this.b=h*o+d*m,this.c=c*s+u*f,this.d=c*o+u*m;return}case t.Inherit.OnlyTranslation:{let t=(i+n)*w.degRad,e=(i+90+l)*w.degRad;this.a=Math.cos(t)*a,this.b=Math.cos(e)*r,this.c=Math.sin(t)*a,this.d=Math.sin(e)*r;break}case t.Inherit.NoRotationOrReflection:{let t=1/this.skeleton.scaleX,e=1/this.skeleton.scaleY,s=(h*=t)*h+(c*=e)*c,o=0;s>1e-4?(s=Math.abs(h*u*e-d*t*c)/s,d=c*s,u=h*s,o=Math.atan2(c,h)*w.radDeg):(h=0,c=0,o=90-Math.atan2(u,d)*w.radDeg);let f=(i+n-o)*w.degRad,m=(i+l-o+90)*w.degRad,g=Math.cos(f)*a,p=Math.cos(m)*r,x=Math.sin(f)*a,b=Math.sin(m)*r;this.a=h*g-d*x,this.b=h*p-d*b,this.c=c*g+u*x,this.d=c*p+u*b;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:{let e=Math.cos(i*=w.degRad),s=Math.sin(i),o=(h*e+d*s)/this.skeleton.scaleX,f=(c*e+u*s)/this.skeleton.scaleY,m=Math.sqrt(o*o+f*f);m>1e-5&&(m=1/m),o*=m,f*=m,m=Math.sqrt(o*o+f*f),this.inherit==t.Inherit.NoScale&&h*u-d*c<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(m=-m);let g=Math.cos(i=Math.PI/2+Math.atan2(f,o))*m,p=Math.sin(i)*m;n*=w.degRad,l=(90+l)*w.degRad;let x=Math.cos(n)*a,b=Math.cos(l)*r,y=Math.sin(n)*a,M=Math.sin(l)*r;this.a=o*x+g*y,this.b=o*b+g*M,this.c=f*x+p*y,this.d=f*b+p*M}}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY}setToSetupPose(){let t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY,this.inherit=t.inherit}updateAppliedTransform(){let e,s,i,a,r=this.parent;if(!r){this.ax=this.worldX-this.skeleton.x,this.ay=this.worldY-this.skeleton.y,this.arotation=Math.atan2(this.c,this.a)*w.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*w.radDeg;return}let n=r.a,l=r.b,o=r.c,h=r.d,d=1/(n*h-l*o),c=h*d,u=l*d,f=o*d,m=n*d,g=this.worldX-r.worldX,p=this.worldY-r.worldY;if(this.ax=g*c-p*u,this.ay=p*m-g*f,this.inherit==t.Inherit.OnlyTranslation)e=this.a,s=this.b,i=this.c,a=this.d;else{switch(this.inherit){case t.Inherit.NoRotationOrReflection:{let t=Math.abs(n*h-l*o)/(n*n+o*o);l=-o*this.skeleton.scaleX*t/this.skeleton.scaleY,h=n*this.skeleton.scaleY*t/this.skeleton.scaleX,d=1/(n*h-l*o),c=h*d,u=l*d;break}case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:let r=w.cosDeg(this.rotation),g=w.sinDeg(this.rotation),p=Math.sqrt((n=(n*r+l*g)/this.skeleton.scaleX)*n+(o=(o*r+h*g)/this.skeleton.scaleY)*o);p>1e-5&&(p=1/p),n*=p,o*=p,p=Math.sqrt(n*n+o*o),this.inherit==t.Inherit.NoScale&&d<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(p=-p);let x=w.PI/2+Math.atan2(o,n);l=Math.cos(x)*p,d=1/(n*(h=Math.sin(x)*p)-l*o),c=h*d,u=l*d,f=o*d,m=n*d}e=c*this.a-u*this.c,s=c*this.b-u*this.d,i=m*this.c-f*this.a,a=m*this.d-f*this.b}if(this.ashearX=0,this.ascaleX=Math.sqrt(e*e+i*i),this.ascaleX>1e-4){let t=e*a-s*i;this.ascaleY=t/this.ascaleX,this.ashearY=-Math.atan2(e*s+i*a,t)*w.radDeg,this.arotation=Math.atan2(i,e)*w.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(s*s+a*a),this.ashearY=0,this.arotation=90-Math.atan2(a,s)*w.radDeg}getWorldRotationX(){return Math.atan2(this.c,this.a)*w.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*w.radDeg}getWorldScaleX(){return Math.sqrt(this.a*this.a+this.c*this.c)}getWorldScaleY(){return Math.sqrt(this.b*this.b+this.d*this.d)}worldToLocal(t){let e=1/(this.a*this.d-this.b*this.c),s=t.x-this.worldX,i=t.y-this.worldY;return t.x=s*this.d*e-i*this.b*e,t.y=i*this.a*e-s*this.c*e,t}localToWorld(t){let e=t.x,s=t.y;return t.x=e*this.a+s*this.b+this.worldX,t.y=e*this.c+s*this.d+this.worldY,t}worldToParent(t){if(null==t)throw Error("world cannot be null.");return null==this.parent?t:this.parent.worldToLocal(t)}parentToWorld(t){if(null==t)throw Error("world cannot be null.");return null==this.parent?t:this.parent.localToWorld(t)}worldToLocalRotation(t){let e=w.sinDeg(t),s=w.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*w.radDeg+this.rotation-this.shearX}localToWorldRotation(t){t-=this.rotation-this.shearX;let e=w.sinDeg(t),s=w.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*w.radDeg}rotateWorld(t){let e=Math.sin(t*=w.degRad),s=Math.cos(t),i=this.a,a=this.b;this.a=s*i-e*this.c,this.b=s*a-e*this.d,this.c=e*i+s*this.c,this.d=e*a+s*this.d}}class tU{name;order;skinRequired;constructor(t,e,s){this.name=t,this.order=e,this.skinRequired=s}}class tW{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw Error("Not a data URI.");let e=t.indexOf("base64,");return -1!=e?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){for(var e=window.atob(t),s=e.length,i=new Uint8Array(s),a=0;a<s;a++)i[a]=e.charCodeAt(a);return i}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw Error("Not a data URI.");let e=t.indexOf("base64,");if(-1==e)throw Error("Not a binary data URI.");return e+=7,this.base64ToUint8Array(t.substr(e))}downloadText(t,e,s){if(this.start(t,e,s))return;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToString(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",t,!0);let a=()=>{this.finish(t,i.status,i.responseText)};i.onload=a,i.onerror=a,i.send()}downloadJson(t,e,s){this.downloadText(t,t=>{e(JSON.parse(t))},s)}downloadBinary(t,e,s){if(this.start(t,e,s))return;if(this.rawDataUris[t]){try{let e=this.rawDataUris[t];this.finish(t,200,this.dataUriToUint8Array(e))}catch(e){this.finish(t,400,JSON.stringify(e))}return}let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";let a=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{200==i.status||0==i.status?this.finish(t,200,new Uint8Array(i.response)):a()},i.onerror=a,i.send()}start(t,e,s){let i=this.callbacks[t];try{if(i)return!0;this.callbacks[t]=i=[]}finally{i.push(e,s)}}finish(t,e,s){let i=this.callbacks[t];delete this.callbacks[t];let a=200==e||0==e?[s]:[e,s];for(let t=a.length-1,e=i.length;t<e;t+=2)i[t].apply(null,a)}}class tz{data;intValue=0;floatValue=0;stringValue=null;time=0;volume=0;balance=0;constructor(t,e){if(!e)throw Error("data cannot be null.");this.time=t,this.data=e}}class tG{name;intValue=0;floatValue=0;stringValue=null;audioPath=null;volume=0;balance=0;constructor(t){this.name=t}}class t${data;bones;target;bendDirection=0;compress=!1;stretch=!1;mix=1;softness=0;active=!1;constructor(t,e){if(!t)throw Error("data cannot be null.");if(!e)throw Error("skeleton cannot be null.");this.data=t,this.bones=[];for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw Error(`Couldn't find bone ${t.bones[s].name}`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw Error(`Couldn't find bone ${t.target.name}`);this.target=s,this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}isActive(){return this.active}setToSetupPose(){let t=this.data;this.mix=t.mix,this.softness=t.softness,this.bendDirection=t.bendDirection,this.compress=t.compress,this.stretch=t.stretch}update(t){if(0==this.mix)return;let e=this.target,s=this.bones;switch(s.length){case 1:this.apply1(s[0],e.worldX,e.worldY,this.compress,this.stretch,this.data.uniform,this.mix);break;case 2:this.apply2(s[0],s[1],e.worldX,e.worldY,this.bendDirection,this.stretch,this.data.uniform,this.softness,this.mix)}}apply1(e,s,i,a,r,n,l){let o=e.parent;if(!o)throw Error("IK bone must have parent.");let h=o.a,d=o.b,c=o.c,u=o.d,f=-e.ashearX-e.arotation,m=0,g=0;switch(e.inherit){case t.Inherit.OnlyTranslation:m=(s-e.worldX)*w.signum(e.skeleton.scaleX),g=(i-e.worldY)*w.signum(e.skeleton.scaleY);break;case t.Inherit.NoRotationOrReflection:let p=Math.abs(h*u-d*c)/Math.max(1e-4,h*h+c*c),x=h/e.skeleton.scaleX,b=c/e.skeleton.scaleY;d=-b*p*e.skeleton.scaleX,u=x*p*e.skeleton.scaleY,f+=Math.atan2(b,x)*w.radDeg;default:let y=s-o.worldX,M=i-o.worldY,S=h*u-d*c;1e-4>=Math.abs(S)?(m=0,g=0):(m=(y*u-M*d)/S-e.ax,g=(M*h-y*c)/S-e.ay)}f+=Math.atan2(g,m)*w.radDeg,e.ascaleX<0&&(f+=180),f>180?f-=360:f<-180&&(f+=360);let k=e.ascaleX,I=e.ascaleY;if(a||r){switch(e.inherit){case t.Inherit.NoScale:case t.Inherit.NoScaleOrReflection:m=s-e.worldX,g=i-e.worldY}let o=e.data.length*k;if(o>1e-4){let t=m*m+g*g;if(a&&t<o*o||r&&t>o*o){let e=(Math.sqrt(t)/o-1)*l+1;k*=e,n&&(I*=e)}}}e.updateWorldTransformWith(e.ax,e.ay,e.arotation+f*l,k,I,e.ashearX,e.ashearY)}apply2(e,s,i,a,r,n,l,o,h){if(e.inherit!=t.Inherit.Normal||s.inherit!=t.Inherit.Normal)return;let d=e.ax,c=e.ay,u=e.ascaleX,f=e.ascaleY,m=u,g=f,p=s.ascaleX,x=0,b=0,y=0;u<0?(u=-u,x=180,y=-1):(x=0,y=1),f<0&&(f=-f,y=-y),p<0?(p=-p,b=180):b=0;let M=s.ax,S=0,k=0,I=0,v=e.a,T=e.b,B=e.c,A=e.d,F=1e-4>=Math.abs(u-f);!F||n?(S=0,k=v*M+e.worldX,I=B*M+e.worldY):(k=v*M+T*(S=s.ay)+e.worldX,I=B*M+A*S+e.worldY);let C=e.parent;if(!C)throw Error("IK parent must itself have a parent.");v=C.a,T=C.b,B=C.c;let E=v*(A=C.d)-T*B,R=k-C.worldX,Y=I-C.worldY,P=(R*A-Y*T)*(E=1e-4>=Math.abs(E)?0:1/E)-d,X=(Y*v-R*B)*E-c,_=Math.sqrt(P*P+X*X),V=s.data.length*p,D,O;if(_<1e-4){this.apply1(e,i,a,!1,n,!1,h),s.updateWorldTransformWith(M,S,0,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY);return}let N=((R=i-C.worldX)*A-(Y=a-C.worldY)*T)*E-d,L=(Y*v-R*B)*E-c,q=N*N+L*L;if(0!=o){o*=u*(p+1)*.5;let t=Math.sqrt(q),e=t-_-V*u+o;if(e>0){let s=Math.min(1,e/(2*o))-1;s=(e-o*(1-s*s))/t,N-=s*N,L-=s*L,q=N*N+L*L}}t:if(F){let t=(q-_*_-(V*=u)*V)/(2*_*V);t<-1?(t=-1,O=Math.PI*r):t>1?(t=1,O=0,n&&(m*=v=(Math.sqrt(q)/(_+V)-1)*h+1,l&&(g*=v))):O=Math.acos(t)*r,D=Math.atan2(L*(v=_+V*t)-N*(T=V*Math.sin(O)),N*v+L*T)}else{let t=(v=u*V)*v,e=(T=f*V)*T,s=Math.atan2(L,N);B=e*_*_+t*q-t*e;let i=-2*e*_,a=e-t;if((A=i*i-4*a*B)>=0){let t=Math.sqrt(A);i<0&&(t=-t);let e=(t=-(.5*(i+t)))/a,n=B/t,l=Math.abs(e)<Math.abs(n)?e:n;if((e=q-l*l)>=0){D=s-Math.atan2(Y=Math.sqrt(e)*r,l),O=Math.atan2(Y/f,(l-_)/u);break t}}let n=w.PI,l=_-v,o=l*l,h=0,d=0,c=_+v,m=c*c,g=0;(B=-v*_/(t-e))>=-1&&B<=1&&((A=(R=v*Math.cos(B=Math.acos(B))+_)*R+(Y=T*Math.sin(B))*Y)<o&&(n=B,o=A,l=R,h=Y),A>m&&(d=B,m=A,c=R,g=Y)),q<=(o+m)*.5?(D=s-Math.atan2(h*r,l),O=n*r):(D=s-Math.atan2(g*r,c),O=d*r)}let U=Math.atan2(S,M)*y,W=e.arotation;(D=(D-U)*w.radDeg+x-W)>180?D-=360:D<-180&&(D+=360),e.updateWorldTransformWith(d,c,W+D*h,m,g,0,0),W=s.arotation,(O=((O+U)*w.radDeg-s.ashearX)*y+b-W)>180?O-=360:O<-180&&(O+=360),s.updateWorldTransformWith(M,S,W+O*h,s.ascaleX,s.ascaleY,s.ashearX,s.ashearY)}}class tj extends tU{bones=[];_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw Error("BoneData not set.")}bendDirection=0;compress=!1;stretch=!1;uniform=!1;mix=0;softness=0;constructor(t){super(t,0,!1)}}class tH extends tU{bones=[];_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw Error("SlotData not set.")}positionMode=t.PositionMode.Fixed;spacingMode=t.SpacingMode.Fixed;rotateMode=t.RotateMode.Chain;offsetRotation=0;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;constructor(t){super(t,0,!1)}}t.PositionMode=void 0,(c=t.PositionMode||(t.PositionMode={}))[c.Fixed=0]="Fixed",c[c.Percent=1]="Percent",t.SpacingMode=void 0,(u=t.SpacingMode||(t.SpacingMode={}))[u.Length=0]="Length",u[u.Fixed=1]="Fixed",u[u.Percent=2]="Percent",u[u.Proportional=3]="Proportional",t.RotateMode=void 0,(f=t.RotateMode||(t.RotateMode={}))[f.Tangent=0]="Tangent",f[f.Chain=1]="Chain",f[f.ChainScale=2]="ChainScale";class tJ{static NONE=-1;static BEFORE=-2;static AFTER=-3;static epsilon=1e-5;data;bones;target;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;spaces=[];positions=[];world=[];curves=[];lengths=[];segments=[];active=!1;constructor(t,e){if(!t)throw Error("data cannot be null.");if(!e)throw Error("skeleton cannot be null.");this.data=t,this.bones=[];for(let s=0,i=t.bones.length;s<i;s++){let i=e.findBone(t.bones[s].name);if(!i)throw Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findSlot(t.target.name);if(!s)throw Error(`Couldn't find target bone ${t.target.name}`);this.target=s,this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}isActive(){return this.active}setToSetupPose(){let t=this.data;this.position=t.position,this.spacing=t.spacing,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY}update(e){let s=this.target.getAttachment();if(!(s instanceof tV))return;let i=this.mixRotate,a=this.mixX,r=this.mixY;if(0==i&&0==a&&0==r)return;let n=this.data,l=n.rotateMode==t.RotateMode.Tangent,o=n.rotateMode==t.RotateMode.ChainScale,h=this.bones,d=h.length,c=l?d:d+1,u=k.setArraySize(this.spaces,c),f=o?this.lengths=k.setArraySize(this.lengths,d):[],m=this.spacing;switch(n.spacingMode){case t.SpacingMode.Percent:if(o)for(let t=0,e=c-1;t<e;t++){let e=h[t],s=e.data.length,i=s*e.a,a=s*e.c;f[t]=Math.sqrt(i*i+a*a)}k.arrayFill(u,1,c,m);break;case t.SpacingMode.Proportional:let g=0;for(let t=0,e=c-1;t<e;){let e=h[t],s=e.data.length;if(s<tJ.epsilon)o&&(f[t]=0),u[++t]=m;else{let i=s*e.a,a=s*e.c,r=Math.sqrt(i*i+a*a);o&&(f[t]=r),u[++t]=r,g+=r}}if(g>0){g=c/g*m;for(let t=1;t<c;t++)u[t]*=g}break;default:let p=n.spacingMode==t.SpacingMode.Length;for(let t=0,e=c-1;t<e;){let e=h[t],s=e.data.length;if(s<tJ.epsilon)o&&(f[t]=0),u[++t]=m;else{let i=s*e.a,a=s*e.c,r=Math.sqrt(i*i+a*a);o&&(f[t]=r),u[++t]=(p?s+m:m)*r/s}}}let x=this.computeWorldPositions(s,c,l),b=x[0],y=x[1],M=n.offsetRotation,S=!1;if(0==M)S=n.rotateMode==t.RotateMode.Chain;else{S=!1;let t=this.target.bone;M*=t.a*t.d-t.b*t.c>0?w.degRad:-w.degRad}for(let t=0,e=3;t<d;t++,e+=3){let s=h[t];s.worldX+=(b-s.worldX)*a,s.worldY+=(y-s.worldY)*r;let n=x[e],d=x[e+1],c=n-b,m=d-y;if(o){let e=f[t];if(0!=e){let t=(Math.sqrt(c*c+m*m)/e-1)*i+1;s.a*=t,s.c*=t}}if(b=n,y=d,i>0){let a=s.a,r=s.b,n=s.c,o=s.d,h=0,d=0,f=0;if(h=(l?x[e-1]:0==u[t+1]?x[e+2]:Math.atan2(m,c))-Math.atan2(n,a),S){d=Math.cos(h),f=Math.sin(h);let t=s.data.length;b+=(t*(d*a-f*n)-c)*i,y+=(t*(f*a+d*n)-m)*i}else h+=M;h>w.PI?h-=w.PI2:h<-w.PI&&(h+=w.PI2),h*=i,d=Math.cos(h),f=Math.sin(h),s.a=d*a-f*n,s.b=d*r-f*o,s.c=f*a+d*n,s.d=f*r+d*o}s.updateAppliedTransform()}}computeWorldPositions(e,s,i){let a,r=this.target,n=this.position,l=this.spaces,o=k.setArraySize(this.positions,3*s+2),h=this.world,d=e.closed,c=e.worldVerticesLength,u=c/6,f=tJ.NONE;if(!e.constantSpeed){let a,m=e.lengths,g=m[u-=d?1:2];switch(this.data.positionMode==t.PositionMode.Percent&&(n*=g),this.data.spacingMode){case t.SpacingMode.Percent:a=g;break;case t.SpacingMode.Proportional:a=g/s;break;default:a=1}h=k.setArraySize(this.world,8);for(let t=0,p=0,x=0;t<s;t++,p+=3){let s=l[t]*a,b=n+=s;if(d)(b%=g)<0&&(b+=g),x=0;else if(b<0){f!=tJ.BEFORE&&(f=tJ.BEFORE,e.computeWorldVertices(r,2,4,h,0,2)),this.addBeforePosition(b,h,0,o,p);continue}else if(b>g){f!=tJ.AFTER&&(f=tJ.AFTER,e.computeWorldVertices(r,c-6,4,h,0,2)),this.addAfterPosition(b-g,h,0,o,p);continue}for(;;x++){let t=m[x];if(!(b>t)){if(0==x)b/=t;else{let e=m[x-1];b=(b-e)/(t-e)}break}}x!=f&&(f=x,d&&x==u?(e.computeWorldVertices(r,c-4,4,h,0,2),e.computeWorldVertices(r,0,4,h,4,2)):e.computeWorldVertices(r,6*x+2,8,h,0,2)),this.addCurvePosition(b,h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],o,p,i||t>0&&0==s)}return o}d?(c+=2,h=k.setArraySize(this.world,c),e.computeWorldVertices(r,2,c-4,h,0,2),e.computeWorldVertices(r,0,2,h,c-4,2),h[c-2]=h[0],h[c-1]=h[1]):(u--,c-=4,h=k.setArraySize(this.world,c),e.computeWorldVertices(r,2,c,h,0,2));let m=k.setArraySize(this.curves,u),g=0,p=h[0],x=h[1],b=0,y=0,w=0,M=0,S=0,I=0,v=0,T=0,B=0,A=0,F=0,C=0,E=0,R=0;for(let t=0,e=2;t<u;t++,e+=6)b=h[e],y=h[e+1],w=h[e+2],M=h[e+3],S=h[e+4],I=h[e+5],v=(p-2*b+w)*.1875,T=(x-2*y+M)*.1875,B=((b-w)*3-p+S)*.09375,A=((y-M)*3-x+I)*.09375,F=2*v+B,C=2*T+A,g+=Math.sqrt((E=(b-p)*.75+v+.16666667*B)*E+(R=(y-x)*.75+T+.16666667*A)*R),E+=F,R+=C,F+=B,C+=A,g+=Math.sqrt(E*E+R*R),E+=F,R+=C,g+=Math.sqrt(E*E+R*R),E+=F+B,R+=C+A,g+=Math.sqrt(E*E+R*R),m[t]=g,p=S,x=I;switch(this.data.positionMode==t.PositionMode.Percent&&(n*=g),this.data.spacingMode){case t.SpacingMode.Percent:a=g;break;case t.SpacingMode.Proportional:a=g/s;break;default:a=1}let Y=this.segments,P=0;for(let t=0,e=0,r=0,u=0;t<s;t++,e+=3){let s=l[t]*a,k=n+=s;if(d)(k%=g)<0&&(k+=g),r=0;else if(k<0){this.addBeforePosition(k,h,0,o,e);continue}else if(k>g){this.addAfterPosition(k-g,h,c-4,o,e);continue}for(;;r++){let t=m[r];if(!(k>t)){if(0==r)k/=t;else{let e=m[r-1];k=(k-e)/(t-e)}break}}if(r!=f){f=r;let t=6*r;for(p=h[t],x=h[t+1],b=h[t+2],y=h[t+3],w=h[t+4],M=h[t+5],S=h[t+6],I=h[t+7],v=(p-2*b+w)*.03,T=(x-2*y+M)*.03,B=((b-w)*3-p+S)*.006,A=((y-M)*3-x+I)*.006,F=2*v+B,C=2*T+A,P=Math.sqrt((E=(b-p)*.3+v+.16666667*B)*E+(R=(y-x)*.3+T+.16666667*A)*R),Y[0]=P,t=1;t<8;t++)E+=F,R+=C,F+=B,C+=A,P+=Math.sqrt(E*E+R*R),Y[t]=P;E+=F,R+=C,P+=Math.sqrt(E*E+R*R),Y[8]=P,E+=F+B,R+=C+A,P+=Math.sqrt(E*E+R*R),Y[9]=P,u=0}for(k*=P;;u++){let t=Y[u];if(!(k>t)){if(0==u)k/=t;else{let e=Y[u-1];k=u+(k-e)/(t-e)}break}}this.addCurvePosition(.1*k,p,x,b,y,w,M,S,I,o,e,i||t>0&&0==s)}return o}addBeforePosition(t,e,s,i,a){let r=e[s],n=e[s+1],l=e[s+2]-r,o=Math.atan2(e[s+3]-n,l);i[a]=r+t*Math.cos(o),i[a+1]=n+t*Math.sin(o),i[a+2]=o}addAfterPosition(t,e,s,i,a){let r=e[s+2],n=e[s+3],l=r-e[s],o=Math.atan2(n-e[s+1],l);i[a]=r+t*Math.cos(o),i[a+1]=n+t*Math.sin(o),i[a+2]=o}addCurvePosition(t,e,s,i,a,r,n,l,o,h,d,c){if(0==t||isNaN(t)){h[d]=e,h[d+1]=s,h[d+2]=Math.atan2(a-s,i-e);return}let u=t*t,f=u*t,m=1-t,g=m*m,p=g*m,x=m*t,b=3*x,y=m*b,w=b*t,M=e*p+i*y+r*w+l*f,S=s*p+a*y+n*w+o*f;h[d]=M,h[d+1]=S,c&&(t<.001?h[d+2]=Math.atan2(a-s,i-e):h[d+2]=Math.atan2(S-(s*g+a*x*2+n*u),M-(e*g+i*x*2+r*u)))}}class tK{data;_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw Error("Bone not set.")}inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xVelocity=0;yOffset=0;yVelocity=0;rotateOffset=0;rotateVelocity=0;scaleOffset=0;scaleVelocity=0;active=!1;skeleton;remaining=0;lastTime=0;constructor(t,e){this.data=t,this.skeleton=e,this.bone=e.bones[t.bone.index],this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}reset(){this.remaining=0,this.lastTime=this.skeleton.time,this._reset=!0,this.xOffset=0,this.xVelocity=0,this.yOffset=0,this.yVelocity=0,this.rotateOffset=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleVelocity=0}setToSetupPose(){let t=this.data;this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}isActive(){return this.active}update(e){let s=this.mix;if(0==s)return;let i=this.data.x>0,a=this.data.y>0,r=this.data.rotate>0||this.data.shearX>0,n=this.data.scaleX>0,l=this.bone,o=l.data.length;switch(e){case t.Physics.none:return;case t.Physics.reset:this.reset();case t.Physics.update:let h=this.skeleton,d=Math.max(this.skeleton.time-this.lastTime,0);this.remaining+=d,this.lastTime=h.time;let c=l.worldX,u=l.worldY;if(this._reset)this._reset=!1,this.ux=c,this.uy=u;else{let t=this.remaining,e=this.inertia,f=this.data.step,m=this.skeleton.data.referenceScale,g=-1,p=this.data.limit*d,x=p*Math.abs(h.scaleY);if(p*=Math.abs(h.scaleX),i||a){if(i){let t=(this.ux-c)*e;this.xOffset+=t>p?p:t<-p?-p:t,this.ux=c}if(a){let t=(this.uy-u)*e;this.yOffset+=t>x?x:t<-x?-x:t,this.uy=u}if(t>=f){g=Math.pow(this.damping,60*f);let e=this.massInverse*f,s=this.strength,r=this.wind*m,n=(t0.yDown?-this.gravity:this.gravity)*m;do i&&(this.xVelocity+=(r-this.xOffset*s)*e,this.xOffset+=this.xVelocity*f,this.xVelocity*=g),a&&(this.yVelocity-=(n+this.yOffset*s)*e,this.yOffset+=this.yVelocity*f,this.yVelocity*=g),t-=f;while(t>=f)}i&&(l.worldX+=this.xOffset*s*this.data.x),a&&(l.worldY+=this.yOffset*s*this.data.y)}if(r||n){let i=Math.atan2(l.c,l.a),a=0,h=0,d=0,c=this.cx-l.worldX,u=this.cy-l.worldY;if(c>p?c=p:c<-p&&(c=-p),u>x?u=x:u<-x&&(u=-x),r){d=(this.data.rotate+this.data.shearX)*s;let t=Math.atan2(u+this.ty,c+this.tx)-i-this.rotateOffset*d;this.rotateOffset+=(t-Math.ceil(t*w.invPI2-.5)*w.PI2)*e,a=Math.cos(t=this.rotateOffset*d+i),h=Math.sin(t),n&&(t=o*l.getWorldScaleX())>0&&(this.scaleOffset+=(c*a+u*h)*e/t)}else{a=Math.cos(i),h=Math.sin(i);let t=o*l.getWorldScaleX();t>0&&(this.scaleOffset+=(c*a+u*h)*e/t)}if((t=this.remaining)>=f){-1==g&&(g=Math.pow(this.damping,60*f));let e=this.massInverse*f,s=this.strength,l=this.wind,c=t0.yDown?-this.gravity:this.gravity,u=o/m;for(;;)if(t-=f,n&&(this.scaleVelocity+=(l*a-c*h-this.scaleOffset*s)*e,this.scaleOffset+=this.scaleVelocity*f,this.scaleVelocity*=g),r){if(this.rotateVelocity-=((l*h+c*a)*u+this.rotateOffset*s)*e,this.rotateOffset+=this.rotateVelocity*f,this.rotateVelocity*=g,t<f)break;let r=this.rotateOffset*d+i;a=Math.cos(r),h=Math.sin(r)}else if(t<f)break}}this.remaining=t}this.cx=l.worldX,this.cy=l.worldY;break;case t.Physics.pose:i&&(l.worldX+=this.xOffset*s*this.data.x),a&&(l.worldY+=this.yOffset*s*this.data.y)}if(r){let t=this.rotateOffset*s,e=0,i=0,a=0;if(this.data.shearX>0){let s=0;this.data.rotate>0&&(e=Math.sin(s=t*this.data.rotate),i=Math.cos(s),a=l.b,l.b=i*a-e*l.d,l.d=e*a+i*l.d),s+=t*this.data.shearX,e=Math.sin(s),i=Math.cos(s),a=l.a,l.a=i*a-e*l.c,l.c=e*a+i*l.c}else t*=this.data.rotate,e=Math.sin(t),i=Math.cos(t),a=l.a,l.a=i*a-e*l.c,l.c=e*a+i*l.c,a=l.b,l.b=i*a-e*l.d,l.d=e*a+i*l.d}if(n){let t=1+this.scaleOffset*s*this.data.scaleX;l.a*=t,l.c*=t}e!=t.Physics.pose&&(this.tx=o*l.a,this.ty=o*l.c),l.updateAppliedTransform()}translate(t,e){this.ux-=t,this.uy-=e,this.cx-=t,this.cy-=e}rotate(t,e,s){let i=s*w.degRad,a=Math.cos(i),r=Math.sin(i),n=this.cx-t,l=this.cy-e;this.translate(n*a-l*r-n,n*r+l*a-l)}}class tQ{data;bone;color;darkColor=null;attachment=null;attachmentState=0;sequenceIndex=-1;deform=[];constructor(t,e){if(!t)throw Error("data cannot be null.");if(!e)throw Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new y,this.darkColor=t.darkColor?new y:null,this.setToSetupPose()}getSkeleton(){return this.bone.skeleton}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(t instanceof A&&this.attachment instanceof A&&t.timelineAttachment==this.attachment.timelineAttachment||(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}setToSetupPose(){this.color.setFromColor(this.data.color),this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),this.data.attachmentName?(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.attachment=null}}class tZ{data;bones;target;mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;temp=new v;active=!1;constructor(t,e){if(!t)throw Error("data cannot be null.");if(!e)throw Error("skeleton cannot be null.");this.data=t,this.bones=[];for(let s=0;s<t.bones.length;s++){let i=e.findBone(t.bones[s].name);if(!i)throw Error(`Couldn't find bone ${t.bones[s].name}.`);this.bones.push(i)}let s=e.findBone(t.target.name);if(!s)throw Error(`Couldn't find target bone ${t.target.name}.`);this.target=s,this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}isActive(){return this.active}setToSetupPose(){let t=this.data;this.mixRotate=t.mixRotate,this.mixX=t.mixX,this.mixY=t.mixY,this.mixScaleX=t.mixScaleX,this.mixScaleY=t.mixScaleY,this.mixShearY=t.mixShearY}update(t){(0!=this.mixRotate||0!=this.mixX||0!=this.mixY||0!=this.mixScaleX||0!=this.mixScaleY||0!=this.mixShearY)&&(this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld())}applyAbsoluteWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,a=this.mixScaleY,r=this.mixShearY,n=0!=e||0!=s,l=this.target,o=l.a,h=l.b,d=l.c,c=l.d,u=o*c-h*d>0?w.degRad:-w.degRad,f=this.data.offsetRotation*u,m=this.data.offsetShearY*u,g=this.bones;for(let u=0,p=g.length;u<p;u++){let p=g[u];if(0!=t){let e=p.a,s=p.b,i=p.c,a=p.d,r=Math.atan2(d,o)-Math.atan2(i,e)+f;r>w.PI?r-=w.PI2:r<-w.PI&&(r+=w.PI2);let n=Math.cos(r*=t),l=Math.sin(r);p.a=n*e-l*i,p.b=n*s-l*a,p.c=l*e+n*i,p.d=l*s+n*a}if(n){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(t.x-p.worldX)*e,p.worldY+=(t.y-p.worldY)*s}if(0!=i){let t=Math.sqrt(p.a*p.a+p.c*p.c);0!=t&&(t=(t+(Math.sqrt(o*o+d*d)-t+this.data.offsetScaleX)*i)/t),p.a*=t,p.c*=t}if(0!=a){let t=Math.sqrt(p.b*p.b+p.d*p.d);0!=t&&(t=(t+(Math.sqrt(h*h+c*c)-t+this.data.offsetScaleY)*a)/t),p.b*=t,p.d*=t}if(r>0){let t=p.b,e=p.d,s=Math.atan2(e,t),i=Math.atan2(c,h)-Math.atan2(d,o)-(s-Math.atan2(p.c,p.a));i>w.PI?i-=w.PI2:i<-w.PI&&(i+=w.PI2),i=s+(i+m)*r;let a=Math.sqrt(t*t+e*e);p.b=Math.cos(i)*a,p.d=Math.sin(i)*a}p.updateAppliedTransform()}}applyRelativeWorld(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,a=this.mixScaleY,r=this.mixShearY,n=0!=e||0!=s,l=this.target,o=l.a,h=l.b,d=l.c,c=l.d,u=o*c-h*d>0?w.degRad:-w.degRad,f=this.data.offsetRotation*u,m=this.data.offsetShearY*u,g=this.bones;for(let u=0,p=g.length;u<p;u++){let p=g[u];if(0!=t){let e=p.a,s=p.b,i=p.c,a=p.d,r=Math.atan2(d,o)+f;r>w.PI?r-=w.PI2:r<-w.PI&&(r+=w.PI2);let n=Math.cos(r*=t),l=Math.sin(r);p.a=n*e-l*i,p.b=n*s-l*a,p.c=l*e+n*i,p.d=l*s+n*a}if(n){let t=this.temp;l.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=t.x*e,p.worldY+=t.y*s}if(0!=i){let t=(Math.sqrt(o*o+d*d)-1+this.data.offsetScaleX)*i+1;p.a*=t,p.c*=t}if(0!=a){let t=(Math.sqrt(h*h+c*c)-1+this.data.offsetScaleY)*a+1;p.b*=t,p.d*=t}if(r>0){let t=Math.atan2(c,h)-Math.atan2(d,o);t>w.PI?t-=w.PI2:t<-w.PI&&(t+=w.PI2);let e=p.b,s=p.d;t=Math.atan2(s,e)+(t-w.PI/2+m)*r;let i=Math.sqrt(e*e+s*s);p.b=Math.cos(t)*i,p.d=Math.sin(t)*i}p.updateAppliedTransform()}}applyAbsoluteLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,a=this.mixScaleY,r=this.mixShearY,n=this.target,l=this.bones;for(let o=0,h=l.length;o<h;o++){let h=l[o],d=h.arotation;0!=t&&(d+=(n.arotation-d+this.data.offsetRotation)*t);let c=h.ax,u=h.ay;c+=(n.ax-c+this.data.offsetX)*e,u+=(n.ay-u+this.data.offsetY)*s;let f=h.ascaleX,m=h.ascaleY;0!=i&&0!=f&&(f=(f+(n.ascaleX-f+this.data.offsetScaleX)*i)/f),0!=a&&0!=m&&(m=(m+(n.ascaleY-m+this.data.offsetScaleY)*a)/m);let g=h.ashearY;0!=r&&(g+=(n.ashearY-g+this.data.offsetShearY)*r),h.updateWorldTransformWith(c,u,d,f,m,h.ashearX,g)}}applyRelativeLocal(){let t=this.mixRotate,e=this.mixX,s=this.mixY,i=this.mixScaleX,a=this.mixScaleY,r=this.mixShearY,n=this.target,l=this.bones;for(let o=0,h=l.length;o<h;o++){let h=l[o],d=h.arotation+(n.arotation+this.data.offsetRotation)*t,c=h.ax+(n.ax+this.data.offsetX)*e,u=h.ay+(n.ay+this.data.offsetY)*s,f=h.ascaleX*((n.ascaleX-1+this.data.offsetScaleX)*i+1),m=h.ascaleY*((n.ascaleY-1+this.data.offsetScaleY)*a+1),g=h.ashearY+(n.ashearY+this.data.offsetShearY)*r;h.updateWorldTransformWith(c,u,d,f,m,h.ashearX,g)}}}class t0{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;data;bones;slots;drawOrder;ikConstraints;transformConstraints;pathConstraints;physicsConstraints;_updateCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return t0.yDown?-this._scaleY:this._scaleY}set scaleY(t){this._scaleY=t}x=0;y=0;time=0;constructor(t){if(!t)throw Error("data cannot be null.");this.data=t,this.bones=[];for(let e=0;e<t.bones.length;e++){let s,i=t.bones[e];if(i.parent){let t=this.bones[i.parent.index];s=new tq(i,this,t),t.children.push(s)}else s=new tq(i,this,null);this.bones.push(s)}this.slots=[],this.drawOrder=[];for(let e=0;e<t.slots.length;e++){let s=t.slots[e],i=this.bones[s.boneData.index],a=new tQ(s,i);this.slots.push(a),this.drawOrder.push(a)}this.ikConstraints=[];for(let e=0;e<t.ikConstraints.length;e++){let s=t.ikConstraints[e];this.ikConstraints.push(new t$(s,this))}this.transformConstraints=[];for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new tZ(s,this))}this.pathConstraints=[];for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new tJ(s,this))}this.physicsConstraints=[];for(let e=0;e<t.physicsConstraints.length;e++){let s=t.physicsConstraints[e];this.physicsConstraints.push(new tK(s,this))}this.color=new y(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.sorted=s.data.skinRequired,s.active=!s.sorted}if(this.skin){let t=this.skin.bones;for(let e=0,s=this.skin.bones.length;e<s;e++){let s=this.bones[t[e].index];do s.sorted=!1,s.active=!0,s=s.parent;while(s)}}let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,a=this.physicsConstraints,r=e.length,n=s.length,l=i.length,o=this.physicsConstraints.length,h=r+n+l+o;t:for(let t=0;t<h;t++){for(let s=0;s<r;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<n;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<l;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}for(let e=0;e<o;e++){let s=a[e];if(s.data.order==t){this.sortPhysicsConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&k.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),1==s.length)this._updateCache.push(t),this.sortReset(i.children);else{let e=s[s.length-1];this.sortBone(e),this._updateCache.push(t),this.sortReset(i.children),e.sorted=!0}}sortPathConstraint(t){if(t.active=t.target.bone.isActive()&&(!t.data.skinRequired||this.skin&&k.contains(this.skin.constraints,t.data,!0)),!t.active)return;let e=t.target,s=e.data.index,i=e.bone;this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,s,i);for(let t=0,e=this.data.skins.length;t<e;t++)this.sortPathConstraintAttachment(this.data.skins[t],s,i);let a=e.getAttachment();a instanceof tV&&this.sortPathConstraintAttachmentWith(a,i);let r=t.bones,n=r.length;for(let t=0;t<n;t++)this.sortBone(r[t]);this._updateCache.push(t);for(let t=0;t<n;t++)this.sortReset(r[t].children);for(let t=0;t<n;t++)r[t].sorted=!0}sortTransformConstraint(t){if(t.active=t.target.isActive()&&(!t.data.skinRequired||this.skin&&k.contains(this.skin.constraints,t.data,!0)),!t.active)return;this.sortBone(t.target);let e=t.bones,s=e.length;if(t.data.local)for(let t=0;t<s;t++){let s=e[t];this.sortBone(s.parent),this.sortBone(s)}else for(let t=0;t<s;t++)this.sortBone(e[t]);this._updateCache.push(t);for(let t=0;t<s;t++)this.sortReset(e[t].children);for(let t=0;t<s;t++)e[t].sorted=!0}sortPathConstraintAttachment(t,e,s){let i=t.attachments[e];if(i)for(let t in i)this.sortPathConstraintAttachmentWith(i[t],s)}sortPathConstraintAttachmentWith(t,e){if(!(t instanceof tV))return;let s=t.bones;if(s){let t=this.bones;for(let e=0,i=s.length;e<i;){let i=s[e++];for(i+=e;e<i;)this.sortBone(t[s[e++]])}}else this.sortBone(e)}sortPhysicsConstraint(t){let e=t.bone;t.active=e.active&&(!t.data.skinRequired||null!=this.skin&&k.contains(this.skin.constraints,t.data,!0)),t.active&&(this.sortBone(e),this._updateCache.push(t),this.sortReset(e.children),e.sorted=!0)}sortBone(t){if(!t||t.sorted)return;let e=t.parent;e&&this.sortBone(e),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let e=0,s=t.length;e<s;e++){let s=t[e];s.active&&(s.sorted&&this.sortReset(s.children),s.sorted=!1)}}updateWorldTransform(t){if(null==t)throw Error("physics is undefined");let e=this.bones;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.ax=s.x,s.ay=s.y,s.arotation=s.rotation,s.ascaleX=s.scaleX,s.ascaleY=s.scaleY,s.ashearX=s.shearX,s.ashearY=s.shearY}let s=this._updateCache;for(let e=0,i=s.length;e<i;e++)s[e].update(t)}updateWorldTransformWith(t,e){let s=this.getRootBone();if(!s)throw Error("Root bone must not be null.");let i=e.a,a=e.b,r=e.c,n=e.d;s.worldX=i*this.x+a*this.y+e.worldX,s.worldY=r*this.x+n*this.y+e.worldY;let l=(s.rotation+s.shearX)*w.degRad,o=(s.rotation+90+s.shearY)*w.degRad,h=Math.cos(l)*s.scaleX,d=Math.cos(o)*s.scaleY,c=Math.sin(l)*s.scaleX,u=Math.sin(o)*s.scaleY;s.a=(i*h+a*c)*this.scaleX,s.b=(i*d+a*u)*this.scaleX,s.c=(r*h+n*c)*this.scaleY,s.d=(r*d+n*u)*this.scaleY;let f=this._updateCache;for(let e=0,i=f.length;e<i;e++){let i=f[e];i!=s&&i.update(t)}}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){for(let t of this.bones)t.setToSetupPose();for(let t of this.ikConstraints)t.setToSetupPose();for(let t of this.transformConstraints)t.setToSetupPose();for(let t of this.pathConstraints)t.setToSetupPose();for(let t of this.physicsConstraints)t.setToSetupPose()}setSlotsToSetupPose(){let t=this.slots;k.arrayCopy(t,0,this.drawOrder,0,t.length);for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose()}getRootBone(){return 0==this.bones.length?null:this.bones[0]}findBone(t){if(!t)throw Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}findSlot(t){if(!t)throw Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.data.name==t)return i}return null}setSkinByName(t){let e=this.data.findSkin(t);if(!e)throw Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(t!=this.skin){if(t){if(this.skin)t.attachAll(this,this.skin);else{let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s],a=i.data.attachmentName;if(a){let e=t.getAttachment(s,a);e&&i.setAttachment(e)}}}}this.skin=t,this.updateCache()}}getAttachmentByName(t,e){let s=this.data.findSlot(t);if(!s)throw Error(`Can't find slot with name ${t}`);return this.getAttachment(s.index,e)}getAttachment(t,e){if(!e)throw Error("attachmentName cannot be null.");if(this.skin){let s=this.skin.getAttachment(t,e);if(s)return s}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(!t)throw Error("slotName cannot be null.");let s=this.slots;for(let i=0,a=s.length;i<a;i++){let a=s[i];if(a.data.name==t){let s=null;if(e&&!(s=this.getAttachment(i,e)))throw Error("Attachment not found: "+e+", for slot: "+t);a.setAttachment(s);return}}throw Error("Slot not found: "+t)}findIkConstraint(t){if(!t)throw Error("constraintName cannot be null.");return this.ikConstraints.find(e=>e.data.name==t)??null}findTransformConstraint(t){if(!t)throw Error("constraintName cannot be null.");return this.transformConstraints.find(e=>e.data.name==t)??null}findPathConstraint(t){if(!t)throw Error("constraintName cannot be null.");return this.pathConstraints.find(e=>e.data.name==t)??null}findPhysicsConstraint(t){if(null==t)throw Error("constraintName cannot be null.");return this.physicsConstraints.find(e=>e.data.name==t)??null}getBoundsRect(){let t=new v,e=new v;return this.getBounds(t,e),{x:t.x,y:t.y,width:e.x,height:e.y}}getBounds(t,e,s=[,,],i=null){if(!t)throw Error("offset cannot be null.");if(!e)throw Error("size cannot be null.");let a=this.drawOrder,r=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let t=0,e=a.length;t<e;t++){let e=a[t];if(!e.bone.active)continue;let h=0,d=null,c=null,u=e.getAttachment();if(u instanceof tO)h=8,d=k.setArraySize(s,h,0),u.computeWorldVertices(e,d,0,2),c=t0.quadTriangles;else if(u instanceof t_)h=u.worldVerticesLength,d=k.setArraySize(s,h,0),u.computeWorldVertices(e,0,h,d,0,2),c=u.triangles;else if(u instanceof tF&&null!=i){i.clipStart(e,u);continue}if(d&&c){null!=i&&i.isClipping()&&(i.clipTriangles(d,c,c.length),d=i.clippedVertices,h=i.clippedVertices.length);for(let t=0,e=d.length;t<e;t+=2){let e=d[t],s=d[t+1];r=Math.min(r,e),n=Math.min(n,s),l=Math.max(l,e),o=Math.max(o,s)}}null!=i&&i.clipEndWithSlot(e)}null!=i&&i.clipEnd(),t.set(r,n),e.set(l-r,o-n)}update(t){this.time+=t}physicsTranslate(t,e){let s=this.physicsConstraints;for(let i=0,a=s.length;i<a;i++)s[i].translate(t,e)}physicsRotate(t,e,s){let i=this.physicsConstraints;for(let a=0,r=i.length;a<r;a++)i[a].rotate(t,e,s)}}t.Physics=void 0,(m=t.Physics||(t.Physics={}))[m.none=0]="none",m[m.reset=1]="reset",m[m.update=2]="update",m[m.pose=3]="pose";class t1 extends tU{_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw Error("BoneData not set.")}x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;constructor(t){super(t,0,!1)}}class t2{name=null;bones=[];slots=[];skins=[];defaultSkin=null;events=[];animations=[];ikConstraints=[];transformConstraints=[];pathConstraints=[];physicsConstraints=[];x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=0;imagesPath=null;audioPath=null;findBone(t){if(!t)throw Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSlot(t){if(!t)throw Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findSkin(t){if(!t)throw Error("skinName cannot be null.");let e=this.skins;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findEvent(t){if(!t)throw Error("eventDataName cannot be null.");let e=this.events;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findAnimation(t){if(!t)throw Error("animationName cannot be null.");let e=this.animations;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findIkConstraint(t){if(!t)throw Error("constraintName cannot be null.");let e=this.ikConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findTransformConstraint(t){if(!t)throw Error("constraintName cannot be null.");let e=this.transformConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findPathConstraint(t){if(!t)throw Error("constraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}findPhysicsConstraint(t){if(!t)throw Error("constraintName cannot be null.");let e=this.physicsConstraints;for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.name==t)return i}return null}}class t3{slotIndex;name;attachment;constructor(t=0,e,s){this.slotIndex=t,this.name=e,this.attachment=s}}class t5{name;attachments=[];bones=[];constraints=[];color=new y(.99607843,.61960787,.30980393,1);constructor(t){if(!t)throw Error("name cannot be null.");this.name=t}setAttachment(t,e,s){if(!s)throw Error("attachment cannot be null.");let i=this.attachments;t>=i.length&&(i.length=t+1),i[t]||(i[t]={}),i[t][e]=s}addSkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];this.setAttachment(s.slotIndex,s.name,s.attachment)}}copySkin(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e],i=!1;for(let t=0;t<this.bones.length;t++)if(this.bones[t]==s){i=!0;break}i||this.bones.push(s)}for(let e=0;e<t.constraints.length;e++){let s=t.constraints[e],i=!1;for(let t=0;t<this.constraints.length;t++)if(this.constraints[t]==s){i=!0;break}i||this.constraints.push(s)}let e=t.getAttachments();for(let t=0;t<e.length;t++){var s=e[t];s.attachment&&(s.attachment instanceof t_?s.attachment=s.attachment.newLinkedMesh():s.attachment=s.attachment.copy(),this.setAttachment(s.slotIndex,s.name,s.attachment))}}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}removeAttachment(t,e){let s=this.attachments[t];s&&delete s[e]}getAttachments(){let t=[];for(var e=0;e<this.attachments.length;e++){let s=this.attachments[e];if(s)for(let i in s){let a=s[i];a&&t.push(new t3(e,i,a))}}return t}getAttachmentsForSlot(t,e){let s=this.attachments[t];if(s)for(let i in s){let a=s[i];a&&e.push(new t3(t,i,a))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(t,e){let s=0;for(let i=0;i<t.slots.length;i++){let a=t.slots[i],r=a.getAttachment();if(r&&s<e.attachments.length){let t=e.attachments[s];for(let e in t)if(r==t[e]){let t=this.getAttachment(s,e);t&&a.setAttachment(t);break}}s++}}}class t6{index=0;name;boneData;color=new y(1,1,1,1);darkColor=null;attachmentName=null;blendMode=t.BlendMode.Normal;visible=!0;constructor(t,e,s){if(t<0)throw Error("index must be >= 0.");if(!e)throw Error("name cannot be null.");if(!s)throw Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}t.BlendMode=void 0,(g=t.BlendMode||(t.BlendMode={}))[g.Normal=0]="Normal",g[g.Additive=1]="Additive",g[g.Multiply=2]="Multiply",g[g.Screen=3]="Screen";class t8 extends tU{bones=[];_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw Error("BoneData not set.")}mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;offsetRotation=0;offsetX=0;offsetY=0;offsetScaleX=0;offsetScaleY=0;offsetShearY=0;relative=!1;local=!1;constructor(t){super(t,0,!1)}}class t4{scale=1;attachmentLoader;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new t2;i.name="";let a=new t7(e),r=a.readInt32(),n=a.readInt32();i.hash=0==n&&0==r?null:n.toString(16)+r.toString(16),i.version=a.readString(),i.x=a.readFloat(),i.y=a.readFloat(),i.width=a.readFloat(),i.height=a.readFloat(),i.referenceScale=a.readFloat()*s;let l=a.readBoolean();l&&(i.fps=a.readFloat(),i.imagesPath=a.readString(),i.audioPath=a.readString());let o=0;o=a.readInt(!0);for(let t=0;t<o;t++){let t=a.readString();if(!t)throw Error("String in string table must not be null.");a.strings.push(t)}o=a.readInt(!0);for(let t=0;t<o;t++){let e=a.readString();if(!e)throw Error("Bone name must not be null.");let r=0==t?null:i.bones[a.readInt(!0)],n=new tL(t,e,r);n.rotation=a.readFloat(),n.x=a.readFloat()*s,n.y=a.readFloat()*s,n.scaleX=a.readFloat(),n.scaleY=a.readFloat(),n.shearX=a.readFloat(),n.shearY=a.readFloat(),n.length=a.readFloat()*s,n.inherit=a.readByte(),n.skinRequired=a.readBoolean(),l&&(y.rgba8888ToColor(n.color,a.readInt32()),n.icon=a.readString()??void 0,n.visible=a.readBoolean()),i.bones.push(n)}o=a.readInt(!0);for(let t=0;t<o;t++){let e=a.readString();if(!e)throw Error("Slot name must not be null.");let s=new t6(t,e,i.bones[a.readInt(!0)]);y.rgba8888ToColor(s.color,a.readInt32());let r=a.readInt32();-1!=r&&y.rgb888ToColor(s.darkColor=new y,r),s.attachmentName=a.readStringRef(),s.blendMode=a.readInt(!0),l&&(s.visible=a.readBoolean()),i.slots.push(s)}o=a.readInt(!0);for(let t=0,e;t<o;t++){let t=a.readString();if(!t)throw Error("IK constraint data name must not be null.");let r=new tj(t);r.order=a.readInt(!0),e=a.readInt(!0);for(let t=0;t<e;t++)r.bones.push(i.bones[a.readInt(!0)]);r.target=i.bones[a.readInt(!0)];let n=a.readByte();r.skinRequired=(1&n)!=0,r.bendDirection=(2&n)!=0?1:-1,r.compress=(4&n)!=0,r.stretch=(8&n)!=0,r.uniform=(16&n)!=0,(32&n)!=0&&(r.mix=(64&n)!=0?a.readFloat():1),(128&n)!=0&&(r.softness=a.readFloat()*s),i.ikConstraints.push(r)}o=a.readInt(!0);for(let t=0,e;t<o;t++){let t=a.readString();if(!t)throw Error("Transform constraint data name must not be null.");let r=new t8(t);r.order=a.readInt(!0),e=a.readInt(!0);for(let t=0;t<e;t++)r.bones.push(i.bones[a.readInt(!0)]);r.target=i.bones[a.readInt(!0)];let n=a.readByte();r.skinRequired=(1&n)!=0,r.local=(2&n)!=0,r.relative=(4&n)!=0,(8&n)!=0&&(r.offsetRotation=a.readFloat()),(16&n)!=0&&(r.offsetX=a.readFloat()*s),(32&n)!=0&&(r.offsetY=a.readFloat()*s),(64&n)!=0&&(r.offsetScaleX=a.readFloat()),(128&n)!=0&&(r.offsetScaleY=a.readFloat()),(1&(n=a.readByte()))!=0&&(r.offsetShearY=a.readFloat()),(2&n)!=0&&(r.mixRotate=a.readFloat()),(4&n)!=0&&(r.mixX=a.readFloat()),(8&n)!=0&&(r.mixY=a.readFloat()),(16&n)!=0&&(r.mixScaleX=a.readFloat()),(32&n)!=0&&(r.mixScaleY=a.readFloat()),(64&n)!=0&&(r.mixShearY=a.readFloat()),i.transformConstraints.push(r)}o=a.readInt(!0);for(let e=0,r;e<o;e++){let e=a.readString();if(!e)throw Error("Path constraint data name must not be null.");let n=new tH(e);n.order=a.readInt(!0),n.skinRequired=a.readBoolean(),r=a.readInt(!0);for(let t=0;t<r;t++)n.bones.push(i.bones[a.readInt(!0)]);n.target=i.slots[a.readInt(!0)];let l=a.readByte();n.positionMode=1&l,n.spacingMode=l>>1&3,n.rotateMode=l>>3&3,(128&l)!=0&&(n.offsetRotation=a.readFloat()),n.position=a.readFloat(),n.positionMode==t.PositionMode.Fixed&&(n.position*=s),n.spacing=a.readFloat(),(n.spacingMode==t.SpacingMode.Length||n.spacingMode==t.SpacingMode.Fixed)&&(n.spacing*=s),n.mixRotate=a.readFloat(),n.mixX=a.readFloat(),n.mixY=a.readFloat(),i.pathConstraints.push(n)}o=a.readInt(!0);for(let t=0;t<o;t++){let t=a.readString();if(!t)throw Error("Physics constraint data name must not be null.");let e=new t1(t);e.order=a.readInt(!0),e.bone=i.bones[a.readInt(!0)];let r=a.readByte();e.skinRequired=(1&r)!=0,(2&r)!=0&&(e.x=a.readFloat()),(4&r)!=0&&(e.y=a.readFloat()),(8&r)!=0&&(e.rotate=a.readFloat()),(16&r)!=0&&(e.scaleX=a.readFloat()),(32&r)!=0&&(e.shearX=a.readFloat()),e.limit=((64&r)!=0?a.readFloat():5e3)*s,e.step=1/a.readUnsignedByte(),e.inertia=a.readFloat(),e.strength=a.readFloat(),e.damping=a.readFloat(),e.massInverse=(128&r)!=0?a.readFloat():1,e.wind=a.readFloat(),e.gravity=a.readFloat(),(1&(r=a.readByte()))!=0&&(e.inertiaGlobal=!0),(2&r)!=0&&(e.strengthGlobal=!0),(4&r)!=0&&(e.dampingGlobal=!0),(8&r)!=0&&(e.massGlobal=!0),(16&r)!=0&&(e.windGlobal=!0),(32&r)!=0&&(e.gravityGlobal=!0),(64&r)!=0&&(e.mixGlobal=!0),e.mix=(128&r)!=0?a.readFloat():1,i.physicsConstraints.push(e)}let h=this.readSkin(a,i,!0,l);h&&(i.defaultSkin=h,i.skins.push(h));{let t=i.skins.length;for(k.setArraySize(i.skins,o=t+a.readInt(!0));t<o;t++){let e=this.readSkin(a,i,!1,l);if(!e)throw Error("readSkin() should not have returned null.");i.skins[t]=e}}o=this.linkedMeshes.length;for(let t=0;t<o;t++){let e=this.linkedMeshes[t],s=i.skins[e.skinIndex];if(!e.parent)throw Error("Linked mesh parent must not be null");let a=s.getAttachment(e.slotIndex,e.parent);if(!a)throw Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?a:e.mesh,e.mesh.setParentMesh(a),null!=e.mesh.region&&e.mesh.updateRegion()}this.linkedMeshes.length=0,o=a.readInt(!0);for(let t=0;t<o;t++){let t=a.readString();if(!t)throw Error("Event data name must not be null");let e=new tG(t);e.intValue=a.readInt(!1),e.floatValue=a.readFloat(),e.stringValue=a.readString(),e.audioPath=a.readString(),e.audioPath&&(e.volume=a.readFloat(),e.balance=a.readFloat()),i.events.push(e)}o=a.readInt(!0);for(let t=0;t<o;t++){let t=a.readString();if(!t)throw Error("Animatio name must not be null.");i.animations.push(this.readAnimation(a,t,i))}return i}readSkin(t,e,s,i){let a=null,r=0;if(s){if(0==(r=t.readInt(!0)))return null;a=new t5("default")}else{let s=t.readString();if(!s)throw Error("Skin name must not be null.");a=new t5(s),i&&y.rgba8888ToColor(a.color,t.readInt32()),a.bones.length=t.readInt(!0);for(let s=0,i=a.bones.length;s<i;s++)a.bones[s]=e.bones[t.readInt(!0)];for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.ikConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.transformConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.pathConstraints[t.readInt(!0)]);for(let s=0,i=t.readInt(!0);s<i;s++)a.constraints.push(e.physicsConstraints[t.readInt(!0)]);r=t.readInt(!0)}for(let s=0;s<r;s++){let s=t.readInt(!0);for(let r=0,n=t.readInt(!0);r<n;r++){let r=t.readStringRef();if(!r)throw Error("Attachment name must not be null");let n=this.readAttachment(t,e,a,s,r,i);n&&a.setAttachment(s,r,n)}}return a}readAttachment(t,e,s,a,r,n){let l=this.scale,o=t.readByte(),h=(8&o)!=0?t.readStringRef():r;if(!h)throw Error("Attachment name must not be null");switch(7&o){case i.Region:{let e=(16&o)!=0?t.readStringRef():null,i=(32&o)!=0?t.readInt32():0xffffffff,a=(64&o)!=0?this.readSequence(t):null,r=(128&o)!=0?t.readFloat():0,n=t.readFloat(),d=t.readFloat(),c=t.readFloat(),u=t.readFloat(),f=t.readFloat(),m=t.readFloat();e||(e=h);let g=this.attachmentLoader.newRegionAttachment(s,h,e,a);if(!g)return null;return g.path=e,g.x=n*l,g.y=d*l,g.scaleX=c,g.scaleY=u,g.rotation=r,g.width=f*l,g.height=m*l,y.rgba8888ToColor(g.color,i),g.sequence=a,null==a&&g.updateRegion(),g}case i.BoundingBox:{let e=this.readVertices(t,(16&o)!=0),i=n?t.readInt32():0,a=this.attachmentLoader.newBoundingBoxAttachment(s,h);if(!a)return null;return a.worldVerticesLength=e.length,a.vertices=e.vertices,a.bones=e.bones,n&&y.rgba8888ToColor(a.color,i),a}case i.Mesh:{let e=(16&o)!=0?t.readStringRef():h,i=(32&o)!=0?t.readInt32():0xffffffff,a=(64&o)!=0?this.readSequence(t):null,r=t.readInt(!0),d=this.readVertices(t,(128&o)!=0),c=this.readFloatArray(t,d.length,1),u=this.readShortArray(t,(d.length-r-2)*3),f=[],m=0,g=0;n&&(f=this.readShortArray(t,t.readInt(!0)),m=t.readFloat(),g=t.readFloat()),e||(e=h);let p=this.attachmentLoader.newMeshAttachment(s,h,e,a);if(!p)return null;return p.path=e,y.rgba8888ToColor(p.color,i),p.bones=d.bones,p.vertices=d.vertices,p.worldVerticesLength=d.length,p.triangles=u,p.regionUVs=c,null==a&&p.updateRegion(),p.hullLength=r<<1,p.sequence=a,n&&(p.edges=f,p.width=m*l,p.height=g*l),p}case i.LinkedMesh:{let e=(16&o)!=0?t.readStringRef():h;if(null==e)throw Error("Path of linked mesh must not be null");let i=(32&o)!=0?t.readInt32():0xffffffff,r=(64&o)!=0?this.readSequence(t):null,d=t.readInt(!0),c=t.readStringRef(),u=0,f=0;n&&(u=t.readFloat(),f=t.readFloat());let m=this.attachmentLoader.newMeshAttachment(s,h,e,r);if(!m)return null;return m.path=e,y.rgba8888ToColor(m.color,i),m.sequence=r,n&&(m.width=u*l,m.height=f*l),this.linkedMeshes.push(new t9(m,d,a,c,(128&o)!=0)),m}case i.Path:{let e=this.readVertices(t,(64&o)!=0),i=k.newArray(e.length/6,0);for(let e=0,s=i.length;e<s;e++)i[e]=t.readFloat()*l;let a=n?t.readInt32():0,r=this.attachmentLoader.newPathAttachment(s,h);if(!r)return null;return r.closed=(16&o)!=0,r.constantSpeed=(32&o)!=0,r.worldVerticesLength=e.length,r.vertices=e.vertices,r.bones=e.bones,r.lengths=i,n&&y.rgba8888ToColor(r.color,a),r}case i.Point:{let e=t.readFloat(),i=t.readFloat(),a=t.readFloat(),r=n?t.readInt32():0,o=this.attachmentLoader.newPointAttachment(s,h);if(!o)return null;return o.x=i*l,o.y=a*l,o.rotation=e,n&&y.rgba8888ToColor(o.color,r),o}case i.Clipping:{let i=t.readInt(!0),a=this.readVertices(t,(16&o)!=0),r=n?t.readInt32():0,l=this.attachmentLoader.newClippingAttachment(s,h);if(!l)return null;return l.endSlot=e.slots[i],l.worldVerticesLength=a.length,l.vertices=a.vertices,l.bones=a.bones,n&&y.rgba8888ToColor(l.color,r),l}}return null}readSequence(t){let e=new F(t.readInt(!0));return e.start=t.readInt(!0),e.digits=t.readInt(!0),e.setupIndex=t.readInt(!0),e}readVertices(t,e){let s=this.scale,i=t.readInt(!0),a=new et;if(a.length=i<<1,!e)return a.vertices=this.readFloatArray(t,a.length,s),a;let r=[],n=[];for(let e=0;e<i;e++){let e=t.readInt(!0);n.push(e);for(let i=0;i<e;i++)n.push(t.readInt(!0)),r.push(t.readFloat()*s),r.push(t.readFloat()*s),r.push(t.readFloat())}return a.vertices=k.toFloatArray(r),a.bones=n,a}readFloatArray(t,e,s){let i=Array(e);if(1==s)for(let s=0;s<e;s++)i[s]=t.readFloat();else for(let a=0;a<e;a++)i[a]=t.readFloat()*s;return i}readShortArray(t,e){let s=Array(e);for(let i=0;i<e;i++)s[i]=t.readInt(!0);return s}readAnimation(e,s,i){e.readInt(!0);let a=[],r=this.scale;for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0),r=i-1;switch(s){case eg:{let s=new Q(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readStringRef());a.push(s);break}case ep:{let s=new $(i,e.readInt(!0),t),n=e.readFloat(),l=e.readUnsignedByte()/255,o=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,n,l,o,h,d),t!=r;t++){let a=e.readFloat(),r=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255;switch(e.readByte()){case eP:s.setStepped(t);break;case eX:ei(e,s,i++,t,0,n,a,l,r,1),ei(e,s,i++,t,1,n,a,o,c,1),ei(e,s,i++,t,2,n,a,h,u,1),ei(e,s,i++,t,3,n,a,d,f,1)}n=a,l=r,o=c,h=u,d=f}a.push(s);break}case ex:{let s=new j(i,e.readInt(!0),t),n=e.readFloat(),l=e.readUnsignedByte()/255,o=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,n,l,o,h),t!=r;t++){let a=e.readFloat(),r=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255;switch(e.readByte()){case eP:s.setStepped(t);break;case eX:ei(e,s,i++,t,0,n,a,l,r,1),ei(e,s,i++,t,1,n,a,o,d,1),ei(e,s,i++,t,2,n,a,h,c,1)}n=a,l=r,o=d,h=c}a.push(s);break}case eb:{let s=new J(i,e.readInt(!0),t),n=e.readFloat(),l=e.readUnsignedByte()/255,o=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,n,l,o,h,d,c,u,f),t!=r;t++){let a=e.readFloat(),r=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255,b=e.readUnsignedByte()/255,y=e.readUnsignedByte()/255;switch(e.readByte()){case eP:s.setStepped(t);break;case eX:ei(e,s,i++,t,0,n,a,l,r,1),ei(e,s,i++,t,1,n,a,o,m,1),ei(e,s,i++,t,2,n,a,h,g,1),ei(e,s,i++,t,3,n,a,d,p,1),ei(e,s,i++,t,4,n,a,c,x,1),ei(e,s,i++,t,5,n,a,u,b,1),ei(e,s,i++,t,6,n,a,f,y,1)}n=a,l=r,o=m,h=g,d=p,c=x,u=b,f=y}a.push(s);break}case ey:{let s=new K(i,e.readInt(!0),t),n=e.readFloat(),l=e.readUnsignedByte()/255,o=e.readUnsignedByte()/255,h=e.readUnsignedByte()/255,d=e.readUnsignedByte()/255,c=e.readUnsignedByte()/255,u=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,n,l,o,h,d,c,u),t!=r;t++){let a=e.readFloat(),r=e.readUnsignedByte()/255,f=e.readUnsignedByte()/255,m=e.readUnsignedByte()/255,g=e.readUnsignedByte()/255,p=e.readUnsignedByte()/255,x=e.readUnsignedByte()/255;switch(e.readByte()){case eP:s.setStepped(t);break;case eX:ei(e,s,i++,t,0,n,a,l,r,1),ei(e,s,i++,t,1,n,a,o,f,1),ei(e,s,i++,t,2,n,a,h,m,1),ei(e,s,i++,t,3,n,a,d,g,1),ei(e,s,i++,t,4,n,a,c,p,1),ei(e,s,i++,t,5,n,a,u,x,1)}n=a,l=r,o=f,h=m,d=g,c=p,u=x}a.push(s);break}case ew:{let s=new H(i,e.readInt(!0),t),n=e.readFloat(),l=e.readUnsignedByte()/255;for(let t=0,i=0;s.setFrame(t,n,l),t!=r;t++){let a=e.readFloat(),r=e.readUnsignedByte()/255;switch(e.readByte()){case eP:s.setStepped(t);break;case eX:ei(e,s,i++,t,0,n,a,l,r,1)}n=a,l=r}a.push(s)}}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0);for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0);if(s==em){let s=new G(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat(),e.readByte());a.push(s);continue}let n=e.readInt(!0);switch(s){case ea:a.push(ee(e,new _(i,n,t),1));break;case er:a.push(es(e,new V(i,n,t),r));break;case en:a.push(ee(e,new D(i,n,t),r));break;case el:a.push(ee(e,new O(i,n,t),r));break;case eo:a.push(es(e,new N(i,n,t),1));break;case eh:a.push(ee(e,new L(i,n,t),1));break;case ed:a.push(ee(e,new q(i,n,t),1));break;case ec:a.push(es(e,new U(i,n,t),1));break;case eu:a.push(ee(e,new W(i,n,t),1));break;case ef:a.push(ee(e,new z(i,n,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,n=new ts(s,e.readInt(!0),t),l=e.readByte(),o=e.readFloat(),h=(1&l)!=0?(2&l)!=0?e.readFloat():1:0,d=(4&l)!=0?e.readFloat()*r:0;for(let t=0,s=0;n.setFrame(t,o,h,d,(8&l)!=0?1:-1,(16&l)!=0,(32&l)!=0),t!=i;t++){l=e.readByte();let i=e.readFloat(),a=(1&l)!=0?(2&l)!=0?e.readFloat():1:0,c=(4&l)!=0?e.readFloat()*r:0;(64&l)!=0?n.setStepped(t):(128&l)!=0&&(ei(e,n,s++,t,0,o,i,h,a,1),ei(e,n,s++,t,1,o,i,d,c,r)),o=i,h=a,d=c}a.push(n)}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0),s=e.readInt(!0),i=s-1,r=new ti(s,e.readInt(!0),t),n=e.readFloat(),l=e.readFloat(),o=e.readFloat(),h=e.readFloat(),d=e.readFloat(),c=e.readFloat(),u=e.readFloat();for(let t=0,s=0;r.setFrame(t,n,l,o,h,d,c,u),t!=i;t++){let i=e.readFloat(),a=e.readFloat(),f=e.readFloat(),m=e.readFloat(),g=e.readFloat(),p=e.readFloat(),x=e.readFloat();switch(e.readByte()){case eP:r.setStepped(t);break;case eX:ei(e,r,s++,t,0,n,i,l,a,1),ei(e,r,s++,t,1,n,i,o,f,1),ei(e,r,s++,t,2,n,i,h,m,1),ei(e,r,s++,t,3,n,i,d,g,1),ei(e,r,s++,t,4,n,i,c,p,1),ei(e,r,s++,t,5,n,i,u,x,1)}n=i,l=a,o=f,h=m,d=g,c=p,u=x}a.push(r)}for(let s=0,n=e.readInt(!0);s<n;s++){let s=e.readInt(!0),n=i.pathConstraints[s];for(let i=0,l=e.readInt(!0);i<l;i++){let i=e.readByte(),l=e.readInt(!0),o=e.readInt(!0);switch(i){case ek:a.push(ee(e,new ta(l,o,s),n.positionMode==t.PositionMode.Fixed?r:1));break;case eI:a.push(ee(e,new tr(l,o,s),n.spacingMode==t.SpacingMode.Length||n.spacingMode==t.SpacingMode.Fixed?r:1));break;case ev:let h=new tn(l,o,s),d=e.readFloat(),c=e.readFloat(),u=e.readFloat(),f=e.readFloat();for(let t=0,s=0,i=h.getFrameCount()-1;h.setFrame(t,d,c,u,f),t!=i;t++){let i=e.readFloat(),a=e.readFloat(),r=e.readFloat(),n=e.readFloat();switch(e.readByte()){case eP:h.setStepped(t);break;case eX:ei(e,h,s++,t,0,d,i,c,a,1),ei(e,h,s++,t,1,d,i,u,r,1),ei(e,h,s++,t,2,d,i,f,n,1)}d=i,c=a,u=r,f=n}a.push(h)}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=e.readInt(!0)-1;for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readByte(),i=e.readInt(!0);if(s==eY){let s=new tg(i,t);for(let t=0;t<i;t++)s.setFrame(t,e.readFloat());a.push(s);continue}let r=e.readInt(!0);switch(s){case eT:a.push(ee(e,new to(i,r,t),1));break;case eB:a.push(ee(e,new th(i,r,t),1));break;case eA:a.push(ee(e,new td(i,r,t),1));break;case eF:a.push(ee(e,new tc(i,r,t),1));break;case eC:a.push(ee(e,new tu(i,r,t),1));break;case eE:a.push(ee(e,new tf(i,r,t),1));break;case eR:a.push(ee(e,new tm(i,r,t),1))}}}for(let t=0,s=e.readInt(!0);t<s;t++){let t=i.skins[e.readInt(!0)];for(let s=0,i=e.readInt(!0);s<i;s++){let s=e.readInt(!0);for(let i=0,n=e.readInt(!0);i<n;i++){let i=e.readStringRef();if(!i)throw Error("attachmentName must not be null.");let n=t.getAttachment(s,i),l=e.readByte(),o=e.readInt(!0),h=o-1;switch(l){case eM:{let t=n.bones,i=n.vertices,l=t?i.length/3*2:i.length,d=new Z(o,e.readInt(!0),s,n),c=e.readFloat();for(let s=0,a=0;;s++){let n;let o=e.readInt(!0);if(0==o)n=t?k.newFloatArray(l):i;else{n=k.newFloatArray(l);let s=e.readInt(!0);if(o+=s,1==r)for(let t=s;t<o;t++)n[t]=e.readFloat();else for(let t=s;t<o;t++)n[t]=e.readFloat()*r;if(!t)for(let t=0,e=n.length;t<e;t++)n[t]+=i[t]}if(d.setFrame(s,c,n),s==h)break;let u=e.readFloat();switch(e.readByte()){case eP:d.setStepped(s);break;case eX:ei(e,d,a++,s,0,c,u,0,1,1)}c=u}a.push(d);break}case eS:{let t=new tp(o,s,n);for(let s=0;s<o;s++){let i=e.readFloat(),a=e.readInt32();t.setFrame(s,i,C[15&a],a>>4,e.readFloat())}a.push(t)}}}}}let n=e.readInt(!0);if(n>0){let t=new te(n),s=i.slots.length;for(let i=0;i<n;i++){let a=e.readFloat(),r=e.readInt(!0),n=k.newArray(s,0);for(let t=s-1;t>=0;t--)n[t]=-1;let l=k.newArray(s-r,0),o=0,h=0;for(let t=0;t<r;t++){let t=e.readInt(!0);for(;o!=t;)l[h++]=o++;n[o+e.readInt(!0)]=o++}for(;o<s;)l[h++]=o++;for(let t=s-1;t>=0;t--)-1==n[t]&&(n[t]=l[--h]);t.setFrame(i,a,n)}a.push(t)}let l=e.readInt(!0);if(l>0){let t=new tt(l);for(let s=0;s<l;s++){let a=e.readFloat(),r=i.events[e.readInt(!0)],n=new tz(a,r);n.intValue=e.readInt(!1),n.floatValue=e.readFloat(),n.stringValue=e.readString(),null==n.stringValue&&(n.stringValue=r.stringValue),n.data.audioPath&&(n.volume=e.readFloat(),n.balance=e.readFloat()),t.setFrame(s,n)}a.push(t)}let o=0;for(let t=0,e=a.length;t<e;t++)o=Math.max(o,a[t].getDuration());return new E(s,a,o)}}class t7{strings;index;buffer;constructor(t,e=[],s=0,i=new DataView(t instanceof ArrayBuffer?t:t.buffer)){this.strings=e,this.index=s,this.buffer=i}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){let t=this.buffer.getInt16(this.index);return this.index+=2,t}readInt32(){let t=this.buffer.getInt32(this.index);return this.index+=4,t}readInt(t){let e=this.readByte(),s=127&e;return(128&e)!=0&&(s|=(127&(e=this.readByte()))<<7,(128&e)!=0&&(s|=(127&(e=this.readByte()))<<14,(128&e)!=0&&(s|=(127&(e=this.readByte()))<<21,(128&e)!=0&&(s|=(127&(e=this.readByte()))<<28)))),t?s:s>>>1^-(1&s)}readStringRef(){let t=this.readInt(!0);return 0==t?null:this.strings[t-1]}readString(){let t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;let e="";for(let s=0;s<t;){let t=this.readUnsignedByte();switch(t>>4){case 12:case 13:e+=String.fromCharCode((31&t)<<6|63&this.readByte()),s+=2;break;case 14:e+=String.fromCharCode((15&t)<<12|(63&this.readByte())<<6|63&this.readByte()),s+=3;break;default:e+=String.fromCharCode(t),s++}}return e}readFloat(){let t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return 0!=this.readByte()}}class t9{parent;skinIndex;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,a){this.mesh=t,this.skinIndex=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=a}}class et{bones;vertices;length;constructor(t=null,e=null,s=0){this.bones=t,this.vertices=e,this.length=s}}function ee(t,e,s){let i=t.readFloat(),a=t.readFloat()*s;for(let r=0,n=0,l=e.getFrameCount()-1;e.setFrame(r,i,a),r!=l;r++){let l=t.readFloat(),o=t.readFloat()*s;switch(t.readByte()){case eP:e.setStepped(r);break;case eX:ei(t,e,n++,r,0,i,l,a,o,s)}i=l,a=o}return e}function es(t,e,s){let i=t.readFloat(),a=t.readFloat()*s,r=t.readFloat()*s;for(let n=0,l=0,o=e.getFrameCount()-1;e.setFrame(n,i,a,r),n!=o;n++){let o=t.readFloat(),h=t.readFloat()*s,d=t.readFloat()*s;switch(t.readByte()){case eP:e.setStepped(n);break;case eX:ei(t,e,l++,n,0,i,o,a,h,s),ei(t,e,l++,n,1,i,o,r,d,s)}i=o,a=h,r=d}return e}function ei(t,e,s,i,a,r,n,l,o,h){e.setBezier(s,i,a,r,l,t.readFloat(),t.readFloat()*h,t.readFloat(),t.readFloat()*h,n,o)}(p=i||(i={}))[p.Region=0]="Region",p[p.BoundingBox=1]="BoundingBox",p[p.Mesh=2]="Mesh",p[p.LinkedMesh=3]="LinkedMesh",p[p.Path=4]="Path",p[p.Point=5]="Point",p[p.Clipping=6]="Clipping";let ea=0,er=1,en=2,el=3,eo=4,eh=5,ed=6,ec=7,eu=8,ef=9,em=10,eg=0,ep=1,ex=2,eb=3,ey=4,ew=5,eM=0,eS=1,ek=0,eI=1,ev=2,eT=0,eB=1,eA=2,eF=4,eC=5,eE=6,eR=7,eY=8,eP=1,eX=2;class e_{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new I(()=>k.newFloatArray(16));update(t,e){if(!t)throw Error("skeleton cannot be null.");let s=this.boundingBoxes,i=this.polygons,a=this.polygonPool,r=t.slots,n=r.length;s.length=0,a.freeAll(i),i.length=0;for(let t=0;t<n;t++){let e=r[t];if(!e.bone.active)continue;let n=e.getAttachment();if(n instanceof tA){s.push(n);let t=a.obtain();t.length!=n.worldVerticesLength&&(t=k.newFloatArray(n.worldVerticesLength)),i.push(t),n.computeWorldVertices(e,0,n.worldVerticesLength,t,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,a=this.polygons;for(let r=0,n=a.length;r<n;r++){let n=a[r];for(let a=0,r=n.length;a<r;a+=2){let r=n[a],l=n[a+1];t=Math.min(t,r),e=Math.min(e,l),s=Math.max(s,r),i=Math.max(i,l)}}this.minX=t,this.minY=e,this.maxX=s,this.maxY=i}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,s,i){let a=this.minX,r=this.minY,n=this.maxX,l=this.maxY;if(t<=a&&s<=a||e<=r&&i<=r||t>=n&&s>=n||e>=l&&i>=l)return!1;let o=(i-e)/(s-t),h=o*(a-t)+e;if(h>r&&h<l||(h=o*(n-t)+e)>r&&h<l)return!0;let d=(r-e)/o+t;return d>a&&d<n||(d=(l-e)/o+t)>a&&d<n}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){let s=this.polygons;for(let i=0,a=s.length;i<a;i++)if(this.containsPointPolygon(s[i],t,e))return this.boundingBoxes[i];return null}containsPointPolygon(t,e,s){let i=t.length,a=i-2,r=!1;for(let n=0;n<i;n+=2){let i=t[n+1],l=t[a+1];if(i<s&&l>=s||l<s&&i>=s){let o=t[n];o+(s-i)/(l-i)*(t[a]-o)<e&&(r=!r)}a=n}return r}intersectsSegment(t,e,s,i){let a=this.polygons;for(let r=0,n=a.length;r<n;r++)if(this.intersectsSegmentPolygon(a[r],t,e,s,i))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(t,e,s,i,a){let r=t.length,n=e-i,l=s-a,o=e*a-s*i,h=t[r-2],d=t[r-1];for(let c=0;c<r;c+=2){let r=t[c],u=t[c+1],f=h*u-d*r,m=h-r,g=d-u,p=n*g-l*m,x=(o*m-n*f)/p;if((x>=h&&x<=r||x>=r&&x<=h)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(o*g-l*f)/p;if((t>=d&&t<=u||t>=u&&t<=d)&&(t>=s&&t<=a||t>=a&&t<=s))return!0}h=r,d=u}return!1}getPolygon(t){if(!t)throw Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return -1==e?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}}class eV{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new I(()=>[]);polygonIndicesPool=new I(()=>[]);triangulate(t){let e=t.length>>1,s=this.indicesArray;s.length=0;for(let t=0;t<e;t++)s[t]=t;let i=this.isConcaveArray;i.length=0;for(let a=0,r=e;a<r;++a)i[a]=eV.isConcave(a,e,t,s);let a=this.triangles;for(a.length=0;e>3;){let r=e-1,n=0,l=1;for(;;){t:if(!i[n]){let a=s[r]<<1,o=s[n]<<1,h=s[l]<<1,d=t[a],c=t[a+1],u=t[o],f=t[o+1],m=t[h],g=t[h+1];for(let a=(l+1)%e;a!=r;a=(a+1)%e){if(!i[a])continue;let e=s[a]<<1,r=t[e],n=t[e+1];if(eV.positiveArea(m,g,d,c,r,n)&&eV.positiveArea(d,c,u,f,r,n)&&eV.positiveArea(u,f,m,g,r,n))break t}break}if(0==l){do{if(!i[n])break;n--}while(n>0);break}r=n,n=l,l=(l+1)%e}a.push(s[(e+n-1)%e]),a.push(s[n]),a.push(s[(n+1)%e]),s.splice(n,1),i.splice(n,1);let o=(--e+n-1)%e,h=n==e?0:n;i[o]=eV.isConcave(o,e,t,s),i[h]=eV.isConcave(h,e,t,s)}return 3==e&&(a.push(s[2]),a.push(s[0]),a.push(s[1])),a}decompose(t,e){let s=this.convexPolygons;this.polygonPool.freeAll(s),s.length=0;let i=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(i),i.length=0;let a=this.polygonIndicesPool.obtain();a.length=0;let r=this.polygonPool.obtain();r.length=0;let n=-1,l=0;for(let o=0,h=e.length;o<h;o+=3){let h=e[o]<<1,d=e[o+1]<<1,c=e[o+2]<<1,u=t[h],f=t[h+1],m=t[d],g=t[d+1],p=t[c],x=t[c+1],b=!1;if(n==h){let t=r.length-4,e=eV.winding(r[t],r[t+1],r[t+2],r[t+3],p,x),s=eV.winding(p,x,r[0],r[1],r[2],r[3]);e==l&&s==l&&(r.push(p),r.push(x),a.push(c),b=!0)}b||(r.length>0?(s.push(r),i.push(a)):(this.polygonPool.free(r),this.polygonIndicesPool.free(a)),(r=this.polygonPool.obtain()).length=0,r.push(u),r.push(f),r.push(m),r.push(g),r.push(p),r.push(x),(a=this.polygonIndicesPool.obtain()).length=0,a.push(h),a.push(d),a.push(c),l=eV.winding(u,f,m,g,p,x),n=h)}r.length>0&&(s.push(r),i.push(a));for(let t=0,e=s.length;t<e;t++){if(0==(a=i[t]).length)continue;let n=a[0],l=a[a.length-1],o=(r=s[t]).length-4,h=r[o],d=r[o+1],c=r[o+2],u=r[o+3],f=r[0],m=r[1],g=r[2],p=r[3],x=eV.winding(h,d,c,u,f,m);for(let o=0;o<e;o++){if(o==t)continue;let e=i[o];if(3!=e.length)continue;let b=e[0],y=e[1],w=e[2],M=s[o],S=M[M.length-2],k=M[M.length-1];if(b!=n||y!=l)continue;let I=eV.winding(h,d,c,u,S,k),v=eV.winding(S,k,f,m,g,p);I==x&&v==x&&(M.length=0,e.length=0,r.push(S),r.push(k),a.push(w),h=c,d=u,c=S,u=k,o=0)}}for(let t=s.length-1;t>=0;t--)0==(r=s[t]).length&&(s.splice(t,1),this.polygonPool.free(r),a=i[t],i.splice(t,1),this.polygonIndicesPool.free(a));return s}static isConcave(t,e,s,i){let a=i[(e+t-1)%e]<<1,r=i[t]<<1,n=i[(t+1)%e]<<1;return!this.positiveArea(s[a],s[a+1],s[r],s[r+1],s[n],s[n+1])}static positiveArea(t,e,s,i,a,r){return t*(r-i)+s*(e-r)+a*(i-e)>=0}static winding(t,e,s,i,a,r){let n=s-t,l=i-e;return a*l-r*n+n*e-t*l>=0?1:-1}}class eD{triangulator=new eV;clippingPolygon=[];clipOutput=[];clippedVertices=[];clippedUVs=[];clippedTriangles=[];scratch=[];clipAttachment=null;clippingPolygons=null;clipStart(t,e){if(this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=k.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let a=this.clippingPolygon;eD.makeClockwise(a);let r=this.clippingPolygons=this.triangulator.decompose(a,this.triangulator.triangulate(a));for(let t=0,e=r.length;t<e;t++){let e=r[t];eD.makeClockwise(e),e.push(e[0]),e.push(e[1])}return r.length}clipEndWithSlot(t){this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){this.clipAttachment&&(this.clipAttachment=null,this.clippingPolygons=null,this.clippedVertices.length=0,this.clippedTriangles.length=0,this.clippingPolygon.length=0)}isClipping(){return null!=this.clipAttachment}clipTriangles(t,e,s,i,a,r,n,l){let o,h,d,c,u,f;"number"==typeof e?(o=s,h=i,d=a,c=r,u=n,f=l):(o=e,h=s,d=i,c=a,u=r,f=n),d&&c&&u&&"boolean"==typeof f?this.clipTrianglesRender(t,o,h,d,c,u,f):this.clipTrianglesNoRender(t,o,h)}clipTrianglesNoRender(t,e,s){let i=this.clipOutput,a=this.clippedVertices,r=this.clippedTriangles,n=this.clippingPolygons,l=n.length,o=0;a.length=0,r.length=0;for(let h=0;h<s;h+=3){let s=e[h]<<1,d=t[s],c=t[s+1],u=t[s=e[h+1]<<1],f=t[s+1],m=t[s=e[h+2]<<1],g=t[s+1];for(let t=0;t<l;t++){let e=a.length;if(this.clip(d,c,u,f,m,g,n[t],i)){let t=i.length;if(0==t)continue;let s=t>>1,n=this.clipOutput,l=k.setArraySize(a,e+2*s);for(let s=0;s<t;s+=2,e+=2){let t=n[s],i=n[s+1];l[e]=t,l[e+1]=i}e=r.length;let h=k.setArraySize(r,e+3*(s-2));s--;for(let t=1;t<s;t++,e+=3)h[e]=o,h[e+1]=o+t,h[e+2]=o+t+1;o+=s+1}else{let t=k.setArraySize(a,e+6);t[e]=d,t[e+1]=c,t[e+2]=u,t[e+3]=f,t[e+4]=m,t[e+5]=g,e=r.length;let s=k.setArraySize(r,e+3);s[e]=o,s[e+1]=o+1,s[e+2]=o+2,o+=3;break}}}}clipTrianglesRender(t,e,s,i,a,r,n){let l=this.clipOutput,o=this.clippedVertices,h=this.clippedTriangles,d=this.clippingPolygons,c=d.length,u=n?12:8,f=0;o.length=0,h.length=0;for(let m=0;m<s;m+=3){let s=e[m]<<1,g=t[s],p=t[s+1],x=i[s],b=i[s+1],y=t[s=e[m+1]<<1],w=t[s+1],M=i[s],S=i[s+1],I=t[s=e[m+2]<<1],v=t[s+1],T=i[s],B=i[s+1];for(let t=0;t<c;t++){let e=o.length;if(this.clip(g,p,y,w,I,v,d[t],l)){let t=l.length;if(0==t)continue;let s=w-v,i=I-y,d=g-I,c=v-p,m=1/(s*d+i*(p-v)),A=t>>1,F=this.clipOutput,C=k.setArraySize(o,e+A*u);for(let l=0;l<t;l+=2,e+=u){let t=F[l],o=F[l+1];C[e]=t,C[e+1]=o,C[e+2]=a.r,C[e+3]=a.g,C[e+4]=a.b,C[e+5]=a.a;let h=t-I,u=o-v,f=(s*h+i*u)*m,g=(c*h+d*u)*m,p=1-f-g;C[e+6]=x*f+M*g+T*p,C[e+7]=b*f+S*g+B*p,n&&(C[e+8]=r.r,C[e+9]=r.g,C[e+10]=r.b,C[e+11]=r.a)}e=h.length;let E=k.setArraySize(h,e+3*(A-2));A--;for(let t=1;t<A;t++,e+=3)E[e]=f,E[e+1]=f+t,E[e+2]=f+t+1;f+=A+1}else{let t=k.setArraySize(o,e+3*u);t[e]=g,t[e+1]=p,t[e+2]=a.r,t[e+3]=a.g,t[e+4]=a.b,t[e+5]=a.a,n?(t[e+6]=x,t[e+7]=b,t[e+8]=r.r,t[e+9]=r.g,t[e+10]=r.b,t[e+11]=r.a,t[e+12]=y,t[e+13]=w,t[e+14]=a.r,t[e+15]=a.g,t[e+16]=a.b,t[e+17]=a.a,t[e+18]=M,t[e+19]=S,t[e+20]=r.r,t[e+21]=r.g,t[e+22]=r.b,t[e+23]=r.a,t[e+24]=I,t[e+25]=v,t[e+26]=a.r,t[e+27]=a.g,t[e+28]=a.b,t[e+29]=a.a,t[e+30]=T,t[e+31]=B,t[e+32]=r.r,t[e+33]=r.g,t[e+34]=r.b,t[e+35]=r.a):(t[e+6]=x,t[e+7]=b,t[e+8]=y,t[e+9]=w,t[e+10]=a.r,t[e+11]=a.g,t[e+12]=a.b,t[e+13]=a.a,t[e+14]=M,t[e+15]=S,t[e+16]=I,t[e+17]=v,t[e+18]=a.r,t[e+19]=a.g,t[e+20]=a.b,t[e+21]=a.a,t[e+22]=T,t[e+23]=B),e=h.length;let s=k.setArraySize(h,e+3);s[e]=f,s[e+1]=f+1,s[e+2]=f+2,f+=3;break}}}}clipTrianglesUnpacked(t,e,s,i){let a=this.clipOutput,r=this.clippedVertices,n=this.clippedUVs,l=this.clippedTriangles,o=this.clippingPolygons,h=o.length,d=0;r.length=0,n.length=0,l.length=0;for(let c=0;c<s;c+=3){let s=e[c]<<1,u=t[s],f=t[s+1],m=i[s],g=i[s+1],p=t[s=e[c+1]<<1],x=t[s+1],b=i[s],y=i[s+1],w=t[s=e[c+2]<<1],M=t[s+1],S=i[s],I=i[s+1];for(let t=0;t<h;t++){let e=r.length;if(this.clip(u,f,p,x,w,M,o[t],a)){let t=a.length;if(0==t)continue;let s=x-M,i=w-p,o=u-w,h=M-f,c=1/(s*o+i*(f-M)),v=t>>1,T=this.clipOutput,B=k.setArraySize(r,e+2*v),A=k.setArraySize(n,e+2*v);for(let a=0;a<t;a+=2,e+=2){let t=T[a],r=T[a+1];B[e]=t,B[e+1]=r;let n=t-w,l=r-M,d=(s*n+i*l)*c,u=(h*n+o*l)*c,f=1-d-u;A[e]=m*d+b*u+S*f,A[e+1]=g*d+y*u+I*f}e=l.length;let F=k.setArraySize(l,e+3*(v-2));v--;for(let t=1;t<v;t++,e+=3)F[e]=d,F[e+1]=d+t,F[e+2]=d+t+1;d+=v+1}else{let t=k.setArraySize(r,e+6);t[e]=u,t[e+1]=f,t[e+2]=p,t[e+3]=x,t[e+4]=w,t[e+5]=M;let s=k.setArraySize(n,e+6);s[e]=m,s[e+1]=g,s[e+2]=b,s[e+3]=y,s[e+4]=S,s[e+5]=I,e=l.length;let i=k.setArraySize(l,e+3);i[e]=d,i[e+1]=d+1,i[e+2]=d+2,d+=3;break}}}}clip(t,e,s,i,a,r,n,l){let o,h=l,d=!1;n.length%4>=2?(o=l,l=this.scratch):o=this.scratch,o.length=0,o.push(t),o.push(e),o.push(s),o.push(i),o.push(a),o.push(r),o.push(t),o.push(e),l.length=0;let c=n.length-4;for(let t=0;;t+=2){let e=n[t],s=n[t+1],i=e-n[t+2],a=s-n[t+3],r=l.length,u=o;for(let t=0,r=o.length-2;t<r;){let r=u[t],n=u[t+1],o=u[t+=2],h=u[t+1],c=a*(e-o)>i*(s-h),f=a*(e-r)-i*(s-n);if(f>0){if(c){l.push(o),l.push(h);continue}let t=o-r,e=h-n,s=f/(t*a-e*i);if(s>=0&&s<=1)l.push(r+t*s),l.push(n+e*s);else{l.push(o),l.push(h);continue}}else if(c){let t=o-r,e=h-n,s=f/(t*a-e*i);if(s>=0&&s<=1)l.push(r+t*s),l.push(n+e*s),l.push(o),l.push(h);else{l.push(o),l.push(h);continue}}d=!0}if(r==l.length)return h.length=0,!0;if(l.push(l[0]),l.push(l[1]),t==c)break;let f=l;(l=o).length=0,o=f}if(h!=l){h.length=0;for(let t=0,e=l.length-2;t<e;t++)h[t]=l[t]}else h.length=h.length-2;return d}static makeClockwise(t){let e=t.length,s=t[e-2]*t[1]-t[0]*t[e-1],i=0,a=0,r=0;for(let n=0,l=e-3;n<l;n+=2)i=t[n],a=t[n+1],r=t[n+2],s+=i*t[n+3]-r*a;if(!(s<0))for(let s=0,i=e-2,a=e>>1;s<a;s+=2){let e=t[s],a=t[s+1],r=i-s;t[s]=t[r],t[s+1]=t[r+1],t[r]=e,t[r+1]=a}}}class eO{attachmentLoader;scale=1;linkedMeshes=[];constructor(t){this.attachmentLoader=t}readSkeletonData(e){let s=this.scale,i=new t2,a="string"==typeof e?JSON.parse(e):e,r=a.skeleton;if(r&&(i.hash=r.hash,i.version=r.spine,i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height,i.referenceScale=eW(r,"referenceScale",100)*s,i.fps=r.fps,i.imagesPath=r.images??null,i.audioPath=r.audio??null),a.bones)for(let e=0;e<a.bones.length;e++){let r=a.bones[e],n=null,l=eW(r,"parent",null);l&&(n=i.findBone(l));let o=new tL(i.bones.length,r.name,n);o.length=eW(r,"length",0)*s,o.x=eW(r,"x",0)*s,o.y=eW(r,"y",0)*s,o.rotation=eW(r,"rotation",0),o.scaleX=eW(r,"scaleX",1),o.scaleY=eW(r,"scaleY",1),o.shearX=eW(r,"shearX",0),o.shearY=eW(r,"shearY",0),o.inherit=k.enumValue(t.Inherit,eW(r,"inherit","Normal")),o.skinRequired=eW(r,"skin",!1);let h=eW(r,"color",null);h&&o.color.setFromString(h),i.bones.push(o)}if(a.slots)for(let e=0;e<a.slots.length;e++){let s=a.slots[e],r=s.name,n=i.findBone(s.bone);if(!n)throw Error(`Couldn't find bone ${s.bone} for slot ${r}`);let l=new t6(i.slots.length,r,n),o=eW(s,"color",null);o&&l.color.setFromString(o);let h=eW(s,"dark",null);h&&(l.darkColor=y.fromString(h)),l.attachmentName=eW(s,"attachment",null),l.blendMode=k.enumValue(t.BlendMode,eW(s,"blend","normal")),l.visible=eW(s,"visible",!0),i.slots.push(l)}if(a.ik)for(let t=0;t<a.ik.length;t++){let e=a.ik[t],r=new tj(e.name);r.order=eW(e,"order",0),r.skinRequired=eW(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=i.findBone(e.bones[t]);if(!s)throw Error(`Couldn't find bone ${e.bones[t]} for IK constraint ${e.name}.`);r.bones.push(s)}let n=i.findBone(e.target);if(!n)throw Error(`Couldn't find target bone ${e.target} for IK constraint ${e.name}.`);r.target=n,r.mix=eW(e,"mix",1),r.softness=eW(e,"softness",0)*s,r.bendDirection=eW(e,"bendPositive",!0)?1:-1,r.compress=eW(e,"compress",!1),r.stretch=eW(e,"stretch",!1),r.uniform=eW(e,"uniform",!1),i.ikConstraints.push(r)}if(a.transform)for(let t=0;t<a.transform.length;t++){let e=a.transform[t],r=new t8(e.name);r.order=eW(e,"order",0),r.skinRequired=eW(e,"skin",!1);for(let t=0;t<e.bones.length;t++){let s=e.bones[t],a=i.findBone(s);if(!a)throw Error(`Couldn't find bone ${s} for transform constraint ${e.name}.`);r.bones.push(a)}let n=e.target,l=i.findBone(n);if(!l)throw Error(`Couldn't find target bone ${n} for transform constraint ${e.name}.`);r.target=l,r.local=eW(e,"local",!1),r.relative=eW(e,"relative",!1),r.offsetRotation=eW(e,"rotation",0),r.offsetX=eW(e,"x",0)*s,r.offsetY=eW(e,"y",0)*s,r.offsetScaleX=eW(e,"scaleX",0),r.offsetScaleY=eW(e,"scaleY",0),r.offsetShearY=eW(e,"shearY",0),r.mixRotate=eW(e,"mixRotate",1),r.mixX=eW(e,"mixX",1),r.mixY=eW(e,"mixY",r.mixX),r.mixScaleX=eW(e,"mixScaleX",1),r.mixScaleY=eW(e,"mixScaleY",r.mixScaleX),r.mixShearY=eW(e,"mixShearY",1),i.transformConstraints.push(r)}if(a.path)for(let e=0;e<a.path.length;e++){let r=a.path[e],n=new tH(r.name);n.order=eW(r,"order",0),n.skinRequired=eW(r,"skin",!1);for(let t=0;t<r.bones.length;t++){let e=r.bones[t],s=i.findBone(e);if(!s)throw Error(`Couldn't find bone ${e} for path constraint ${r.name}.`);n.bones.push(s)}let l=r.target,o=i.findSlot(l);if(!o)throw Error(`Couldn't find target slot ${l} for path constraint ${r.name}.`);n.target=o,n.positionMode=k.enumValue(t.PositionMode,eW(r,"positionMode","Percent")),n.spacingMode=k.enumValue(t.SpacingMode,eW(r,"spacingMode","Length")),n.rotateMode=k.enumValue(t.RotateMode,eW(r,"rotateMode","Tangent")),n.offsetRotation=eW(r,"rotation",0),n.position=eW(r,"position",0),n.positionMode==t.PositionMode.Fixed&&(n.position*=s),n.spacing=eW(r,"spacing",0),(n.spacingMode==t.SpacingMode.Length||n.spacingMode==t.SpacingMode.Fixed)&&(n.spacing*=s),n.mixRotate=eW(r,"mixRotate",1),n.mixX=eW(r,"mixX",1),n.mixY=eW(r,"mixY",n.mixX),i.pathConstraints.push(n)}if(a.physics)for(let t=0;t<a.physics.length;t++){let e=a.physics[t],r=new t1(e.name);r.order=eW(e,"order",0),r.skinRequired=eW(e,"skin",!1);let n=e.bone,l=i.findBone(n);if(null==l)throw Error("Physics bone not found: "+n);r.bone=l,r.x=eW(e,"x",0),r.y=eW(e,"y",0),r.rotate=eW(e,"rotate",0),r.scaleX=eW(e,"scaleX",0),r.shearX=eW(e,"shearX",0),r.limit=eW(e,"limit",5e3)*s,r.step=1/eW(e,"fps",60),r.inertia=eW(e,"inertia",1),r.strength=eW(e,"strength",100),r.damping=eW(e,"damping",1),r.massInverse=1/eW(e,"mass",1),r.wind=eW(e,"wind",0),r.gravity=eW(e,"gravity",0),r.mix=eW(e,"mix",1),r.inertiaGlobal=eW(e,"inertiaGlobal",!1),r.strengthGlobal=eW(e,"strengthGlobal",!1),r.dampingGlobal=eW(e,"dampingGlobal",!1),r.massGlobal=eW(e,"massGlobal",!1),r.windGlobal=eW(e,"windGlobal",!1),r.gravityGlobal=eW(e,"gravityGlobal",!1),r.mixGlobal=eW(e,"mixGlobal",!1),i.physicsConstraints.push(r)}if(a.skins)for(let t=0;t<a.skins.length;t++){let e=a.skins[t],s=new t5(e.name);if(e.bones)for(let t=0;t<e.bones.length;t++){let a=e.bones[t],r=i.findBone(a);if(!r)throw Error(`Couldn't find bone ${a} for skin ${e.name}.`);s.bones.push(r)}if(e.ik)for(let t=0;t<e.ik.length;t++){let a=e.ik[t],r=i.findIkConstraint(a);if(!r)throw Error(`Couldn't find IK constraint ${a} for skin ${e.name}.`);s.constraints.push(r)}if(e.transform)for(let t=0;t<e.transform.length;t++){let a=e.transform[t],r=i.findTransformConstraint(a);if(!r)throw Error(`Couldn't find transform constraint ${a} for skin ${e.name}.`);s.constraints.push(r)}if(e.path)for(let t=0;t<e.path.length;t++){let a=e.path[t],r=i.findPathConstraint(a);if(!r)throw Error(`Couldn't find path constraint ${a} for skin ${e.name}.`);s.constraints.push(r)}if(e.physics)for(let t=0;t<e.physics.length;t++){let a=e.physics[t],r=i.findPhysicsConstraint(a);if(!r)throw Error(`Couldn't find physics constraint ${a} for skin ${e.name}.`);s.constraints.push(r)}for(let t in e.attachments){let a=i.findSlot(t);if(!a)throw Error(`Couldn't find slot ${t} for skin ${e.name}.`);let r=e.attachments[t];for(let t in r){let e=this.readAttachment(r[t],s,a.index,t,i);e&&s.setAttachment(a.index,t,e)}}i.skins.push(s),"default"==s.name&&(i.defaultSkin=s)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],s=e.skin?i.findSkin(e.skin):i.defaultSkin;if(!s)throw Error(`Skin not found: ${e.skin}`);let a=s.getAttachment(e.slotIndex,e.parent);if(!a)throw Error(`Parent mesh not found: ${e.parent}`);e.mesh.timelineAttachment=e.inheritTimeline?a:e.mesh,e.mesh.setParentMesh(a),null!=e.mesh.region&&e.mesh.updateRegion()}if(this.linkedMeshes.length=0,a.events)for(let t in a.events){let e=a.events[t],s=new tG(t);s.intValue=eW(e,"int",0),s.floatValue=eW(e,"float",0),s.stringValue=eW(e,"string",""),s.audioPath=eW(e,"audio",null),s.audioPath&&(s.volume=eW(e,"volume",1),s.balance=eW(e,"balance",0)),i.events.push(s)}if(a.animations)for(let t in a.animations){let e=a.animations[t];this.readAnimation(e,t,i)}return i}readAttachment(t,e,s,i,a){let r=this.scale;switch(i=eW(t,"name",i),eW(t,"type","region")){case"region":{let s=eW(t,"path",i),a=this.readSequence(eW(t,"sequence",null)),n=this.attachmentLoader.newRegionAttachment(e,i,s,a);if(!n)return null;n.path=s,n.x=eW(t,"x",0)*r,n.y=eW(t,"y",0)*r,n.scaleX=eW(t,"scaleX",1),n.scaleY=eW(t,"scaleY",1),n.rotation=eW(t,"rotation",0),n.width=t.width*r,n.height=t.height*r,n.sequence=a;let l=eW(t,"color",null);return l&&n.color.setFromString(l),null!=n.region&&n.updateRegion(),n}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(!s)return null;this.readVertices(t,s,t.vertexCount<<1);let a=eW(t,"color",null);return a&&s.color.setFromString(a),s}case"mesh":case"linkedmesh":{let a=eW(t,"path",i),n=this.readSequence(eW(t,"sequence",null)),l=this.attachmentLoader.newMeshAttachment(e,i,a,n);if(!l)return null;l.path=a;let o=eW(t,"color",null);o&&l.color.setFromString(o),l.width=eW(t,"width",0)*r,l.height=eW(t,"height",0)*r,l.sequence=n;let h=eW(t,"parent",null);if(h)return this.linkedMeshes.push(new eN(l,eW(t,"skin",null),s,h,eW(t,"timelines",!0))),l;let d=t.uvs;return this.readVertices(t,l,d.length),l.triangles=t.triangles,l.regionUVs=d,null!=l.region&&l.updateRegion(),l.edges=eW(t,"edges",null),l.hullLength=2*eW(t,"hull",0),l}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(!s)return null;s.closed=eW(t,"closed",!1),s.constantSpeed=eW(t,"constantSpeed",!0);let a=t.vertexCount;this.readVertices(t,s,a<<1);let n=k.newArray(a/3,0);for(let e=0;e<t.lengths.length;e++)n[e]=t.lengths[e]*r;s.lengths=n;let l=eW(t,"color",null);return l&&s.color.setFromString(l),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(!s)return null;s.x=eW(t,"x",0)*r,s.y=eW(t,"y",0)*r,s.rotation=eW(t,"rotation",0);let a=eW(t,"color",null);return a&&s.color.setFromString(a),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(!s)return null;let r=eW(t,"end",null);r&&(s.endSlot=a.findSlot(r));let n=t.vertexCount;this.readVertices(t,s,n<<1);let l=eW(t,"color",null);return l&&s.color.setFromString(l),s}}return null}readSequence(t){if(null==t)return null;let e=new F(eW(t,"count",0));return e.start=eW(t,"start",1),e.digits=eW(t,"digits",0),e.setupIndex=eW(t,"setup",0),e}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let a=t.vertices;if(s==a.length){let t=k.toFloatArray(a);if(1!=i)for(let e=0,s=a.length;e<s;e++)t[e]*=i;e.vertices=t;return}let r=[],n=[];for(let t=0,e=a.length;t<e;){let e=a[t++];n.push(e);for(let s=t+4*e;t<s;t+=4)n.push(a[t]),r.push(a[t+1]*i),r.push(a[t+2]*i),r.push(a[t+3])}e.bones=n,e.vertices=k.toFloatArray(r)}readAnimation(e,i,a){let r=this.scale,n=[];if(e.slots)for(let t in e.slots){let s=e.slots[t],i=a.findSlot(t);if(!i)throw Error("Slot not found: "+t);let r=i.index;for(let t in s){let e=s[t];if(!e)continue;let i=e.length;if("attachment"==t){let t=new Q(i,r);for(let s=0;s<i;s++){let i=e[s];t.setFrame(s,eW(i,"time",0),eW(i,"name",null))}n.push(t)}else if("rgba"==t){let t=new $(i,i<<2,r),s=e[0],a=eW(s,"time",0),l=y.fromString(s.color);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,l.a);let n=e[i+1];if(!n){t.shrink(r);break}let o=eW(n,"time",0),h=y.fromString(n.color),d=s.curve;d&&(r=eU(d,t,r,i,0,a,o,l.r,h.r,1),r=eU(d,t,r,i,1,a,o,l.g,h.g,1),r=eU(d,t,r,i,2,a,o,l.b,h.b,1),r=eU(d,t,r,i,3,a,o,l.a,h.a,1)),a=o,l=h,s=n}n.push(t)}else if("rgb"==t){let t=new j(i,3*i,r),s=e[0],a=eW(s,"time",0),l=y.fromString(s.color);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b);let n=e[i+1];if(!n){t.shrink(r);break}let o=eW(n,"time",0),h=y.fromString(n.color),d=s.curve;d&&(r=eU(d,t,r,i,0,a,o,l.r,h.r,1),r=eU(d,t,r,i,1,a,o,l.g,h.g,1),r=eU(d,t,r,i,2,a,o,l.b,h.b,1)),a=o,l=h,s=n}n.push(t)}else if("alpha"==t)n.push(eL(e,new H(i,i,r),0,1));else if("rgba2"==t){let t=new J(i,7*i,r),s=e[0],a=eW(s,"time",0),l=y.fromString(s.light),o=y.fromString(s.dark);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,l.a,o.r,o.g,o.b);let n=e[i+1];if(!n){t.shrink(r);break}let h=eW(n,"time",0),d=y.fromString(n.light),c=y.fromString(n.dark),u=s.curve;u&&(r=eU(u,t,r,i,0,a,h,l.r,d.r,1),r=eU(u,t,r,i,1,a,h,l.g,d.g,1),r=eU(u,t,r,i,2,a,h,l.b,d.b,1),r=eU(u,t,r,i,3,a,h,l.a,d.a,1),r=eU(u,t,r,i,4,a,h,o.r,c.r,1),r=eU(u,t,r,i,5,a,h,o.g,c.g,1),r=eU(u,t,r,i,6,a,h,o.b,c.b,1)),a=h,l=d,o=c,s=n}n.push(t)}else if("rgb2"==t){let t=new K(i,6*i,r),s=e[0],a=eW(s,"time",0),l=y.fromString(s.light),o=y.fromString(s.dark);for(let i=0,r=0;;i++){t.setFrame(i,a,l.r,l.g,l.b,o.r,o.g,o.b);let n=e[i+1];if(!n){t.shrink(r);break}let h=eW(n,"time",0),d=y.fromString(n.light),c=y.fromString(n.dark),u=s.curve;u&&(r=eU(u,t,r,i,0,a,h,l.r,d.r,1),r=eU(u,t,r,i,1,a,h,l.g,d.g,1),r=eU(u,t,r,i,2,a,h,l.b,d.b,1),r=eU(u,t,r,i,3,a,h,o.r,c.r,1),r=eU(u,t,r,i,4,a,h,o.g,c.g,1),r=eU(u,t,r,i,5,a,h,o.b,c.b,1)),a=h,l=d,o=c,s=n}n.push(t)}}}if(e.bones)for(let s in e.bones){let i=e.bones[s],l=a.findBone(s);if(!l)throw Error("Bone not found: "+s);let o=l.index;for(let e in i){let s=i[e],a=s.length;if(0!=a){if("rotate"===e)n.push(eL(s,new _(a,a,o),0,1));else if("translate"===e){let t=new V(a,a<<1,o);n.push(eq(s,t,"x","y",0,r))}else if("translatex"===e){let t=new D(a,a,o);n.push(eL(s,t,0,r))}else if("translatey"===e){let t=new O(a,a,o);n.push(eL(s,t,0,r))}else if("scale"===e){let t=new N(a,a<<1,o);n.push(eq(s,t,"x","y",1,1))}else if("scalex"===e){let t=new L(a,a,o);n.push(eL(s,t,1,1))}else if("scaley"===e){let t=new q(a,a,o);n.push(eL(s,t,1,1))}else if("shear"===e){let t=new U(a,a<<1,o);n.push(eq(s,t,"x","y",0,1))}else if("shearx"===e){let t=new W(a,a,o);n.push(eL(s,t,0,1))}else if("sheary"===e){let t=new z(a,a,o);n.push(eL(s,t,0,1))}else if("inherit"===e){let e=new G(a,l.index);for(let i=0;i<s.length;i++){let a=s[i];e.setFrame(i,eW(a,"time",0),k.enumValue(t.Inherit,eW(a,"inherit","Normal")))}n.push(e)}}}}if(e.ik)for(let t in e.ik){let s=e.ik[t],i=s[0];if(!i)continue;let l=a.findIkConstraint(t);if(!l)throw Error("IK Constraint not found: "+t);let o=a.ikConstraints.indexOf(l),h=new ts(s.length,s.length<<1,o),d=eW(i,"time",0),c=eW(i,"mix",1),u=eW(i,"softness",0)*r;for(let t=0,e=0;;t++){h.setFrame(t,d,c,u,eW(i,"bendPositive",!0)?1:-1,eW(i,"compress",!1),eW(i,"stretch",!1));let a=s[t+1];if(!a){h.shrink(e);break}let n=eW(a,"time",0),l=eW(a,"mix",1),o=eW(a,"softness",0)*r,f=i.curve;f&&(e=eU(f,h,e,t,0,d,n,c,l,1),e=eU(f,h,e,t,1,d,n,u,o,r)),d=n,c=l,u=o,i=a}n.push(h)}if(e.transform)for(let t in e.transform){let s=e.transform[t],i=s[0];if(!i)continue;let r=a.findTransformConstraint(t);if(!r)throw Error("Transform constraint not found: "+t);let l=a.transformConstraints.indexOf(r),o=new ti(s.length,6*s.length,l),h=eW(i,"time",0),d=eW(i,"mixRotate",1),c=eW(i,"mixX",1),u=eW(i,"mixY",c),f=eW(i,"mixScaleX",1),m=eW(i,"mixScaleY",f),g=eW(i,"mixShearY",1);for(let t=0,e=0;;t++){o.setFrame(t,h,d,c,u,f,m,g);let a=s[t+1];if(!a){o.shrink(e);break}let r=eW(a,"time",0),n=eW(a,"mixRotate",1),l=eW(a,"mixX",1),p=eW(a,"mixY",l),x=eW(a,"mixScaleX",1),b=eW(a,"mixScaleY",x),y=eW(a,"mixShearY",1),w=i.curve;w&&(e=eU(w,o,e,t,0,h,r,d,n,1),e=eU(w,o,e,t,1,h,r,c,l,1),e=eU(w,o,e,t,2,h,r,u,p,1),e=eU(w,o,e,t,3,h,r,f,x,1),e=eU(w,o,e,t,4,h,r,m,b,1),e=eU(w,o,e,t,5,h,r,g,y,1)),h=r,d=n,c=l,u=p,f=x,m=b,f=x,i=a}n.push(o)}if(e.path)for(let s in e.path){let i=e.path[s],l=a.findPathConstraint(s);if(!l)throw Error("Path constraint not found: "+s);let o=a.pathConstraints.indexOf(l);for(let e in i){let s=i[e],a=s[0];if(!a)continue;let h=s.length;if("position"===e){let e=new ta(h,h,o);n.push(eL(s,e,0,l.positionMode==t.PositionMode.Fixed?r:1))}else if("spacing"===e){let e=new tr(h,h,o);n.push(eL(s,e,0,l.spacingMode==t.SpacingMode.Length||l.spacingMode==t.SpacingMode.Fixed?r:1))}else if("mix"===e){let t=new tn(h,3*h,o),e=eW(a,"time",0),i=eW(a,"mixRotate",1),r=eW(a,"mixX",1),l=eW(a,"mixY",r);for(let n=0,o=0;;n++){t.setFrame(n,e,i,r,l);let h=s[n+1];if(!h){t.shrink(o);break}let d=eW(h,"time",0),c=eW(h,"mixRotate",1),u=eW(h,"mixX",1),f=eW(h,"mixY",u),m=a.curve;m&&(o=eU(m,t,o,n,0,e,d,i,c,1),o=eU(m,t,o,n,1,e,d,r,u,1),o=eU(m,t,o,n,2,e,d,l,f,1)),e=d,i=c,r=u,l=f,a=h}n.push(t)}}}if(e.physics)for(let t in e.physics){let s=e.physics[t],i=-1;if(t.length>0){let e=a.findPhysicsConstraint(t);if(!e)throw Error("Physics constraint not found: "+t);i=a.physicsConstraints.indexOf(e)}for(let t in s){let e,a=s[t],r=a[0];if(!r)continue;let l=a.length;if("reset"==t){let t=new tg(l,i);for(let e=0;null!=r;r=a[e+1],e++)t.setFrame(e,eW(r,"time",0));n.push(t);continue}if("inertia"==t)e=new to(l,l,i);else if("strength"==t)e=new th(l,l,i);else if("damping"==t)e=new td(l,l,i);else if("mass"==t)e=new tc(l,l,i);else if("wind"==t)e=new tu(l,l,i);else if("gravity"==t)e=new tf(l,l,i);else{if("mix"!=t)continue;e=new tm(l,l,i)}n.push(eL(a,e,0,1))}}if(e.attachments)for(let t in e.attachments){let i=e.attachments[t],l=a.findSkin(t);if(!l)throw Error("Skin not found: "+t);for(let t in i){let e=i[t],o=a.findSlot(t);if(!o)throw Error("Slot not found: "+t);let h=o.index;for(let t in e){let i=e[t],a=l.getAttachment(h,t);for(let t in i){let e=i[t],l=e[0];if(l){if("deform"==t){let t=a.bones,s=a.vertices,i=t?s.length/3*2:s.length,o=new Z(e.length,e.length,h,a),d=eW(l,"time",0);for(let a=0,n=0;;a++){let h;let c=eW(l,"vertices",null);if(c){h=k.newFloatArray(i);let e=eW(l,"offset",0);if(k.arrayCopy(c,0,h,e,c.length),1!=r)for(let t=e,s=t+c.length;t<s;t++)h[t]*=r;if(!t)for(let t=0;t<i;t++)h[t]+=s[t]}else h=t?k.newFloatArray(i):s;o.setFrame(a,d,h);let u=e[a+1];if(!u){o.shrink(n);break}let f=eW(u,"time",0),m=l.curve;m&&(n=eU(m,o,n,a,0,d,f,0,1,1)),d=f,l=u}n.push(o)}else if("sequence"==t){let t=new tp(e.length,h,a),i=0;for(let a=0;a<e.length;a++){let r=eW(l,"delay",i),n=eW(l,"time",0),o=s[eW(l,"mode","hold")],h=eW(l,"index",0);t.setFrame(a,n,o,h,r),i=r,l=e[a+1]}n.push(t)}}}}}}if(e.drawOrder){let t=new te(e.drawOrder.length),s=a.slots.length,i=0;for(let r=0;r<e.drawOrder.length;r++,i++){let n=e.drawOrder[r],l=null,o=eW(n,"offsets",null);if(o){l=k.newArray(s,-1);let t=k.newArray(s-o.length,0),e=0,i=0;for(let s=0;s<o.length;s++){let r=o[s],n=a.findSlot(r.slot);if(!n)throw Error("Slot not found: "+n);let h=n.index;for(;e!=h;)t[i++]=e++;l[e+r.offset]=e++}for(;e<s;)t[i++]=e++;for(let e=s-1;e>=0;e--)-1==l[e]&&(l[e]=t[--i])}t.setFrame(i,eW(n,"time",0),l)}n.push(t)}if(e.events){let t=new tt(e.events.length),s=0;for(let i=0;i<e.events.length;i++,s++){let r=e.events[i],n=a.findEvent(r.name);if(!n)throw Error("Event not found: "+r.name);let l=new tz(k.toSinglePrecision(eW(r,"time",0)),n);l.intValue=eW(r,"int",n.intValue),l.floatValue=eW(r,"float",n.floatValue),l.stringValue=eW(r,"string",n.stringValue),l.data.audioPath&&(l.volume=eW(r,"volume",1),l.balance=eW(r,"balance",0)),t.setFrame(s,l)}n.push(t)}let l=0;for(let t=0,e=n.length;t<e;t++)l=Math.max(l,n[t].getDuration());a.animations.push(new E(i,n,l))}}class eN{parent;skin;slotIndex;mesh;inheritTimeline;constructor(t,e,s,i,a){this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i,this.inheritTimeline=a}}function eL(t,e,s,i){let a=t[0],r=eW(a,"time",0),n=eW(a,"value",s)*i,l=0;for(let o=0;;o++){e.setFrame(o,r,n);let h=t[o+1];if(!h)return e.shrink(l),e;let d=eW(h,"time",0),c=eW(h,"value",s)*i;a.curve&&(l=eU(a.curve,e,l,o,0,r,d,n,c,i)),r=d,n=c,a=h}}function eq(t,e,s,i,a,r){let n=t[0],l=eW(n,"time",0),o=eW(n,s,a)*r,h=eW(n,i,a)*r,d=0;for(let c=0;;c++){e.setFrame(c,l,o,h);let u=t[c+1];if(!u)return e.shrink(d),e;let f=eW(u,"time",0),m=eW(u,s,a)*r,g=eW(u,i,a)*r,p=n.curve;p&&(d=eU(p,e,d,c,0,l,f,o,m,r),d=eU(p,e,d,c,1,l,f,h,g,r)),l=f,o=m,h=g,n=u}}function eU(t,e,s,i,a,r,n,l,o,h){if("stepped"==t)return e.setStepped(i),s;let d=a<<2,c=t[d],u=t[d+1]*h,f=t[d+2],m=t[d+3]*h;return e.setBezier(s,i,a,r,l,c,u,f,m,n,o),s+1}function eW(t,e,s){return void 0!==t[e]?t[e]:s}function ez(t,e,s){let i=new tN(t);return"json"===s?new eO(i).readSkeletonData(e):new t4(i).readSkeletonData(new Uint8Array(e))}async function eG(t,s,i){let a;let r=t.map((t,a)=>{let r=s[a],n=e.AssetType.Texture2D;return"ktx"===r?n=e.AssetType.KTX:"ktx2"===r&&(n=e.AssetType.KTX2),eH(t,i,n)});try{a=await Promise.all(r)}catch(t){throw t}return a}async function e$(t,s){let i,a;let r=function(t){let e=new URL(t),s=e.origin+e.pathname;return s.endsWith("/")?s:s.substring(0,s.lastIndexOf("/")+1)}(t);try{i=await e.request(t,{type:"text"})}catch(e){throw Error(`Spine Atlas: ${t} load error: ${e}`)}let n=new tR(i),l=[];for(let t of n.pages){let e=r+t.name;l.push(eH(e,s))}try{a=await Promise.all(l)}catch(t){throw Error(`Spine Texture: load error: ${t}`)}return ej(i,a)}function ej(t,e){let s=new tR(t);return s.pages.forEach((t,s)=>{var i;let a=(i=e.find(e=>e.name===t.name)||e[s],new eJ(new Image,i));t.setTexture(a)}),s}function eH(t,s,i=e.AssetType.Texture2D){return s.resourceManager.load({url:t,type:i})}(()=>{if(void 0===Math.fround){var t;Math.fround=(t=new Float32Array(1),function(e){return t[0]=e,t[0]})}})();class eJ extends tC{constructor(t,e){super(t),this.texture=e,this.texture.generateMipmaps()}getImage(){return this.texture}setFilters(s,i){s===t.TextureFilter.Nearest?this.texture.filterMode=e.TextureFilterMode.Point:i===t.TextureFilter.MipMapLinearLinear?this.texture.filterMode=e.TextureFilterMode.Trilinear:this.texture.filterMode=e.TextureFilterMode.Bilinear}setWraps(t,e){this.texture.wrapModeU=this._convertWrapMode(t),this.texture.wrapModeV=this._convertWrapMode(e)}dispose(){}_convertWrapMode(s){switch(s){case t.TextureWrap.ClampToEdge:return e.TextureWrapMode.Clamp;case t.TextureWrap.Repeat:return e.TextureWrapMode.Repeat;case t.TextureWrap.MirroredRepeat:return e.TextureWrapMode.Mirror;default:throw Error("Unsupported texture wrap mode.")}}}class eK{constructor(t,e=1){this._type=t,this._lastElementIndex=e-1;let s=this._elements=Array(e);for(let i=0;i<e;++i)s[i]=new t}get(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]}return(t){this._elements[++this._lastElementIndex]=t}}class eQ{constructor(t){this._usedElementCount=0,this._type=t,this._elements=[]}get(){let{_usedElementCount:t,_elements:e}=this;if(this._usedElementCount++,e.length!==t)return e[t];{let t=new this._type;return e.push(t),t}}clear(){this._usedElementCount=0}}let{SourceAlpha:eZ,One:e0,DestinationColor:e1,Zero:e2,OneMinusSourceColor:e3,OneMinusSourceAlpha:e5}=e.BlendFactor,{Add:e6}=e.BlendOperation;function e8(e,s){let i=e.renderState.blendState.targetBlendState;switch(s){case t.BlendMode.Additive:i.sourceColorBlendFactor=eZ,i.destinationColorBlendFactor=e0,i.sourceAlphaBlendFactor=e0,i.destinationAlphaBlendFactor=e0,i.colorBlendOperation=i.alphaBlendOperation=e6;break;case t.BlendMode.Multiply:i.sourceColorBlendFactor=e1,i.destinationColorBlendFactor=e5,i.sourceAlphaBlendFactor=e0,i.destinationAlphaBlendFactor=e5,i.colorBlendOperation=i.alphaBlendOperation=e6;break;case t.BlendMode.Screen:i.sourceColorBlendFactor=e0,i.destinationColorBlendFactor=e3,i.sourceAlphaBlendFactor=e0,i.destinationAlphaBlendFactor=e3,i.colorBlendOperation=i.alphaBlendOperation=e6;break;default:i.sourceColorBlendFactor=eZ,i.destinationColorBlendFactor=e5,i.sourceAlphaBlendFactor=e0,i.destinationAlphaBlendFactor=e5,i.colorBlendOperation=i.alphaBlendOperation=e6}}class e4{}let e7=1/0,e9=-1/0;class st{static{this.QUAD_TRIANGLES=[0,1,2,2,3,0]}static{this.VERTEX_SIZE=8}static{this.VERTEX_STRIDE=9}static{this.tempDark=new y}static{this.tempColor=new y}static{this.tempVerts=Array(8)}static{this.tempBlendMode=null}static{this.tempTexture=null}static{this.subPrimitivePool=new eK(e.SubPrimitive)}static{this.subRenderItemPool=new eQ(e4)}static{this.bounds=new e.BoundingBox(new e.Vector3(e7,e7,e7),new e.Vector3(e9,e9,e9))}getMaxVertexCount(t){let e=new Set,{skins:s}=t,i=s.length;for(let t=0;t<i;t++){let i=s[t];this._collectUniqueAttachments(i,e)}return this._calculateTotalVertexCount(e)}buildPrimitive(e,s){let i,a;let{useClipping:r=!0,zSpacing:n=.01}=s.setting,{_clipper:l,_separateSlots:o,_subRenderItems:h,_separateSlotTextureMap:d}=this,{bounds:c}=st;c.min.set(e7,e7,e7),c.max.set(e9,e9,e9);let u=0,f=0,m=e.drawOrder,g=m.length,{engine:p,_indices:x,_vertices:b,_subPrimitives:y}=s,{tempVerts:w,tempTexture:M,tempBlendMode:S,subRenderItemPool:k,subPrimitivePool:I}=st;h.length=0,k.clear();let v=s._vertices,T=0,B=0,A=t.BlendMode.Normal,F=null,C=0;st.tempBlendMode=null,st.tempTexture=null;for(let t=0;t<g;++t){let e=m[t];if(!e.bone.active){l.clipEndWithSlot(e);continue}let s=e.getAttachment(),c=null,g=n*t,p=0,E=l.isClipping(),R=E?2:st.VERTEX_SIZE;if(!s){r&&l.clipEndWithSlot(e);continue}switch(s.constructor){case tO:c=s.color,p=4*R,s.computeWorldVertices(e,w,0,R),i=st.QUAD_TRIANGLES,a=s.uvs,F=s.region.texture;break;case t_:c=s.color,(p=(s.worldVerticesLength>>1)*R)>v.length&&(st.tempVerts=Array(p)),s.computeWorldVertices(e,0,s.worldVerticesLength,w,0,R),i=s.triangles,a=s.uvs,F=s.region.texture;break;case tF:r&&l.clipStart(e,s);continue;default:r&&l.clipEndWithSlot(e);continue}if(null!=F){let t,s,r,n;let m=e.bone.skeleton.color,v=e.color,Y=m.a*v.a*c.a,P=st.tempColor,X=st.tempDark;if(P.set(m.r*v.r*c.r,m.g*v.g*c.g,m.b*v.b*c.b,Y),E)l.clipTriangles(w,i,i.length,a,P,X,!1),s=(t=l.clippedVertices).length,n=(r=l.clippedTriangles).length;else{let{r:e,g:l,b:o,a:h}=P;for(let t=2,s=0,i=p;t<i;t+=R,s+=2)w[t]=e,w[t+1]=l,w[t+2]=o,w[t+3]=h,w[t+4]=a[s],w[t+5]=a[s+1];t=w,s=p,r=i,n=i.length}if(0==s||0==n){l.clipEndWithSlot(e);continue}let _=u/st.VERTEX_STRIDE,V=u,D=0;for(;D<s;){let e=t[D++],s=t[D++];b[V++]=e,b[V++]=s,b[V++]=g,b[V++]=t[D++],b[V++]=t[D++],b[V++]=t[D++],b[V++]=t[D++],b[V++]=t[D++],b[V++]=t[D++],this._expandByPoint(e,s,g)}for(u=V,V=f,D=0;D<n;V++,D++)x[V]=r[D]+_;f+=n;let O=e.data,N=O.name;A=O.blendMode;let L=null!==S&&S!==O.blendMode,q=null!==M&&M!==F,U=o.get(N);if(U||L||q){if(B>0){let t=y[C];t&&C++;let e=t||I.get();e.start=T,e.count=B;let s=k.get();s.subPrimitive=e,s.texture=M,s.blendMode=S,h.push(s),T+=B,B=0}if(U){let t=d.get(N);if(t){let e=F.texture;t.filterMode=e.filterMode,t.wrapModeU=e.wrapModeU,t.wrapModeV=e.wrapModeV}let e=y[C];e&&C++;let s=e||I.get();s.start=T,s.count=n;let i=k.get();i.blendMode=A,i.subPrimitive=s,i.texture=F,i.slotName=N,h.push(i),T+=n,B=0}else B+=n}else B+=n;M=F,S=A}l.clipEndWithSlot(e)}if(B>0){let t=y[C];t&&C++;let e=t||I.get();e.start=T,e.count=B;let s=k.get();s.blendMode=A,s.subPrimitive=e,s.texture=F,h.push(s),B=0}l.clipEnd();let E=y.length,R=h.length;if(R<E)for(let t=R;t<E;t++){let e=y[t];I.return(e)}s._clearSubPrimitives();for(let t=0;t<R;++t){let e=h[t],{slotName:i,blendMode:a,texture:r}=e;s._addSubPrimitive(e.subPrimitive);let n=r.texture;d.has(i)&&(n=d.get(i));let l=`${n.instanceId}_${a}`,o=ss._materialCache.get(l);o||(o=this._createMaterialForTexture(n,p,a),ss._materialCache.set(l,o)),s.setMaterial(t,o)}s._vertexBuffer.setData(b),s._indexBuffer.setData(x)}addSeparateSlot(t){this._separateSlots.set(t,t)}addSeparateSlotTexture(t,e){this._separateSlotTextureMap.set(t,e)}_createMaterialForTexture(t,e,s){let i=ss._getDefaultMaterial(e);return i.shaderData.setTexture("material_SpineTexture",t),e8(i,s),i}_expandByPoint(t,e,s){let{bounds:{min:i,max:a}}=st,r=Math.min(i.x,t),n=Math.min(i.y,e),l=Math.min(i.z,s),o=Math.max(a.x,t),h=Math.max(a.y,e),d=Math.max(a.z,s);i.set(r,n,l),a.set(o,h,d)}_collectUniqueAttachments(t,e){let{attachments:s}=t;for(let t=0,i=s.length;t<i;t++){let i=s[t];for(let t in i){let s=i[t];s&&!e.has(s)&&e.add(s)}}}_calculateTotalVertexCount(t){let e=0,s=st.QUAD_TRIANGLES.length;return t.forEach(t=>{t instanceof tO?e+=s:t instanceof t_&&(e+=t.triangles.length)}),e}constructor(){this._clipper=new eD,this._subRenderItems=[],this._separateSlots=new Map,this._separateSlotTextureMap=new Map}}class se extends e.Material{static{this._spineVS=`
|
|
2
|
+
uniform mat4 renderer_MVPMat;
|
|
3
|
+
|
|
4
|
+
attribute vec3 POSITION;
|
|
5
|
+
attribute vec2 TEXCOORD_0;
|
|
6
|
+
attribute vec4 COLOR_0;
|
|
7
|
+
|
|
8
|
+
varying vec2 v_uv;
|
|
9
|
+
varying vec4 v_color;
|
|
10
|
+
|
|
11
|
+
void main()
|
|
12
|
+
{
|
|
13
|
+
gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);
|
|
14
|
+
|
|
15
|
+
v_uv = TEXCOORD_0;
|
|
16
|
+
v_color = COLOR_0;
|
|
17
|
+
}
|
|
18
|
+
`}static{this._spineFS=`
|
|
19
|
+
uniform sampler2D material_SpineTexture;
|
|
20
|
+
|
|
21
|
+
varying vec2 v_uv;
|
|
22
|
+
varying vec4 v_color;
|
|
23
|
+
|
|
24
|
+
void main()
|
|
25
|
+
{
|
|
26
|
+
vec4 baseColor = texture2D(material_SpineTexture, v_uv);
|
|
27
|
+
gl_FragColor = baseColor * v_color;
|
|
28
|
+
}
|
|
29
|
+
`}constructor(s){super(s,e.Shader.find("galacean-spine-shader")||e.Shader.create("galacean-spine-shader",se._spineVS,se._spineFS));let i=this.renderState;i.blendState.targetBlendState.enabled=!0,e8(this,t.BlendMode.Normal),i.depthState.writeEnabled=!1,i.rasterState.cullMode=e.CullMode.Off,i.renderQueueType=e.RenderQueueType.Transparent}}class ss extends e.Renderer{static{this._spineGenerator=new st}static{this._positionVertexElement=new e.VertexElement("POSITION",0,e.VertexElementFormat.Vector3,0)}static{this._colorVertexElement=new e.VertexElement("COLOR_0",12,e.VertexElementFormat.Vector4,0)}static{this._uvVertexElement=new e.VertexElement("TEXCOORD_0",28,e.VertexElementFormat.Vector2,0)}static{this._materialCache=new Map}static{this._animationDataCache=new Map}static _getDefaultMaterial(t){let e=this._defaultMaterial;if(e){if(e.engine===t)return e.clone();e.destroy(!0),e=null}return(e=new se(t)).isGCIgnored=!0,this._defaultMaterial=e,e.clone()}get resource(){return this._resource}set resource(t){if(!t){this._state=null,this._skeleton=null,this._resource=null;return}this._resource=t,this._addResourceReferCount(t,1);let{skeletonData:e}=t;this._skeleton=new t0(e);let s=ss._animationDataCache.get(e);s||(s=new tB(e),ss._animationDataCache.set(e,s)),this._state=new tx(s);let i=ss._spineGenerator.getMaxVertexCount(e);this._createBuffer(i),this._initializeDefaultState(),this._dirtyUpdateFlag|=4,this._state.addListener({start:()=>{this._onAnimationStart()},complete:t=>{this._onAnimationComplete(t)}})}get state(){return this._state}get skeleton(){return this._skeleton}constructor(t){super(t),this.setting=new si,this.defaultState=new sa,this._subPrimitives=[],this._needResizeBuffer=!1,this._vertexCount=0;let s=new e.Primitive(this._engine);this._primitive=s,s.addVertexElement(ss._positionVertexElement),s.addVertexElement(ss._colorVertexElement),s.addVertexElement(ss._uvVertexElement)}addSeparateSlot(t){this._skeleton||console.error("Skeleton not found!"),this._skeleton.findSlot(t)?ss._spineGenerator.addSeparateSlot(t):console.warn(`Slot: ${t} not find.`)}_onEnable(){this._initializeDefaultState()}update(e){let{_state:s,_skeleton:i}=this;s&&i&&(s.update(e),s.apply(i),i.update(e),i.updateWorldTransform(t.Physics.update),ss._spineGenerator.buildPrimitive(this._skeleton,this),this._isContainDirtyFlag(4)&&(this._onWorldVolumeChanged(),this._setDirtyFlagFalse(4)),this._isContainDirtyFlag(2)&&this._calculateGeneratorBounds(this.bounds))}_render(t){let{_primitive:e,_subPrimitives:s}=this,{_materials:i,_engine:a}=this,r=a._renderElementPool.get();r.set(this.priority,this._distanceForSort);let n=a._subRenderElementPool;if(s){for(let t=0,a=s.length;t<a;t++){let a=i[t];if(!a)continue;(a.destroyed||a.shader.destroyed)&&(a=this.engine._meshMagentaMaterial);let l=n.get();l.set(this,a,e,s[t]),r.addSubRenderElement(l)}t.camera._renderPipeline.pushRenderElement(t,r)}}_updateBounds(t){this._calculateGeneratorBounds(t)}_calculateGeneratorBounds(t){let{bounds:s}=st;e.BoundingBox.transform(s,this.entity.transform.worldMatrix,t)}_cloneTo(t){t.resource=this._resource}_onDestroy(){let{_primitive:t,_subPrimitives:e,_resource:s}=this;e.length=0,t&&t.destroy(),s&&this._addResourceReferCount(s,-1),this._clearMaterialCache(),this._primitive=null,this._resource=null,this._skeleton=null,this._state=null,this.setting=null,super._onDestroy()}_createBuffer(t){let{_engine:s,_primitive:i}=this;this._vertices=new Float32Array(t*st.VERTEX_STRIDE),this._indices=new Uint16Array(t);let a=4*st.VERTEX_STRIDE,r=new e.Buffer(s,e.BufferBindFlag.VertexBuffer,this._vertices,e.BufferUsage.Dynamic),n=new e.Buffer(s,e.BufferBindFlag.IndexBuffer,this._indices,e.BufferUsage.Dynamic);this._indexBuffer=n,this._vertexBuffer=r;let l=new e.VertexBufferBinding(r,a);this._primitive.setVertexBufferBinding(0,l);let o=new e.IndexBufferBinding(n,e.IndexFormat.UInt16);i.setIndexBufferBinding(o)}_addSubPrimitive(t){this._subPrimitives.push(t)}_clearSubPrimitives(){this._subPrimitives.length=0}_isContainDirtyFlag(t){return(this._dirtyUpdateFlag&t)!=0}_setDirtyFlagFalse(t){this._dirtyUpdateFlag&=~t}_onWorldVolumeChanged(){this._dirtyUpdateFlag|=1}_onAnimationStart(){this._dirtyUpdateFlag|=2}_onAnimationComplete(t){t.loop||this._setDirtyFlagFalse(2)}_clearMaterialCache(){this._materials.forEach(e=>{let s=e.shaderData.getTexture("material_SpineTexture"),i=function(e){let s=e.renderState.blendState.targetBlendState;return s.sourceColorBlendFactor===eZ&&s.destinationColorBlendFactor===e0&&s.sourceAlphaBlendFactor===e0&&s.destinationAlphaBlendFactor===e0&&s.colorBlendOperation===e6&&s.alphaBlendOperation===e6?t.BlendMode.Additive:s.sourceColorBlendFactor===e1&&s.destinationColorBlendFactor===e2&&s.sourceAlphaBlendFactor===e0&&s.destinationAlphaBlendFactor===e2&&s.colorBlendOperation===e6&&s.alphaBlendOperation===e6?t.BlendMode.Multiply:s.sourceColorBlendFactor===e0&&s.destinationColorBlendFactor===e3&&s.sourceAlphaBlendFactor===e0&&s.destinationAlphaBlendFactor===e3&&s.colorBlendOperation===e6&&s.alphaBlendOperation===e6?t.BlendMode.Screen:t.BlendMode.Normal}(e),a=`${s.instanceId}_${i}`;ss._materialCache.delete(a)})}_initializeDefaultState(){let{skeleton:t,state:e}=this;if(t&&e){let{animationName:s,skinName:i,loop:a,scale:r}=this.defaultState;t.scaleX=r,t.scaleY=r,"default"!==i&&(t.setSkinByName(i),t.setToSetupPose()),s&&e.setAnimation(0,s,a)}}}x([e.deepClone],ss.prototype,"setting",void 0),x([e.deepClone],ss.prototype,"defaultState",void 0),x([e.ignoreClone],ss.prototype,"_primitive",void 0),x([e.ignoreClone],ss.prototype,"_subPrimitives",void 0),x([e.ignoreClone],ss.prototype,"_indexBuffer",void 0),x([e.ignoreClone],ss.prototype,"_vertexBuffer",void 0),x([e.ignoreClone],ss.prototype,"_vertices",void 0),x([e.ignoreClone],ss.prototype,"_indices",void 0),x([e.ignoreClone],ss.prototype,"_needResizeBuffer",void 0),x([e.ignoreClone],ss.prototype,"_vertexCount",void 0),x([e.ignoreClone],ss.prototype,"_resource",void 0),x([e.ignoreClone],ss.prototype,"_skeleton",void 0),x([e.ignoreClone],ss.prototype,"_state",void 0);class si{constructor(t=.01,e=!0){this.zSpacing=t,this.useClipping=e}}class sa{constructor(t=1,e=!0,s=null,i="default"){this.scale=t,this.loop=e,this.animationName=s,this.skinName=i}}class sr extends e.ReferResource{get skeletonData(){return this._skeletonData}constructor(t,e){super(t),this.textures=[],this._skeletonData=e,this._associationTextureInSkeletonData(e)}_onDestroy(){super._onDestroy();let{textures:t,_skeletonData:e}=this;t&&this._disassociationSuperResource(t),this._clearAttachmentTextures(e),ss._animationDataCache.delete(e),this._skeletonData=null}_disassociationSuperResource(t){for(let e=0,s=t.length;e<s;e++)t[e]._disassociationSuperResource(this)}_associationTextureInSkeletonData(t){let{skins:e}=t;e.forEach(t=>{let{attachments:e}=t;e.forEach(t=>{let e=Object.values(t)[0],s=e?.region?.texture.texture;s&&!this.textures.find(t=>t.instanceId===s.instanceId)&&(this.textures.push(s),s._associationSuperResource(this))})})}_clearAttachmentTextures(t){let{skins:e}=t;e.forEach(t=>{let{attachments:e}=t;e.forEach(t=>{let e=Object.values(t)[0];e?.region?.texture&&(e.region.texture.texture=null)})})}}class sn{constructor(t,e=0,s){this.data=t,this._dataView=new DataView(t.buffer,t.byteOffset+e,s??t.byteLength-e),this._position=0}nextUint16(){let t=this._dataView.getUint16(this._position,!0);return this._position+=2,t}nextStr(){let t=this.nextUint16(),e=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,t);return this._position+=t,this.decodeText(e)}nextImageData(){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)}decodeText(t){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(t);let e="";for(let s=0,i=t.length;s<i;s++)e+=String.fromCharCode(t[s]);return decodeURIComponent(encodeURIComponent(e))}}class sl extends e.Loader{static{this.imageExtensions=["png","jpg","webp","jpeg","ktx","ktx2"]}static{this.skeletonExtensions=["skel","json","bin"]}static parseAndAssignSpineAsset(t,e,s){let{imageExtensions:i,skeletonExtensions:a}=sl,r=sl.getUrlExtension(t,e);r&&(a.includes(r)&&(s.skeletonPath=t,s.skeletonExtension=r),"atlas"===r&&(s.atlasPath=t),i.includes(r)&&(s.imagePaths.push(t),s.imageExtensions.push(r)))}static deriveAndAssignSpineAsset(t,e,s){let i;let a=sl.getUrlExtension(t,e);if(!a)return;s.skeletonPath=t,s.skeletonExtension=a;let r=/(\.(json|bin|skel))$/;if(r.test(t)&&(i=t.replace(r,"")),i){let t=i+".atlas";s.atlasPath=t}}static verifyFileExtensions(t,e){return t?e&&!Array.isArray(t)?(console.error("Expect fileExtensions to be an array."),[]):e||"string"==typeof t?t:(console.error("Expect fileExtensions to be a string."),null):null}static getUrlExtension(t,e){if(e)return e;let s=t.match(/\/([^\/?#]+)\.([a-zA-Z0-9]+)(\?|#|$)|\?[^#]*\.([a-zA-Z0-9]+)(\?|#|$)/);return s?s[2]||s[4]:null}load(t,s){return new e.AssetPromise(async(e,i)=>{let a;try{if(t.urls)a=await this._handleOriginAsset(t,s);else{let e=await this.request(t.url,{type:"arraybuffer"}),i=new sn(new Uint8Array(e)),r=i.nextStr();a=r.startsWith("spine")?await this._handleEditorAsset(e,i,r,s):await this._handleOriginAsset(t,s,e)}}catch(t){i(t)}e(a)})}async _handleEditorAsset(t,e,s,i){let a,r,n;let l=s.startsWith("spine:skel")?"skel":"json",{engine:o}=i;if("skel"===l)r=e.nextStr(),a=e.nextImageData();else{let{data:e,atlas:s}=JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(t)));r=s.refId,a=e}try{n=await i.getResourceByRef({refId:r})}catch(t){throw t}return new sr(o,ez(n,a,l))}async _handleOriginAsset(t,e,s){let{fileExtensions:i}=t.params||{},a={skeletonPath:"",skeletonExtension:"",atlasPath:"",imagePaths:[],imageExtensions:[]},{engine:r}=e;if(s){let e;let n=sl.verifyFileExtensions(i,!1);sl.deriveAndAssignSpineAsset(t.url,n,a);let{skeletonPath:l,atlasPath:o}=a;if(!l||!o)throw Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");try{e=await e$(o,r)}catch(t){throw t}let{data:h,type:d}=this._determineSkeletonDataType(s);return new sr(r,ez(e,h,d))}{let e,s;i=sl.verifyFileExtensions(i,!0);for(let e=0;e<t.urls.length;e+=1){let s=t.urls[e],r=i&&i[e]||null;sl.parseAndAssignSpineAsset(s,r,a)}let{skeletonPath:n,atlasPath:l,imagePaths:o,skeletonExtension:h,imageExtensions:d}=a;if(!n||!l)throw Error("Failed to load spine assets. Please check the file path and ensure the file extension is included.");try{let t=["json"===h?this.request(n,{type:"text"}):this.request(n,{type:"arraybuffer"})];if(o.length>0){let i,a;t=t.concat([this.request(l,{type:"text"}),eG(o,d,r)]),[s,i,a]=await Promise.all(t),e=ej(i,a)}else t.push(e$(l,r)),[s,e]=await Promise.all(t)}catch(t){throw t}return new sr(r,ez(e,s,"json"===h?"json":"skel"))}}_determineSkeletonDataType(t){let e,s;try{let i=new TextDecoder("utf-8").decode(t);JSON.parse(i),e=i,s="json"}catch(i){e=t,s="skel"}return{data:e,type:s}}}sl=x([e.resourceLoader("spine",["json","bin","skel"])],sl);class so extends e.Loader{load(t,s){return new e.AssetPromise(async e=>{let{data:i,textures:a}=JSON.parse(await this.request(t.url,{type:"text"})),r=a.map(t=>s.getResourceByRef({refId:t.refId}));e(ej(i,await Promise.all(r)))})}}so=x([e.resourceLoader("EditorSpineAtlas",["atlas"])],so);let sh="0.0.0-experimental-engine-spine-caifu.1";e.Loader.registerClass("SpineAnimationRenderer",ss),console.log(`Galacean spine version: ${sh}`),t.AlphaTimeline=H,t.Animation=E,t.AnimationState=tx,t.AnimationStateAdapter=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},t.AnimationStateData=tB,t.AssetManagerBase=class{pathPrefix="";textureLoader;downloader;assets={};errors={};toLoad=0;loaded=0;constructor(t,e="",s=new tW){this.textureLoader=t,this.pathPrefix=e,this.downloader=s}start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,s){this.toLoad--,this.loaded++,this.assets[e]=s,t&&t(e,s)}error(t,e,s){this.toLoad--,this.loaded++,this.errors[e]=s,t&&t(e,s)}loadAll(){return new Promise((t,e)=>{let s=()=>{if(this.isLoadingComplete()){this.hasErrors()?e(this.errors):t(this);return}requestAnimationFrame(s)};requestAnimationFrame(s)})}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadBinary(t,s=>{this.success(e,t,s)},(e,i)=>{this.error(s,t,`Couldn't load binary ${t}: status ${e}, ${i}`)})}loadText(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadText(t,s=>{this.success(e,t,s)},(e,i)=>{this.error(s,t,`Couldn't load text ${t}: status ${e}, ${i}`)})}loadJson(t,e=()=>{},s=()=>{}){t=this.start(t),this.downloader.downloadJson(t,s=>{this.success(e,t,s)},(e,i)=>{this.error(s,t,`Couldn't load JSON ${t}: status ${e}, ${i}`)})}loadTexture(t,e=()=>{},s=()=>{}){if(t=this.start(t),"undefined"!=typeof window&&"undefined"!=typeof navigator&&window.document){let i=new Image;i.crossOrigin="anonymous",i.onload=()=>{this.success(e,t,this.textureLoader(i))},i.onerror=()=>{this.error(s,t,`Couldn't load image: ${t}`)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),i.src=t}else fetch(t,{mode:"cors"}).then(e=>e.ok?e.blob():(this.error(s,t,`Couldn't load image: ${t}`),null)).then(t=>t?createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(s=>{s&&this.success(e,t,this.textureLoader(s))})}loadTextureAtlas(t,e=()=>{},s=()=>{},i){let a=t.lastIndexOf("/"),r=a>=0?t.substring(0,a+1):"";t=this.start(t),this.downloader.downloadText(t,a=>{try{let n=new tR(a),l=n.pages.length,o=!1;for(let a of n.pages)this.loadTexture(i?i[a.name]:r+a.name,(s,i)=>{o||(a.setTexture(i),0==--l&&this.success(e,t,n))},(e,i)=>{o||this.error(s,t,`Couldn't load texture atlas ${t} page image: ${e}`),o=!0})}catch(e){this.error(s,t,`Couldn't parse texture atlas ${t}: ${e.message}`)}},(e,i)=>{this.error(s,t,`Couldn't load texture atlas ${t}: status ${e}, ${i}`)})}get(t){return this.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;let e=this.assets[t];if(e)return e;let s=this.errors[t];throw Error("Asset not found: "+t+(s?"\n"+s:""))}remove(t){t=this.pathPrefix+t;let e=this.assets[t];return e.dispose&&e.dispose(),delete this.assets[t],e}removeAll(){for(let t in this.assets){let e=this.assets[t];e.dispose&&e.dispose()}this.assets={}}isLoadingComplete(){return 0==this.toLoad}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},t.AtlasAttachmentLoader=tN,t.Attachment=B,t.AttachmentTimeline=Q,t.BinaryInput=t7,t.Bone=tq,t.BoneData=tL,t.BoundingBoxAttachment=tA,t.CURRENT=tT,t.ClippingAttachment=tF,t.Color=y,t.ConstraintData=tU,t.CurveTimeline=Y,t.CurveTimeline1=P,t.CurveTimeline2=X,t.DebugUtils=class{static logBones(t){for(let e=0;e<t.bones.length;e++){let s=t.bones[e];console.log(s.data.name+", "+s.a+", "+s.b+", "+s.c+", "+s.d+", "+s.worldX+", "+s.worldY)}}},t.DeformTimeline=Z,t.Downloader=tW,t.DrawOrderTimeline=te,t.Event=tz,t.EventData=tG,t.EventQueue=ty,t.EventTimeline=tt,t.FIRST=tM,t.FakeTexture=class extends tC{setFilters(t,e){}setWraps(t,e){}dispose(){}},t.HOLD_FIRST=tk,t.HOLD_MIX=tI,t.HOLD_SUBSEQUENT=tS,t.IkConstraint=t$,t.IkConstraintData=tj,t.IkConstraintTimeline=ts,t.InheritTimeline=G,t.IntSet=class{array=[];add(t){let e=this.contains(t);return this.array[0|t]=0|t,!e}contains(t){return void 0!=this.array[0|t]}remove(t){this.array[0|t]=void 0}clear(){this.array.length=0}},t.Interpolation=M,t.MathUtils=w,t.MeshAttachment=t_,t.PathAttachment=tV,t.PathConstraint=tJ,t.PathConstraintData=tH,t.PathConstraintMixTimeline=tn,t.PathConstraintPositionTimeline=ta,t.PathConstraintSpacingTimeline=tr,t.PhysicsConstraintDampingTimeline=td,t.PhysicsConstraintGravityTimeline=tf,t.PhysicsConstraintInertiaTimeline=to,t.PhysicsConstraintMassTimeline=tc,t.PhysicsConstraintMixTimeline=tm,t.PhysicsConstraintResetTimeline=tg,t.PhysicsConstraintStrengthTimeline=th,t.PhysicsConstraintTimeline=tl,t.PhysicsConstraintWindTimeline=tu,t.PointAttachment=tD,t.Pool=I,t.Pow=S,t.PowOut=class extends S{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}},t.RGB2Timeline=K,t.RGBA2Timeline=J,t.RGBATimeline=$,t.RGBTimeline=j,t.RegionAttachment=tO,t.RotateTimeline=_,t.SETUP=tv,t.SUBSEQUENT=tw,t.ScaleTimeline=N,t.ScaleXTimeline=L,t.ScaleYTimeline=q,t.SequenceTimeline=tp,t.ShearTimeline=U,t.ShearXTimeline=W,t.ShearYTimeline=z,t.Skeleton=t0,t.SkeletonBinary=t4,t.SkeletonBounds=e_,t.SkeletonClipping=eD,t.SkeletonData=t2,t.SkeletonDataResource=sr,t.SkeletonJson=eO,t.Skin=t5,t.SkinEntry=t3,t.Slot=tQ,t.SlotData=t6,t.SpineAnimationRenderer=ss,t.StringSet=b,t.Texture=tC,t.TextureAtlas=tR,t.TextureAtlasPage=tP,t.TextureAtlasRegion=tX,t.TextureRegion=tE,t.TimeKeeper=T,t.Timeline=R,t.TrackEntry=tb,t.TransformConstraint=tZ,t.TransformConstraintData=t8,t.TransformConstraintTimeline=ti,t.TranslateTimeline=V,t.TranslateXTimeline=D,t.TranslateYTimeline=O,t.Triangulator=eV,t.Utils=k,t.Vector2=v,t.VertexAttachment=A,t.WindowedMean=class{values;addedValues=0;lastValue=0;mean=0;dirty=!0;constructor(t=32){this.values=Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=t,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e<this.values.length;e++)t+=this.values[e];this.mean=t/this.values.length,this.dirty=!1}return this.mean}return 0}},t.createTextureAtlas=ej,t.version=sh,Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@galacean/engine")):"function"==typeof define&&define.amd?define(["exports","@galacean/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Galacean=t.Galacean||{},t.Galacean.Spine={}),t.Galacean);
|