@eva/plugin-renderer-spine36 2.0.1-beta.1 → 2.0.1-beta.2
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.
|
@@ -92,14 +92,15 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
92
92
|
onDestroy() {
|
|
93
93
|
this.destroied = true;
|
|
94
94
|
}
|
|
95
|
-
play(name,
|
|
95
|
+
play(name, loopAnimation, track) {
|
|
96
96
|
try {
|
|
97
|
+
const loop = loopAnimation !== null && loopAnimation !== void 0 ? loopAnimation : this.autoPlay;
|
|
97
98
|
if (name) this.animationName = name;
|
|
98
99
|
if (!this.armature) {
|
|
99
100
|
this.waitExecuteInfos.push({
|
|
100
101
|
playType: true,
|
|
101
102
|
name,
|
|
102
|
-
loop
|
|
103
|
+
loop,
|
|
103
104
|
track
|
|
104
105
|
});
|
|
105
106
|
} else {
|
|
@@ -396,7 +397,7 @@ var _EVA_IIFE_spine36 = function (exports, eva_js, pluginRenderer, pixi_js) {
|
|
|
396
397
|
});
|
|
397
398
|
const res = yield eva_js.resource.getResource(component.lastResource);
|
|
398
399
|
((_d = (_c = res.data) === null || _c === void 0 ? void 0 : _c.image) === null || _d === void 0 ? void 0 : _d.src) || ((_f = (_e = res.data) === null || _e === void 0 ? void 0 : _e.image) === null || _f === void 0 ? void 0 : _f.label);
|
|
399
|
-
|
|
400
|
+
releaseSpineData(res);
|
|
400
401
|
}
|
|
401
402
|
component.armature = null;
|
|
402
403
|
delete this.armatures[changed.gameObject.id];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_spine36=function(t,e,s,i){"use strict";function n(t){return function(e,s){var i=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,s);i.key=s,i.type=t}}function r(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 a(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{l(i.next(t))}catch(t){r(t)}}function o(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){t.done?n(t.value):new s((function(e){e(t.value)})).then(a,o)}l((i=i.apply(t,e||[])).next())}))}class o extends e.Component{constructor(){super(...arguments),this.resource="",this.scale=1,this.animationName="",this.autoPlay=!0,this.waitExecuteInfos=[]}set armature(t){if(this._armature=t,t){this.autoPlay&&this.play(this.animationName);for(const t of this.waitExecuteInfos)if(t.playType){const{name:e,loop:s,track:i}=t;this.play(e,s,i)}else this.stop(t.track);this.waitExecuteInfos=[]}}get armature(){return this._armature}init(t){t&&_extends(this,t)}onDestroy(){this.destroied=!0}play(t,e,s){try{t&&(this.animationName=t),this.armature?(void 0===s&&(s=0),this.armature.state.setAnimation(s,this.animationName,e)):this.waitExecuteInfos.push({playType:!0,name:t,loop:null!=e?e:this.autoPlay,track:s})}catch(t){console.log(t)}}stop(t){this.armature?(void 0===t&&(t=0),this.armature.state.setEmptyAnimation(t,0)):this.waitExecuteInfos.push({playType:!1,track:t})}addAnimation(t,e,s,i){try{this.armature&&(void 0===i&&(i=0),this.armature.state.addAnimation(i,t,s,e))}catch(t){console.log(t)}}setMix(t,e,s){this.armature&&this.armature.state.data.setMix(t,e,s)}getAnim(t=0){try{if(this.armature)return this.armature.state.tracks[t].animation.name}catch(t){console.log(t)}}setDefaultMix(t){this.armature&&(this.armature.state.data.defaultMix=t)}setAttachment(t,e){this.armature&&this.armature.skeleton.setAttachment(t,e)}getBone(t){if(this.armature)return this.armature.skeleton.findBone(t)}}o.componentName="Spine",r([n("string")],o.prototype,"resource",void 0),r([n("number")],o.prototype,"scale",void 0),r([n("string")],o.prototype,"animationName",void 0),r([n("boolean")],o.prototype,"autoPlay",void 0);let l={};function h(t,e,s){return a(this,void 0,void 0,(function*(){let i=l[t.name];if(!i)if(t.complete)i=function(t,e,s,i){const n=e.ske,r=e.atlas,a=new i.AtlasAttachmentLoader(r),o=n instanceof Uint8Array?new i.SkeletonBinary(a):new i.SkeletonJson(a);o.scale=s||1;const h={spineData:o.readSkeletonData(n),ref:0,imageSrc:e.image.label};return l[t]=h,h}(t.name,t.data,e,s);else if(!i)return;return i.ref++,i.spineData}))}let d=class extends s.Renderer{constructor(){super(...arguments),this.armatures={}}init({pixiSpine:t}){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=t,this.game.canvas.addEventListener("webglcontextrestored",(()=>{const t=this.game.gameObjects;let s=[];for(let i in this.armatures){const n=+i;for(let i=0;i<t.length;++i){let r=t[i];if(r.id===n){let t=r.getComponent(o);t&&(this.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:r,component:t,componentName:o.componentName}),s.push({type:e.OBSERVER_TYPE.ADD,gameObject:r,component:t,componentName:o.componentName}));break}}}setTimeout((()=>{s.forEach((t=>{this.add(t)}))}),1e3)}),!1)}update(t){for(let e in this.armatures)this.armatures[e].update(.001*t.deltaTime);super.update()}componentChanged(t){return a(this,void 0,void 0,(function*(){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t)}))}add(t,s){var i,n;return a(this,void 0,void 0,(function*(){const r=t.component;clearTimeout(r.addHandler);const a=t.gameObject.id,o=this.increaseAsyncId(a),l=yield e.resource.getResource(r.resource);if(!this.validateAsyncId(a,o))return;const d=yield h(l,r.scale,this.pixiSpine);if(!this.validateAsyncId(a,o))return;if(!d)return void(r.addHandler=setTimeout((()=>{r.destroied||(void 0===s&&(s=20),--s>0?this.add(t,s):console.log("retry exceed max times",r.resource))}),1e3));this.remove(t);const u=null===(n=null===(i=this.renderSystem)||void 0===i?void 0:i.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id);if(!u)return;r.lastResource=r.resource;const c=new this.pixiSpine.Spine({skeletonData:d,autoUpdate:!1});if(this.armatures[t.gameObject.id]=c,t.gameObject&&t.gameObject.transform){const e=t.gameObject.transform;c.x=e.size.width*e.origin.x,c.y=e.size.height*e.origin.y}u.addChildAt(c,0),c.update(),r.armature=c,r.emit("loaded",{resource:r.resource}),c.state.addListener({start:(t,e)=>{r.emit("start",{track:t,name:t.animation.name})},complete:(t,e)=>{r.emit("complete",{track:t,name:t.animation.name})},interrupt:(t,e)=>{r.emit("interrupt",{track:t,name:t.animation.name})},end:(t,e)=>{r.emit("end",{track:t,name:t.animation.name})},event:(t,e)=>{r.emit("event",t,e)}})}))}change(t){this.remove(t),this.add(t)}remove(t){var s,n,r,o,h,d;return a(this,void 0,void 0,(function*(){this.increaseAsyncId(t.gameObject.id);const u=t.component;clearTimeout(u.addHandler);const c=this.armatures[t.gameObject.id],p=null===(n=null===(s=this.renderSystem)||void 0===s?void 0:s.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id);if(p&&c&&p.removeChild(c),u.armature){u.armature.destroy({children:!0});const t=yield e.resource.getResource(u.lastResource);(null===(o=null===(r=t.data)||void 0===r?void 0:r.image)||void 0===o?void 0:o.src)||null===(d=null===(h=t.data)||void 0===h?void 0:h.image)||void 0===d||d.label,yield function(t){const s=t.name,n=l[s];n&&(n.ref--,setTimeout((()=>a(this,void 0,void 0,(function*(){if(n.ref<=0){yield i.Assets.unload([t.src.image.url,t.src.atlas.url,t.src.ske.url]);const n=i.Assets.resolver;delete n._assetMap[t.src.image.url],delete n._assetMap[t.src.atlas.url],delete n._assetMap[t.src.ske.url],delete n._resolverHash[t.src.image.url],delete n._resolverHash[t.src.atlas.url],delete n._resolverHash[t.src.ske.url],e.resource.destroy(s),delete l[s]}}))),100))}(t)}u.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE}))}};d.systemName="SpineSystem",d=r([e.decorators.componentObserver({Spine:["resource"]})],d);var u=d;e.resource.registerResourceType("SPINE");var c=Object.defineProperty,p=Object.defineProperties,m=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,w=(t,e,s)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,b=(t,e)=>{for(var s in e||(e={}))f.call(e,s)&&w(t,s,e[s]);if(g)for(var s of g(e))x.call(e,s)&&w(t,s,e[s]);return t},E=(t,e,s)=>w(t,"symbol"!=typeof e?e+"":e,s),y=(t,e,s)=>new Promise(((i,n)=>{var r=t=>{try{o(s.next(t))}catch(t){n(t)}},a=t=>{try{o(s.throw(t))}catch(t){n(t)}},o=t=>t.done?i(t.value):Promise.resolve(t.value).then(r,a);o((s=s.apply(t,e)).next())}));if("undefined"!=typeof window&&window.PIXI){const t=window.require;window.require=e=>t?t(e):e.startsWith("@pixi/")||e.startsWith("pixi.js")?window.PIXI:void 0}class T{constructor(t){if(E(this,"name"),null==t)throw new Error("name cannot be null.");this.name=t}}const A=class t extends T{constructor(e){super(e),E(this,"id",(65535&t.nextID++)<<11),E(this,"bones"),E(this,"vertices"),E(this,"worldVerticesLength",0)}computeWorldVertices(t,e,s,i,n,r){s=n+(s>>1)*r;let a=t.bone.skeleton,o=t.attachmentVertices,l=this.vertices,h=this.bones;if(null==h){o.length>0&&(l=o);let a=t.bone,h=a.worldX,d=a.worldY,u=a.a,c=a.b,p=a.c,m=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*u+s*c+h,i[a+1]=e*p+s*m+d}return}let d=0,u=0;for(let t=0;t<e;t+=2){let t=h[d];d+=t+1,u+=t}let c=a.bones;if(0==o.length)for(let t=n,e=3*u;t<s;t+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,e+=3){let t=c[h[d]],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*u,o=u<<1;e<s;e+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,a+=3,o+=2){let e=c[h[d]],i=l[a]+t[o],r=l[a+1]+t[o+1],u=l[a+2];s+=(i*e.a+r*e.b+e.worldX)*u,n+=(i*e.c+r*e.d+e.worldY)*u}i[e]=s,i[e+1]=n}}}applyDeform(t){return this==t}};E(A,"nextID",0);let C=A;class M{constructor(){E(this,"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}}const S=class{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(),this}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?255: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(),this}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}};E(S,"WHITE",new S(1,1,1,1)),E(S,"RED",new S(1,0,0,1)),E(S,"GREEN",new S(0,1,0,1)),E(S,"BLUE",new S(0,0,1,1)),E(S,"MAGENTA",new S(1,0,1,1));let v=S;const R=class t{static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(e){return Math.cos(e*t.degRad)}static sinDeg(e){return Math.sin(e*t.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){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(e,s){return t.randomTriangularWith(e,s,.5*(e+s))}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))}};E(R,"PI",3.1415927),E(R,"PI2",2*R.PI),E(R,"radiansToDegrees",180/R.PI),E(R,"radDeg",R.radiansToDegrees),E(R,"degreesToRadians",R.PI/180),E(R,"degRad",R.degreesToRadians);let P=R;class I{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class k extends I{constructor(t){super(),E(this,"power",2),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 V extends k{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}}const D=class t{static arrayCopy(t,e,s,i,n){for(let r=e,a=i;r<e+n;r++,a++)s[a]=t[r]}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(e,s,i=0){return e.length>=s?e:t.setArraySize(e,s,i)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static newShortArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static toFloatArray(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e}static toSinglePrecision(e){return t.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e}static webkit602BugfixHelper(t,e){}};E(D,"SUPPORTS_TYPED_ARRAYS","undefined"!=typeof Float32Array);let N=D;class _{constructor(t){E(this,"items",new Array),E(this,"instantiator"),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++)t[e].reset&&t[e].reset(),this.items[e]=t[e]}clear(){this.items.length=0}}class L{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 O{constructor(t,e,s){if(E(this,"name"),E(this,"timelines"),E(this,"duration"),null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=s}apply(t,e,s,i,n,r,a,o){if(null==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)}static binarySearch(t,e,s=1){let i=0,n=t.length/s-2;if(0==n)return s;let r=n>>>1;for(;;){if(t[(r+1)*s]<=e?i=r+1:n=r,i==n)return(i+1)*s;r=i+n>>>1}}static linearSearch(t,e,s){for(let i=0,n=t.length-s;i<=n;i+=s)if(t[i]>e)return i;return-1}}var Y,F,X,B=((Y=B||{})[Y.setup=0]="setup",Y[Y.current=1]="current",Y[Y.currentLayered=2]="currentLayered",Y),W=((F=W||{})[F.in=0]="in",F[F.out=1]="out",F),U=((X=U||{})[X.rotate=0]="rotate",X[X.translate=1]="translate",X[X.scale=2]="scale",X[X.shear=3]="shear",X[X.attachment=4]="attachment",X[X.color=5]="color",X[X.deform=6]="deform",X[X.event=7]="event",X[X.drawOrder=8]="drawOrder",X[X.ikConstraint=9]="ikConstraint",X[X.transformConstraint=10]="transformConstraint",X[X.pathConstraintPosition=11]="pathConstraintPosition",X[X.pathConstraintSpacing=12]="pathConstraintSpacing",X[X.pathConstraintMix=13]="pathConstraintMix",X[X.twoColor=14]="twoColor",X);const j=class t{constructor(e){if(E(this,"curves"),e<=0)throw new Error("frameCount must be > 0: "+e);this.curves=N.newFloatArray((e-1)*t.BEZIER_SIZE)}getFrameCount(){return this.curves.length/t.BEZIER_SIZE+1}setLinear(e){this.curves[e*t.BEZIER_SIZE]=t.LINEAR}setStepped(e){this.curves[e*t.BEZIER_SIZE]=t.STEPPED}getCurveType(e){let s=e*t.BEZIER_SIZE;if(s==this.curves.length)return t.LINEAR;let i=this.curves[s];return i==t.LINEAR?t.LINEAR:i==t.STEPPED?t.STEPPED:t.BEZIER}setCurve(e,s,i,n,r){let a=.03*(2*-s+n),o=.03*(2*-i+r),l=.006*(3*(s-n)+1),h=.006*(3*(i-r)+1),d=2*a+l,u=2*o+h,c=.3*s+a+.16666667*l,p=.3*i+o+.16666667*h,m=e*t.BEZIER_SIZE,g=this.curves;g[m++]=t.BEZIER;let f=c,x=p;for(let e=m+t.BEZIER_SIZE-1;m<e;m+=2)g[m]=f,g[m+1]=x,c+=d,p+=u,d+=l,u+=h,f+=c,x+=p}getCurvePercent(e,s){s=P.clamp(s,0,1);let i=this.curves,n=e*t.BEZIER_SIZE,r=i[n];if(r==t.LINEAR)return s;if(r==t.STEPPED)return 0;n++;let a=0;for(let e=n,r=n+t.BEZIER_SIZE-1;n<r;n+=2)if(a=i[n],a>=s){let t,r;return n==e?(t=0,r=0):(t=i[n-2],r=i[n-1]),r+(i[n+1]-r)*(s-t)/(a-t)}let o=i[n-1];return o+(1-o)*(s-a)/(1-a)}};E(j,"LINEAR",0),E(j,"STEPPED",1),E(j,"BEZIER",2),E(j,"BEZIER_SIZE",19);let q=j;const G=class t extends q{constructor(t){super(t),E(this,"boneIndex"),E(this,"frames"),this.frames=N.newFloatArray(t<<1)}getPropertyId(){return 0+this.boneIndex}setFrame(e,s,i){e<<=1,this.frames[e]=s,this.frames[e+t.ROTATION]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return void(h.rotation=h.data.rotation);case 1:let t=h.data.rotation-h.rotation;t-=360*(16384-(16384.499999999996-t/360|0)),h.rotation+=t*r}return}if(i>=l[l.length-t.ENTRIES]){if(0==a)h.rotation=h.data.rotation+l[l.length+t.PREV_ROTATION]*r;else{let e=h.data.rotation+l[l.length+t.PREV_ROTATION]-h.rotation;e-=360*(16384-(16384.499999999996-e/360|0)),h.rotation+=e*r}return}let d=O.binarySearch(l,i,t.ENTRIES),u=l[d+t.PREV_ROTATION],c=l[d],p=this.getCurvePercent((d>>1)-1,1-(i-c)/(l[d+t.PREV_TIME]-c)),m=l[d+t.ROTATION]-u;m-=360*(16384-(16384.499999999996-m/360|0)),m=u+m*p,0==a?(m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation=h.data.rotation+m*r):(m=h.data.rotation+m-h.rotation,m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation+=m*r)}};E(G,"ENTRIES",2),E(G,"PREV_TIME",-2),E(G,"PREV_ROTATION",-1),E(G,"ROTATION",1);let $=G;const z=class t extends q{constructor(e){super(e),E(this,"boneIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(1<<24)+this.boneIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.X]=i,this.frames[e+t.Y]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return h.x=h.data.x,void(h.y=h.data.y);case 1:h.x+=(h.data.x-h.x)*r,h.y+=(h.data.y-h.y)*r}return}let d=0,u=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_X],u=l[l.length+t.PREV_Y];else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_X],u=l[e+t.PREV_Y];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.X]-d)*n,u+=(l[e+t.Y]-u)*n}0==a?(h.x=h.data.x+d*r,h.y=h.data.y+u*r):(h.x+=(h.data.x+d-h.x)*r,h.y+=(h.data.y+u-h.y)*r)}};E(z,"ENTRIES",3),E(z,"PREV_TIME",-3),E(z,"PREV_X",-2),E(z,"PREV_Y",-1),E(z,"X",1),E(z,"Y",2);let H=z;class Z extends H{constructor(t){super(t)}getPropertyId(){return(2<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.scaleX=l.data.scaleX,void(l.scaleY=l.data.scaleY);case 1:l.scaleX+=(l.data.scaleX-l.scaleX)*n,l.scaleY+=(l.data.scaleY-l.scaleY)*n}return}let h=0,d=0;if(s>=o[o.length-Z.ENTRIES])h=o[o.length+Z.PREV_X]*l.data.scaleX,d=o[o.length+Z.PREV_Y]*l.data.scaleY;else{let t=O.binarySearch(o,s,Z.ENTRIES);h=o[t+Z.PREV_X],d=o[t+Z.PREV_Y];let e=o[t],i=this.getCurvePercent(t/Z.ENTRIES-1,1-(s-e)/(o[t+Z.PREV_TIME]-e));h=(h+(o[t+Z.X]-h)*i)*l.data.scaleX,d=(d+(o[t+Z.Y]-d)*i)*l.data.scaleY}if(1==n)l.scaleX=h,l.scaleY=d;else{let t=0,e=0;0==r?(t=l.data.scaleX,e=l.data.scaleY):(t=l.scaleX,e=l.scaleY),1==a?(h=Math.abs(h)*P.signum(t),d=Math.abs(d)*P.signum(e)):(t=Math.abs(t)*P.signum(h),e=Math.abs(e)*P.signum(d)),l.scaleX=t+(h-t)*n,l.scaleY=e+(d-e)*n}}}class J extends H{constructor(t){super(t)}getPropertyId(){return(3<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case 1:l.shearX+=(l.data.shearX-l.shearX)*n,l.shearY+=(l.data.shearY-l.shearY)*n}return}let h=0,d=0;if(s>=o[o.length-J.ENTRIES])h=o[o.length+J.PREV_X],d=o[o.length+J.PREV_Y];else{let t=O.binarySearch(o,s,J.ENTRIES);h=o[t+J.PREV_X],d=o[t+J.PREV_Y];let e=o[t],i=this.getCurvePercent(t/J.ENTRIES-1,1-(s-e)/(o[t+J.PREV_TIME]-e));h+=(o[t+J.X]-h)*i,d+=(o[t+J.Y]-d)*i}0==r?(l.shearX=l.data.shearX+h*n,l.shearY=l.data.shearY+d*n):(l.shearX+=(l.data.shearX+h-l.shearX)*n,l.shearY+=(l.data.shearY+d-l.shearY)*n)}}const Q=class t extends q{constructor(e){super(e),E(this,"slotIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(5<<24)+this.slotIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return void l.color.setFromColor(l.data.color);case 1:let t=l.color,e=l.data.color;t.add((e.r-t.r)*r,(e.g-t.g)*r,(e.b-t.b)*r,(e.a-t.a)*r)}return}let d=0,u=0,c=0,p=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A]}else{let e=O.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,u+=(h[e+t.G]-u)*n,c+=(h[e+t.B]-c)*n,p+=(h[e+t.A]-p)*n}if(1==r)l.color.set(d,u,c,p);else{let t=l.color;0==a&&t.setFromColor(l.data.color),t.add((d-t.r)*r,(u-t.g)*r,(c-t.b)*r,(p-t.a)*r)}}};E(Q,"ENTRIES",5),E(Q,"PREV_TIME",-5),E(Q,"PREV_R",-4),E(Q,"PREV_G",-3),E(Q,"PREV_B",-2),E(Q,"PREV_A",-1),E(Q,"R",1),E(Q,"G",2),E(Q,"B",3),E(Q,"A",4);let K=Q;const tt=class t extends q{constructor(e){super(e),E(this,"slotIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(14<<24)+this.slotIndex}setFrame(e,s,i,n,r,a,o,l,h){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a,this.frames[e+t.R2]=o,this.frames[e+t.G2]=l,this.frames[e+t.B2]=h}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return l.color.setFromColor(l.data.color),void l.darkColor.setFromColor(l.data.darkColor);case 1:let t=l.color,e=l.darkColor,s=l.data.color,i=l.data.darkColor;t.add((s.r-t.r)*r,(s.g-t.g)*r,(s.b-t.b)*r,(s.a-t.a)*r),e.add((i.r-e.r)*r,(i.g-e.g)*r,(i.b-e.b)*r,0)}return}let d=0,u=0,c=0,p=0,m=0,g=0,f=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2]}else{let e=O.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,u+=(h[e+t.G]-u)*n,c+=(h[e+t.B]-c)*n,p+=(h[e+t.A]-p)*n,m+=(h[e+t.R2]-m)*n,g+=(h[e+t.G2]-g)*n,f+=(h[e+t.B2]-f)*n}if(1==r)l.color.set(d,u,c,p),l.darkColor.set(m,g,f,1);else{let t=l.color,e=l.darkColor;0==a&&(t.setFromColor(l.data.color),e.setFromColor(l.data.darkColor)),t.add((d-t.r)*r,(u-t.g)*r,(c-t.b)*r,(p-t.a)*r),e.add((m-e.r)*r,(g-e.g)*r,(f-e.b)*r,0)}}};E(tt,"ENTRIES",8),E(tt,"PREV_TIME",-8),E(tt,"PREV_R",-7),E(tt,"PREV_G",-6),E(tt,"PREV_B",-5),E(tt,"PREV_A",-4),E(tt,"PREV_R2",-3),E(tt,"PREV_G2",-2),E(tt,"PREV_B2",-1),E(tt,"R",1),E(tt,"G",2),E(tt,"B",3),E(tt,"A",4),E(tt,"R2",5),E(tt,"G2",6),E(tt,"B2",7);let et=tt;class st{constructor(t){E(this,"slotIndex"),E(this,"frames"),E(this,"attachmentNames"),this.frames=N.newFloatArray(t),this.attachmentNames=new Array(t)}getPropertyId(){return(4<<24)+this.slotIndex}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex];if(1==a&&0==r){let e=o.data.attachmentName;return void o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}let l=this.frames;if(s<l[0]){if(0==r){let e=o.data.attachmentName;o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}return}let h=0;h=s>=l[l.length-1]?l.length-1:O.binarySearch(l,s,1)-1;let d=this.attachmentNames[h];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}var it=null;class nt extends q{constructor(t){super(t),E(this,"slotIndex"),E(this,"attachment"),E(this,"frames"),E(this,"frameVertices"),this.frames=N.newFloatArray(t),this.frameVertices=new Array(t),null==it&&(it=N.newFloatArray(64))}getPropertyId(){return(6<<27)+ +this.attachment.id+this.slotIndex}setFrame(t,e,s){this.frames[t]=e,this.frameVertices[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex],l=o.getAttachment();if(!(l instanceof C&&l.applyDeform(this.attachment)))return;let h=o.attachmentVertices;0==h.length&&(n=1);let d=this.frameVertices,u=d[0].length,c=this.frames;if(s<c[0]){let t=l;switch(r){case 0:return void(h.length=0);case 1:if(1==n){h.length=0;break}let e=N.setArraySize(h,u);if(null==t.bones)for(var p=t.vertices,m=0;m<u;m++)e[m]+=(p[m]-e[m])*n;else{n=1-n;for(m=0;m<u;m++)e[m]*=n}}return}let g=N.setArraySize(h,u);if(s>=c[c.length-1]){let t=d[c.length-1];if(1==n)N.arrayCopy(t,0,g,0,u);else if(0==r){let e=l;if(null==e.bones){let s=e.vertices;for(let e=0;e<u;e++){let i=s[e];g[e]=i+(t[e]-i)*n}}else for(let e=0;e<u;e++)g[e]=t[e]*n}else for(let e=0;e<u;e++)g[e]+=(t[e]-g[e])*n;return}let f=O.binarySearch(c,s),x=d[f-1],w=d[f],b=c[f],E=this.getCurvePercent(f-1,1-(s-b)/(c[f-1]-b));if(1==n)for(let t=0;t<u;t++){let e=x[t];g[t]=e+(w[t]-e)*E}else if(0==r){let t=l;if(null==t.bones){let e=t.vertices;for(let t=0;t<u;t++){let s=x[t],i=e[t];g[t]=i+(s+(w[t]-s)*E-i)*n}}else for(let t=0;t<u;t++){let e=x[t];g[t]=(e+(w[t]-e)*E)*n}}else for(let t=0;t<u;t++){let e=x[t];g[t]+=(e+(w[t]-e)*E-g[t])*n}}}class rt{constructor(t){E(this,"frames"),E(this,"events"),this.frames=N.newFloatArray(t),this.events=new Array(t)}getPropertyId(){return 7<<24}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(null==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=O.binarySearch(o,e);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 at{constructor(t){E(this,"frames"),E(this,"drawOrders"),this.frames=N.newFloatArray(t),this.drawOrders=new Array(t)}getPropertyId(){return 8<<24}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(t,e,s,i,n,r,a){let o=t.drawOrder,l=t.slots;if(1==a&&0==r)return void N.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length);let h=this.frames;if(s<h[0])return void(0==r&&N.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length));let d=0;d=s>=h[h.length-1]?h.length-1:O.binarySearch(h,s)-1;let u=this.drawOrders[d];if(null==u)N.arrayCopy(l,0,o,0,l.length);else for(let t=0,e=u.length;t<e;t++)o[t]=l[u[t]]}}const ot=class t extends q{constructor(e){super(e),E(this,"ikConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(9<<24)+this.ikConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.MIX]=i,this.frames[e+t.BEND_DIRECTION]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.ikConstraints[this.ikConstraintIndex];if(i<l[0]){switch(a){case 0:return h.mix=h.data.mix,void(h.bendDirection=h.data.bendDirection);case 1:h.mix+=(h.data.mix-h.mix)*r,h.bendDirection=h.data.bendDirection}return}if(i>=l[l.length-t.ENTRIES])return void(0==a?(h.mix=h.data.mix+(l[l.length+t.PREV_MIX]-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[l.length+t.PREV_BEND_DIRECTION]):(h.mix+=(l[l.length+t.PREV_MIX]-h.mix)*r,0==o&&(h.bendDirection=l[l.length+t.PREV_BEND_DIRECTION])));let d=O.binarySearch(l,i,t.ENTRIES),u=l[d+t.PREV_MIX],c=l[d],p=this.getCurvePercent(d/t.ENTRIES-1,1-(i-c)/(l[d+t.PREV_TIME]-c));0==a?(h.mix=h.data.mix+(u+(l[d+t.MIX]-u)*p-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[d+t.PREV_BEND_DIRECTION]):(h.mix+=(u+(l[d+t.MIX]-u)*p-h.mix)*r,0==o&&(h.bendDirection=l[d+t.PREV_BEND_DIRECTION]))}};E(ot,"ENTRIES",3),E(ot,"PREV_TIME",-3),E(ot,"PREV_MIX",-2),E(ot,"PREV_BEND_DIRECTION",-1),E(ot,"MIX",1),E(ot,"BEND_DIRECTION",2);let lt=ot;const ht=class t extends q{constructor(e){super(e),E(this,"transformConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(10<<24)+this.transformConstraintIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n,this.frames[e+t.SCALE]=r,this.frames[e+t.SHEAR]=a}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.transformConstraints[this.transformConstraintIndex];if(i<l[0]){let t=h.data;switch(a){case 0:return h.rotateMix=t.rotateMix,h.translateMix=t.translateMix,h.scaleMix=t.scaleMix,void(h.shearMix=t.shearMix);case 1:h.rotateMix+=(t.rotateMix-h.rotateMix)*r,h.translateMix+=(t.translateMix-h.translateMix)*r,h.scaleMix+=(t.scaleMix-h.scaleMix)*r,h.shearMix+=(t.shearMix-h.shearMix)*r}return}let d=0,u=0,c=0,p=0;if(i>=l[l.length-t.ENTRIES]){let e=l.length;d=l[e+t.PREV_ROTATE],u=l[e+t.PREV_TRANSLATE],c=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR]}else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],u=l[e+t.PREV_TRANSLATE],c=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,u+=(l[e+t.TRANSLATE]-u)*n,c+=(l[e+t.SCALE]-c)*n,p+=(l[e+t.SHEAR]-p)*n}if(0==a){let t=h.data;h.rotateMix=t.rotateMix+(d-t.rotateMix)*r,h.translateMix=t.translateMix+(u-t.translateMix)*r,h.scaleMix=t.scaleMix+(c-t.scaleMix)*r,h.shearMix=t.shearMix+(p-t.shearMix)*r}else h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(u-h.translateMix)*r,h.scaleMix+=(c-h.scaleMix)*r,h.shearMix+=(p-h.shearMix)*r}};E(ht,"ENTRIES",5),E(ht,"PREV_TIME",-5),E(ht,"PREV_ROTATE",-4),E(ht,"PREV_TRANSLATE",-3),E(ht,"PREV_SCALE",-2),E(ht,"PREV_SHEAR",-1),E(ht,"ROTATE",1),E(ht,"TRANSLATE",2),E(ht,"SCALE",3),E(ht,"SHEAR",4);let dt=ht;const ut=class t extends q{constructor(e){super(e),E(this,"pathConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(11<<24)+this.pathConstraintIndex}setFrame(e,s,i){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.VALUE]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return void(h.position=h.data.position);case 1:h.position+=(h.data.position-h.position)*r}return}let d=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_VALUE];else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_VALUE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.VALUE]-d)*n}0==a?h.position=h.data.position+(d-h.data.position)*r:h.position+=(d-h.position)*r}};E(ut,"ENTRIES",2),E(ut,"PREV_TIME",-2),E(ut,"PREV_VALUE",-1),E(ut,"VALUE",1);let ct=ut;class pt extends ct{constructor(t){super(t)}getPropertyId(){return(12<<24)+this.pathConstraintIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(s<o[0]){switch(r){case 0:return void(l.spacing=l.data.spacing);case 1:l.spacing+=(l.data.spacing-l.spacing)*n}return}let h=0;if(s>=o[o.length-pt.ENTRIES])h=o[o.length+pt.PREV_VALUE];else{let t=O.binarySearch(o,s,pt.ENTRIES);h=o[t+pt.PREV_VALUE];let e=o[t],i=this.getCurvePercent(t/pt.ENTRIES-1,1-(s-e)/(o[t+pt.PREV_TIME]-e));h+=(o[t+pt.VALUE]-h)*i}0==r?l.spacing=l.data.spacing+(h-l.data.spacing)*n:l.spacing+=(h-l.spacing)*n}}const mt=class t extends q{constructor(e){super(e),E(this,"pathConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(13<<24)+this.pathConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return h.rotateMix=h.data.rotateMix,void(h.translateMix=h.data.translateMix);case 1:h.rotateMix+=(h.data.rotateMix-h.rotateMix)*r,h.translateMix+=(h.data.translateMix-h.translateMix)*r}return}let d=0,u=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_ROTATE],u=l[l.length+t.PREV_TRANSLATE];else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],u=l[e+t.PREV_TRANSLATE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,u+=(l[e+t.TRANSLATE]-u)*n}0==a?(h.rotateMix=h.data.rotateMix+(d-h.data.rotateMix)*r,h.translateMix=h.data.translateMix+(u-h.data.translateMix)*r):(h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(u-h.translateMix)*r)}};E(mt,"ENTRIES",3),E(mt,"PREV_TIME",-3),E(mt,"PREV_ROTATE",-2),E(mt,"PREV_TRANSLATE",-1),E(mt,"ROTATE",1),E(mt,"TRANSLATE",2);let gt=mt;const ft=class t{constructor(t){E(this,"data"),E(this,"tracks",new Array),E(this,"events",new Array),E(this,"listeners",new Array),E(this,"queue",new bt(this)),E(this,"propertyIDs",new M),E(this,"mixingTo",new Array),E(this,"animationsChanged",!1),E(this,"timeScale",1),E(this,"trackEntryPool",new _((()=>new wt))),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(null==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(null!=r){let e=i.trackLast-r.delay;if(e>=0){for(r.delay=0,r.trackTime=e+t*r.timeScale,i.trackTime+=n,this.setCurrent(s,r,!0);null!=r.mixingFrom;)r.mixTime+=n,r=r.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&null==i.mixingFrom){e[s]=null,this.queue.end(i),this.disposeNext(i);continue}if(null!=i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null;null!=t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(null==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==t.timeScale)?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e*t.timeScale,!1)}apply(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let r=0,a=i.length;r<a;r++){let a=i[r];if(null==a||a.delay>0)continue;n=!0;let o=0==r?B.current:B.currentLayered,l=a.alpha;null!=a.mixingFrom?l*=this.applyMixingFrom(a,e,o):a.trackTime>=a.trackEnd&&null==a.next&&(l=0);let h=a.animationLast,d=a.getAnimationTime(),u=a.animation.timelines.length,c=a.animation.timelines;if(1==l)for(let t=0;t<u;t++)c[t].apply(e,h,d,s,1,B.setup,W.in);else{let i=a.timelineData,n=0==a.timelinesRotation.length;n&&N.setArraySize(a.timelinesRotation,u<<1,null);let r=a.timelinesRotation;for(let a=0;a<u;a++){let u=c[a],p=i[a]>=t.FIRST?B.setup:o;u instanceof $?this.applyRotateTimeline(u,e,d,l,p,r,a<<1,n):(N.webkit602BugfixHelper(l,p),u.apply(e,h,d,s,l,p,W.in))}}this.queueEvents(a,d),s.length=0,a.nextAnimationLast=d,a.nextTrackLast=a.trackTime}return this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;null!=n.mixingFrom&&this.applyMixingFrom(n,s,i);let r=0;0==e.mixDuration?(r=1,i=B.setup):(r=e.mixTime/e.mixDuration,r>1&&(r=1));let a=r<n.eventThreshold?this.events:null,o=r<n.attachmentThreshold,l=r<n.drawOrderThreshold,h=n.animationLast,d=n.getAnimationTime(),u=n.animation.timelines.length,c=n.animation.timelines,p=n.timelineData,m=n.timelineDipMix,g=0==n.timelinesRotation.length;g&&N.setArraySize(n.timelinesRotation,u<<1,null);let f,x=n.timelinesRotation,w=n.alpha*e.interruptAlpha,b=w*(1-r),E=0;n.totalAlpha=0;for(var y=0;y<u;y++){let e=c[y];switch(p[y]){case t.SUBSEQUENT:if(!o&&e instanceof st)continue;if(!l&&e instanceof at)continue;f=i,E=b;break;case t.FIRST:f=B.setup,E=b;break;case t.DIP:f=B.setup,E=w;break;default:f=B.setup,E=w;let s=m[y];E*=Math.max(0,1-s.mixTime/s.mixDuration)}n.totalAlpha+=E,e instanceof $?this.applyRotateTimeline(e,s,d,E,f,x,y<<1,g):(N.webkit602BugfixHelper(E,f),e.apply(s,h,d,a,E,f,W.out))}return e.mixDuration>0&&this.queueEvents(n,d),this.events.length=0,n.nextAnimationLast=d,n.nextTrackLast=n.trackTime,r}applyRotateTimeline(t,e,s,i,n,r,a,o){if(o&&(r[a]=0),1==i)return void t.apply(e,0,s,null,1,n,W.in);let l=t,h=l.frames,d=e.bones[l.boneIndex];if(s<h[0])return void(n==B.setup&&(d.rotation=d.data.rotation));let u=0;if(s>=h[h.length-$.ENTRIES])u=d.data.rotation+h[h.length+$.PREV_ROTATION];else{let t=O.binarySearch(h,s,$.ENTRIES),e=h[t+$.PREV_ROTATION],i=h[t],n=l.getCurvePercent((t>>1)-1,1-(s-i)/(h[t+$.PREV_TIME]-i));u=h[t+$.ROTATION]-e,u-=360*(16384-(16384.499999999996-u/360|0)),u=e+u*n+d.data.rotation,u-=360*(16384-(16384.499999999996-u/360|0))}let c=n==B.setup?d.data.rotation:d.rotation,p=0,m=u-c;if(0==m)p=r[a];else{m-=360*(16384-(16384.499999999996-m/360|0));let t=0,e=0;o?(t=0,e=m):(t=r[a],e=r[a+1]);let s=m>0,i=t>=0;P.signum(e)!=P.signum(m)&&Math.abs(e)<=90&&(Math.abs(t)>180&&(t+=360*P.signum(t)),i=s),p=m+t-t%360,i!=s&&(p+=360*P.signum(t)),r[a]=p}r[a+1]=m,c+=p*i,d.rotation=c-360*(16384-(16384.499999999996-c/360|0))}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)}for((t.loop?0==n||r>t.trackTime%n:e>=i&&t.animationLast<i)&&this.queue.complete(t);o<l;o++){a[o].time<s||this.queue.event(t,a[o])}}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(null==e)return;this.queue.end(e),this.disposeNext(e);let s=e;for(;;){let t=s.mixingFrom;if(null==t)break;this.queue.end(t),s.mixingFrom=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,null!=i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,e.mixTime=0,null!=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){let i=this.data.skeletonData.findAnimation(e);if(null==i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s){if(null==e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);null!=n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.disposeNext(n),n=n.mixingFrom,i=!1):this.disposeNext(n));let r=this.trackEntry(t,e,s,n);return this.setCurrent(t,r,i),this.queue.drain(),r}addAnimation(t,e,s,i){let n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s,i){if(null==e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(null!=n)for(;null!=n.next;)n=n.next;let r=this.trackEntry(t,e,s,n);if(null==n)this.setCurrent(t,r,!0),this.queue.drain();else if(n.next=r,i<=0){let t=n.animationEnd-n.animationStart;0!=t?(n.loop?i+=t*(1+(n.trackTime/t|0)):i+=t,i-=this.data.getMix(n.animation,e)):i=0}return r.delay=i,r}setEmptyAnimation(e,s){let i=this.setAnimationWith(e,t.emptyAnimation,!1);return i.mixDuration=s,i.trackEnd=s,i}addEmptyAnimation(e,s,i){i<=0&&(i-=s);let n=this.addAnimationWith(e,t.emptyAnimation,!1,i);return n.mixDuration=s,n.trackEnd=s,n}setEmptyAnimations(t){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];null!=s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(N.ensureArrayCapacity(this.tracks,t-this.tracks.length+1,null),this.tracks.length=t+1,null)}trackEntry(t,e,s,i){let n=this.trackEntryPool.obtain();return n.trackIndex=t,n.animation=e,n.loop=s,n.eventThreshold=0,n.attachmentThreshold=0,n.drawOrderThreshold=0,n.animationStart=0,n.animationEnd=e.duration,n.animationLast=-1,n.nextAnimationLast=-1,n.delay=0,n.trackTime=0,n.trackLast=-1,n.nextTrackLast=-1,n.trackEnd=Number.MAX_VALUE,n.timeScale=1,n.alpha=1,n.interruptAlpha=1,n.mixTime=0,n.mixDuration=null==i?0:this.data.getMix(i.animation,e),n}disposeNext(t){let e=t.next;for(;null!=e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1;let t=this.propertyIDs;t.clear();let e=this.mixingTo;for(var s=0,i=this.tracks.length;s<i;s++){let i=this.tracks[s];null!=i&&i.setTimelineData(null,e,t)}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(null==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()}};E(ft,"emptyAnimation",new O("<empty>",[],0)),E(ft,"SUBSEQUENT",0),E(ft,"FIRST",1),E(ft,"DIP",2),E(ft,"DIP_MIX",3);let xt=ft;class wt{constructor(){E(this,"animation"),E(this,"next"),E(this,"mixingFrom"),E(this,"listener"),E(this,"trackIndex"),E(this,"loop"),E(this,"eventThreshold"),E(this,"attachmentThreshold"),E(this,"drawOrderThreshold"),E(this,"animationStart"),E(this,"animationEnd"),E(this,"animationLast"),E(this,"nextAnimationLast"),E(this,"delay"),E(this,"trackTime"),E(this,"trackLast"),E(this,"nextTrackLast"),E(this,"trackEnd"),E(this,"timeScale"),E(this,"alpha"),E(this,"mixTime"),E(this,"mixDuration"),E(this,"interruptAlpha"),E(this,"totalAlpha"),E(this,"timelineData",new Array),E(this,"timelineDipMix",new Array),E(this,"timelinesRotation",new Array)}reset(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelineData.length=0,this.timelineDipMix.length=0,this.timelinesRotation.length=0}setTimelineData(t,e,s){null!=t&&e.push(t);let i=null!=this.mixingFrom?this.mixingFrom.setTimelineData(this,e,s):this;null!=t&&e.pop();let n=e,r=e.length-1,a=this.animation.timelines,o=this.animation.timelines.length,l=N.setArraySize(this.timelineData,o);this.timelineDipMix.length=0;let h=N.setArraySize(this.timelineDipMix,o);t:for(var d=0;d<o;d++){let e=a[d].getPropertyId();if(s.add(e))if(null!=t&&t.hasTimeline(e)){for(var u=r;u>=0;u--){let t=n[u];if(!t.hasTimeline(e)&&t.mixDuration>0){l[d]=xt.DIP_MIX,h[d]=t;continue t}}l[d]=xt.DIP}else l[d]=xt.FIRST;else l[d]=xt.SUBSEQUENT}return i}hasTimeline(t){let e=this.animation.timelines;for(var s=0,i=e.length;s<i;s++)if(e[s].getPropertyId()==t)return!0;return!1}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}}class bt{constructor(t){E(this,"objects",[]),E(this,"drainDisabled",!1),E(this,"animState"),this.animState=t}start(t){this.objects.push(0),this.objects.push(t),this.animState.animationsChanged=!0}interrupt(t){this.objects.push(1),this.objects.push(t)}end(t){this.objects.push(2),this.objects.push(t),this.animState.animationsChanged=!0}dispose(t){this.objects.push(3),this.objects.push(t)}complete(t){this.objects.push(4),this.objects.push(t)}event(t,e){this.objects.push(5),this.objects.push(t),this.objects.push(e)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let t=this.objects,e=this.animState.listeners;for(let s=0;s<t.length;s+=2){let i=t[s],n=t[s+1];switch(i){case 0:null!=n.listener&&n.listener.start&&n.listener.start(n);for(let t=0;t<e.length;t++)e[t].start&&e[t].start(n);break;case 1:null!=n.listener&&n.listener.interrupt&&n.listener.interrupt(n);for(let t=0;t<e.length;t++)e[t].interrupt&&e[t].interrupt(n);break;case 2:null!=n.listener&&n.listener.end&&n.listener.end(n);for(let t=0;t<e.length;t++)e[t].end&&e[t].end(n);case 3:null!=n.listener&&n.listener.dispose&&n.listener.dispose(n);for(let t=0;t<e.length;t++)e[t].dispose&&e[t].dispose(n);this.animState.trackEntryPool.free(n);break;case 4:null!=n.listener&&n.listener.complete&&n.listener.complete(n);for(let t=0;t<e.length;t++)e[t].complete&&e[t].complete(n);break;case 5:let i=t[2+s++];null!=n.listener&&n.listener.event&&n.listener.event(n,i);for(let t=0;t<e.length;t++)e[t].event&&e[t].event(n,i)}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var Et,yt=((Et=yt||{})[Et.start=0]="start",Et[Et.interrupt=1]="interrupt",Et[Et.end=2]="end",Et[Et.dispose=3]="dispose",Et[Et.complete=4]="complete",Et[Et.event=5]="event",Et);class Tt{constructor(t){if(E(this,"skeletonData"),E(this,"animationToMixTime",{}),E(this,"defaultMix",0),null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(null==i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(null==t)throw new Error("from cannot be null.");if(null==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 At extends C{constructor(t){super(t),E(this,"color",new v(1,1,1,1))}}class Ct extends C{constructor(t){super(t),E(this,"endSlot"),E(this,"color",new v(.2275,.2275,.8078,1))}}class Mt extends C{constructor(t){super(t),E(this,"region"),E(this,"path"),E(this,"regionUVs"),E(this,"uvs"),E(this,"triangles"),E(this,"color",new v(1,1,1,1)),E(this,"hullLength"),E(this,"parentMesh"),E(this,"inheritDeform",!1),E(this,"tempColor",new v(0,0,0,0))}updateUVs(){let t=0,e=0,s=0,i=0;null==this.region?(t=e=0,s=i=1):(t=this.region.u,e=this.region.v,s=this.region.u2-t,i=this.region.v2-e);let n=this.regionUVs;null!=this.uvs&&this.uvs.length==n.length||(this.uvs=N.newFloatArray(n.length));let r=this.uvs;if(this.region.rotate)for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a+1]*s,r[a+1]=e+i-n[a]*i;else for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a]*s,r[a+1]=e+n[a+1]*i}applyDeform(t){return this==t||this.inheritDeform&&this.parentMesh==t}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,null!=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)}}class St extends C{constructor(t){super(t),E(this,"lengths"),E(this,"closed",!1),E(this,"constantSpeed",!1),E(this,"color",new v(1,1,1,1))}}class vt extends C{constructor(t){super(t),E(this,"x"),E(this,"y"),E(this,"rotation"),E(this,"color",new v(.38,.94,0,1))}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=P.cosDeg(this.rotation),s=P.sinDeg(this.rotation),i=e*t.a+s*t.b,n=e*t.c+s*t.d;return Math.atan2(n,i)*P.radDeg}}const Rt=class t extends T{constructor(t){super(t),E(this,"x",0),E(this,"y",0),E(this,"scaleX",1),E(this,"scaleY",1),E(this,"rotation",0),E(this,"width",0),E(this,"height",0),E(this,"color",new v(1,1,1,1)),E(this,"path"),E(this,"rendererObject"),E(this,"region"),E(this,"offset",N.newFloatArray(8)),E(this,"uvs",N.newFloatArray(8)),E(this,"tempColor",new v(1,1,1,1))}updateOffset(){let e=this.width/this.region.originalWidth*this.scaleX,s=this.height/this.region.originalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.region.offsetX*e,n=-this.height/2*this.scaleY+this.region.offsetY*s,r=i+this.region.width*e,a=n+this.region.height*s,o=this.rotation*Math.PI/180,l=Math.cos(o),h=Math.sin(o),d=i*l+this.x,u=i*h,c=n*l+this.y,p=n*h,m=r*l+this.x,g=r*h,f=a*l+this.y,x=a*h,w=this.offset;w[t.OX1]=d-p,w[t.OY1]=c+u,w[t.OX2]=d-x,w[t.OY2]=f+u,w[t.OX3]=m-x,w[t.OY3]=f+g,w[t.OX4]=m-p,w[t.OY4]=c+g}setRegion(t){this.region=t;let e=this.uvs;t.rotate?(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(e,s,i,n){let r=this.offset,a=e.worldX,o=e.worldY,l=e.a,h=e.b,d=e.c,u=e.d,c=0,p=0;c=r[t.OX1],p=r[t.OY1],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o,i+=n,c=r[t.OX2],p=r[t.OY2],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o,i+=n,c=r[t.OX3],p=r[t.OY3],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o,i+=n,c=r[t.OX4],p=r[t.OY4],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o}};E(Rt,"OX1",0),E(Rt,"OY1",1),E(Rt,"OX2",2),E(Rt,"OY2",3),E(Rt,"OX3",4),E(Rt,"OY3",5),E(Rt,"OX4",6),E(Rt,"OY4",7),E(Rt,"X1",0),E(Rt,"Y1",1),E(Rt,"C1R",2),E(Rt,"C1G",3),E(Rt,"C1B",4),E(Rt,"C1A",5),E(Rt,"U1",6),E(Rt,"V1",7),E(Rt,"X2",8),E(Rt,"Y2",9),E(Rt,"C2R",10),E(Rt,"C2G",11),E(Rt,"C2B",12),E(Rt,"C2A",13),E(Rt,"U2",14),E(Rt,"V2",15),E(Rt,"X3",16),E(Rt,"Y3",17),E(Rt,"C3R",18),E(Rt,"C3G",19),E(Rt,"C3B",20),E(Rt,"C3A",21),E(Rt,"U3",22),E(Rt,"V3",23),E(Rt,"X4",24),E(Rt,"Y4",25),E(Rt,"C4R",26),E(Rt,"C4G",27),E(Rt,"C4B",28),E(Rt,"C4A",29),E(Rt,"U4",30),E(Rt,"V4",31);let Pt=Rt;class It{constructor(t){E(this,"atlas"),this.atlas=t}newRegionAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");i.renderObject=i;let n=new Pt(e);return n.setRegion(i),n}newMeshAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");i.renderObject=i;let n=new Mt(e);return n.region=i,n}newBoundingBoxAttachment(t,e){return new At(e)}newPathAttachment(t,e){return new St(e)}newPointAttachment(t,e){return new vt(e)}newClippingAttachment(t,e){return new Ct(e)}}class kt{constructor(t,e,s){if(E(this,"index"),E(this,"name"),E(this,"parent"),E(this,"length"),E(this,"x",0),E(this,"y",0),E(this,"rotation",0),E(this,"scaleX",1),E(this,"scaleY",1),E(this,"shearX",0),E(this,"shearY",0),E(this,"transformMode",0),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}var Vt,Dt=((Vt=Dt||{})[Vt.Normal=0]="Normal",Vt[Vt.OnlyTranslation=1]="OnlyTranslation",Vt[Vt.NoRotationOrReflection=2]="NoRotationOrReflection",Vt[Vt.NoScale=3]="NoScale",Vt[Vt.NoScaleOrReflection=4]="NoScaleOrReflection",Vt);class Nt{constructor(t,e,s){if(E(this,"data"),E(this,"skeleton"),E(this,"parent"),E(this,"children",new Array),E(this,"x",0),E(this,"y",0),E(this,"rotation",0),E(this,"scaleX",0),E(this,"scaleY",0),E(this,"shearX",0),E(this,"shearY",0),E(this,"ax",0),E(this,"ay",0),E(this,"arotation",0),E(this,"ascaleX",0),E(this,"ascaleY",0),E(this,"ashearX",0),E(this,"ashearY",0),E(this,"appliedValid",!1),E(this,"a",0),E(this,"b",0),E(this,"worldX",0),E(this,"c",0),E(this,"d",0),E(this,"worldY",0),E(this,"sorted",!1),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}update(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(t,e,s,i,n,r,a){this.ax=t,this.ay=e,this.arotation=s,this.ascaleX=i,this.ascaleY=n,this.ashearX=r,this.ashearY=a,this.appliedValid=!0;let o=this.parent;if(null==o){let o=s+90+a,l=P.cosDeg(s+r)*i,h=P.cosDeg(o)*n,d=P.sinDeg(s+r)*i,u=P.sinDeg(o)*n,c=this.skeleton;return c.flipX&&(t=-t,l=-l,h=-h),c.flipY&&(e=-e,d=-d,u=-u),this.a=l,this.b=h,this.c=d,this.d=u,this.worldX=t+c.x,void(this.worldY=e+c.y)}let l=o.a,h=o.b,d=o.c,u=o.d;switch(this.worldX=l*t+h*e+o.worldX,this.worldY=d*t+u*e+o.worldY,this.data.transformMode){case Dt.Normal:{let t=s+90+a,e=P.cosDeg(s+r)*i,o=P.cosDeg(t)*n,c=P.sinDeg(s+r)*i,p=P.sinDeg(t)*n;return this.a=l*e+h*c,this.b=l*o+h*p,this.c=d*e+u*c,void(this.d=d*o+u*p)}case Dt.OnlyTranslation:{let t=s+90+a;this.a=P.cosDeg(s+r)*i,this.b=P.cosDeg(t)*n,this.c=P.sinDeg(s+r)*i,this.d=P.sinDeg(t)*n;break}case Dt.NoRotationOrReflection:{let t=l*l+d*d,e=0;t>1e-4?(t=Math.abs(l*u-h*d)/t,h=d*t,u=l*t,e=Math.atan2(d,l)*P.radDeg):(l=0,d=0,e=90-Math.atan2(u,h)*P.radDeg);let o=s+r-e,c=s+a-e+90,p=P.cosDeg(o)*i,m=P.cosDeg(c)*n,g=P.sinDeg(o)*i,f=P.sinDeg(c)*n;this.a=l*p-h*g,this.b=l*m-h*f,this.c=d*p+u*g,this.d=d*m+u*f;break}case Dt.NoScale:case Dt.NoScaleOrReflection:{let t=P.cosDeg(s),e=P.sinDeg(s),o=l*t+h*e,c=d*t+u*e,p=Math.sqrt(o*o+c*c);p>1e-5&&(p=1/p),o*=p,c*=p,p=Math.sqrt(o*o+c*c);let m=Math.PI/2+Math.atan2(c,o),g=Math.cos(m)*p,f=Math.sin(m)*p,x=P.cosDeg(r)*i,w=P.cosDeg(90+a)*n,b=P.sinDeg(r)*i,E=P.sinDeg(90+a)*n;return(this.data.transformMode!=Dt.NoScaleOrReflection?l*u-h*d<0:this.skeleton.flipX!=this.skeleton.flipY)&&(g=-g,f=-f),this.a=o*x+g*b,this.b=o*w+g*E,this.c=c*x+f*b,void(this.d=c*w+f*E)}}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)}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}getWorldRotationX(){return Math.atan2(this.c,this.a)*P.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*P.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)}updateAppliedTransform(){this.appliedValid=!0;let t=this.parent;if(null==t)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*P.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)*P.radDeg);let e=t.a,s=t.b,i=t.c,n=t.d,r=1/(e*n-s*i),a=this.worldX-t.worldX,o=this.worldY-t.worldY;this.ax=a*n*r-o*s*r,this.ay=o*e*r-a*i*r;let l=r*n,h=r*e,d=r*s,u=r*i,c=l*this.a-d*this.c,p=l*this.b-d*this.d,m=h*this.c-u*this.a,g=h*this.d-u*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(c*c+m*m),this.ascaleX>1e-4){let t=c*g-p*m;this.ascaleY=t/this.ascaleX,this.ashearY=Math.atan2(c*p+m*g,t)*P.radDeg,this.arotation=Math.atan2(m,c)*P.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(p*p+g*g),this.ashearY=0,this.arotation=90-Math.atan2(g,p)*P.radDeg}worldToLocal(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=1/(e*n-s*i),a=t.x-this.worldX,o=t.y-this.worldY;return t.x=a*n*r-o*s*r,t.y=o*e*r-a*i*r,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}worldToLocalRotation(t){let e=P.sinDeg(t),s=P.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*P.radDeg}localToWorldRotation(t){let e=P.sinDeg(t),s=P.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*P.radDeg}rotateWorld(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=P.cosDeg(t),a=P.sinDeg(t);this.a=r*e-a*i,this.b=r*s-a*n,this.c=a*e+r*i,this.d=a*s+r*n,this.appliedValid=!1}}class _t{constructor(t){E(this,"_image"),this._image=t}getImage(){return this._image}static filterFromString(t){switch(t.toLowerCase()){case"nearest":return 9728;case"linear":return 9729;case"mipmap":case"mipmaplinearlinear":return 9987;case"mipmapnearestnearest":return 9984;case"mipmaplinearnearest":return 9985;case"mipmapnearestlinear":return 9986;default:throw new Error(`Unknown texture filter ${t}`)}}static wrapFromString(t){switch(t.toLowerCase()){case"mirroredtepeat":return 33648;case"clamptoedge":return 33071;case"repeat":return 10497;default:throw new Error(`Unknown texture wrap ${t}`)}}}var Lt,Ot,Yt=((Lt=Yt||{})[Lt.Nearest=9728]="Nearest",Lt[Lt.Linear=9729]="Linear",Lt[Lt.MipMap=9987]="MipMap",Lt[Lt.MipMapNearestNearest=9984]="MipMapNearestNearest",Lt[Lt.MipMapLinearNearest=9985]="MipMapLinearNearest",Lt[Lt.MipMapNearestLinear=9986]="MipMapNearestLinear",Lt[Lt.MipMapLinearLinear=9987]="MipMapLinearLinear",Lt),Ft=((Ot=Ft||{})[Ot.MirroredRepeat=33648]="MirroredRepeat",Ot[Ot.ClampToEdge=33071]="ClampToEdge",Ot[Ot.Repeat=10497]="Repeat",Ot);class Xt{constructor(){E(this,"renderObject"),E(this,"u",0),E(this,"v",0),E(this,"u2",0),E(this,"v2",0),E(this,"width",0),E(this,"height",0),E(this,"rotate",!1),E(this,"offsetX",0),E(this,"offsetY",0),E(this,"originalWidth",0),E(this,"originalHeight",0),E(this,"texture")}}class Bt extends _t{setFilters(t,e){}setWraps(t,e){}dispose(){}}class Wt{constructor(t,e){E(this,"pages",new Array),E(this,"regions",new Array),this.load(t,e)}load(t,e){if(null==e)throw new Error("textureLoader cannot be null.");let s=new Ut(t),i=new Array(4),n=null;for(;;){let t=s.readLine();if(null==t)break;if(t=t.trim(),0==t.length)n=null;else if(n){let e=new qt;e.name=t,e.page=n,e.rotate="true"==s.readValue(),s.readTuple(i);let r=parseInt(i[0]),a=parseInt(i[1]);s.readTuple(i);let o=parseInt(i[0]),l=parseInt(i[1]);e.u=r/n.width,e.v=a/n.height,e.rotate?(e.u2=(r+l)/n.width,e.v2=(a+o)/n.height):(e.u2=(r+o)/n.width,e.v2=(a+l)/n.height),e.x=r,e.y=a,e.width=Math.abs(o),e.height=Math.abs(l),4==s.readTuple(i)&&4==s.readTuple(i)&&s.readTuple(i),e.originalWidth=parseInt(i[0]),e.originalHeight=parseInt(i[1]),s.readTuple(i),e.offsetX=parseInt(i[0]),e.offsetY=parseInt(i[1]),e.index=parseInt(s.readValue()),e.texture=n.texture,this.regions.push(e)}else{n=new jt,n.name=t,2==s.readTuple(i)&&(n.width=parseInt(i[0]),n.height=parseInt(i[1]),s.readTuple(i)),s.readTuple(i),n.minFilter=_t.filterFromString(i[0]),n.magFilter=_t.filterFromString(i[1]);let r=s.readValue();n.uWrap=Ft.ClampToEdge,n.vWrap=Ft.ClampToEdge,"x"==r?n.uWrap=Ft.Repeat:"y"==r?n.vWrap=Ft.Repeat:"xy"==r&&(n.uWrap=n.vWrap=Ft.Repeat),n.texture=e(t),n.texture.setFilters(n.minFilter,n.magFilter),n.texture.setWraps(n.uWrap,n.vWrap),n.width=n.texture.getImage().width,n.height=n.texture.getImage().height,this.pages.push(n)}}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()}}class Ut{constructor(t){E(this,"lines"),E(this,"index",0),this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readValue(){let t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()}readTuple(t){let e=this.readLine(),s=e.indexOf(":");if(-1==s)throw new Error("Invalid line: "+e);let i=0,n=s+1;for(;i<3;i++){let s=e.indexOf(",",n);if(-1==s)break;t[i]=e.substr(n,s-n).trim(),n=s+1}return t[i]=e.substring(n).trim(),i+1}}class jt{constructor(){E(this,"name"),E(this,"minFilter"),E(this,"magFilter"),E(this,"uWrap"),E(this,"vWrap"),E(this,"texture"),E(this,"width"),E(this,"height")}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap),this.width=this.texture.getImage().width,this.height=this.texture.getImage().height}}class qt extends Xt{constructor(){super(...arguments),E(this,"page"),E(this,"name"),E(this,"x"),E(this,"y"),E(this,"index"),E(this,"rotate"),E(this,"texture")}}class Gt{constructor(t,e=""){E(this,"pathPrefix"),E(this,"textureLoader"),E(this,"assets",{}),E(this,"errors",{}),E(this,"toLoad",0),E(this,"loaded",0),this.textureLoader=t,this.pathPrefix=e}static downloadText(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.onload=()=>{200==i.status?e(i.responseText):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}static downloadBinary(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status?e(new Uint8Array(i.response)):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}loadText(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++,Gt.downloadText(t,(s=>{this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++}),((e,i)=>{this.errors[t]=`Couldn't load text ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load text ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++}))}loadTexture(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++;let i=new Image;i.crossOrigin="anonymous",i.onload=s=>{let n=this.textureLoader(i);this.assets[t]=n,this.toLoad--,this.loaded++,e&&e(t,i)},i.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,s&&s(t,`Couldn't load image ${t}`)},i.src=t}loadTextureData(t,e,s=null,i=null){t=this.pathPrefix+t,this.toLoad++;let n=new Image;n.onload=e=>{let i=this.textureLoader(n);this.assets[t]=i,this.toLoad--,this.loaded++,s&&s(t,n)},n.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,i&&i(t,`Couldn't load image ${t}`)},n.src=e}loadTextureAtlas(t,e=null,s=null){let i=t.lastIndexOf("/")>=0?t.substring(0,t.lastIndexOf("/")):"";t=this.pathPrefix+t,this.toLoad++,Gt.downloadText(t,(n=>{var r={count:0},a=new Array;try{new Wt(n,(t=>{a.push(i+"/"+t);let e=document.createElement("img");return e.width=16,e.height=16,new Bt(e)}))}catch(e){let i=e;return this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,void this.loaded++}for(let o of a){let l=!1;this.loadTexture(o,((o,h)=>{if(r.count++,r.count==a.length)if(l)this.errors[t]=`Couldn't load texture atlas page ${o}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${o} of atlas ${t}`),this.toLoad--,this.loaded++;else try{let s=new Wt(n,(t=>this.get(i+"/"+t)));this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++}catch(e){let i=e;this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,this.loaded++}}),((e,i)=>{l=!0,r.count++,r.count==a.length&&(this.errors[t]=`Couldn't load texture atlas page ${e}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${e} of atlas ${t}`),this.toLoad--,this.loaded++)}))}}),((e,i)=>{this.errors[t]=`Couldn't load texture atlas ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load texture atlas ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++}))}get(t){return t=this.pathPrefix+t,this.assets[t]}remove(t){t=this.pathPrefix+t;let e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null}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}}class $t{constructor(t,e){if(E(this,"data"),E(this,"intValue"),E(this,"floatValue"),E(this,"stringValue"),E(this,"time"),null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class zt{constructor(t){E(this,"name"),E(this,"intValue"),E(this,"floatValue"),E(this,"stringValue"),this.name=t}}class Ht{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"mix",1),E(this,"bendDirection",0),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}getOrder(){return this.data.order}apply(){this.update()}update(){let t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.mix)}}apply1(t,e,s,i){t.appliedValid||t.updateAppliedTransform();let n=t.parent,r=1/(n.a*n.d-n.b*n.c),a=e-n.worldX,o=s-n.worldY,l=(a*n.d-o*n.b)*r-t.ax,h=(o*n.a-a*n.c)*r-t.ay,d=Math.atan2(h,l)*P.radDeg-t.ashearX-t.arotation;t.ascaleX<0&&(d+=180),d>180?d-=360:d<-180&&(d+=360),t.updateWorldTransformWith(t.ax,t.ay,t.arotation+d*i,t.ascaleX,t.ascaleY,t.ashearX,t.ashearY)}apply2(t,e,s,i,n,r){if(0==r)return void e.updateWorldTransform();t.appliedValid||t.updateAppliedTransform(),e.appliedValid||e.updateAppliedTransform();let a=t.ax,o=t.ay,l=t.ascaleX,h=t.ascaleY,d=e.ascaleX,u=0,c=0,p=0;l<0?(l=-l,u=180,p=-1):(u=0,p=1),h<0&&(h=-h,p=-p),d<0?(d=-d,c=180):c=0;let m=e.ax,g=0,f=0,x=0,w=t.a,b=t.b,E=t.c,y=t.d,T=Math.abs(l-h)<=1e-4;T?(g=e.ay,f=w*m+b*g+t.worldX,x=E*m+y*g+t.worldY):(g=0,f=w*m+t.worldX,x=E*m+t.worldY);let A=t.parent;w=A.a,b=A.b,E=A.c,y=A.d;let C=1/(w*y-b*E),M=s-A.worldX,S=i-A.worldY,v=(M*y-S*b)*C-a,R=(S*w-M*E)*C-o;M=f-A.worldX,S=x-A.worldY;let I=(M*y-S*b)*C-a,k=(S*w-M*E)*C-o,V=Math.sqrt(I*I+k*k),D=e.data.length*d,N=0,_=0;t:if(T){D*=l;let t=(v*v+R*R-V*V-D*D)/(2*V*D);t<-1?t=-1:t>1&&(t=1),_=Math.acos(t)*n,w=V+D*t,b=D*Math.sin(_),N=Math.atan2(R*w-v*b,v*w+R*b)}else{w=l*D,b=h*D;let t=w*w,e=b*b,s=v*v+R*R,i=Math.atan2(R,v);E=e*V*V+t*s-t*e;let r=-2*e*V,a=e-t;if(y=r*r-4*a*E,y>=0){let t=Math.sqrt(y);r<0&&(t=-t),t=-(r+t)/2;let e=t/a,o=E/t,d=Math.abs(e)<Math.abs(o)?e:o;if(d*d<=s){S=Math.sqrt(s-d*d)*n,N=i-Math.atan2(S,d),_=Math.atan2(S/h,(d-V)/l);break t}}let o=P.PI,d=V-w,u=d*d,c=0,p=0,m=V+w,g=m*m,f=0;E=-w*V/(t-e),E>=-1&&E<=1&&(E=Math.acos(E),M=w*Math.cos(E)+V,S=b*Math.sin(E),y=M*M+S*S,y<u&&(o=E,u=y,d=M,c=S),y>g&&(p=E,g=y,m=M,f=S)),s<=(u+g)/2?(N=i-Math.atan2(c*n,d),_=o*n):(N=i-Math.atan2(f*n,m),_=p*n)}let L=Math.atan2(g,m)*p,O=t.arotation;N=(N-L)*P.radDeg+u-O,N>180?N-=360:N<-180&&(N+=360),t.updateWorldTransformWith(a,o,O+N*r,t.ascaleX,t.ascaleY,0,0),O=e.arotation,_=((_+L)*P.radDeg-e.ashearX)*p+c-O,_>180?_-=360:_<-180&&(_+=360),e.updateWorldTransformWith(m,g,O+_*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)}}class Zt{constructor(t){E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"bendDirection",1),E(this,"mix",1),this.name=t}}class Jt{constructor(t){E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"positionMode"),E(this,"spacingMode"),E(this,"rotateMode"),E(this,"offsetRotation"),E(this,"position"),E(this,"spacing"),E(this,"rotateMix"),E(this,"translateMix"),this.name=t}}var Qt,Kt,te,ee=((Qt=ee||{})[Qt.Fixed=0]="Fixed",Qt[Qt.Percent=1]="Percent",Qt),se=((Kt=se||{})[Kt.Length=0]="Length",Kt[Kt.Fixed=1]="Fixed",Kt[Kt.Percent=2]="Percent",Kt),ie=((te=ie||{})[te.Tangent=0]="Tangent",te[te.Chain=1]="Chain",te[te.ChainScale=2]="ChainScale",te);const ne=class t{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"position",0),E(this,"spacing",0),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"spaces",new Array),E(this,"positions",new Array),E(this,"world",new Array),E(this,"curves",new Array),E(this,"lengths",new Array),E(this,"segments",new Array),null==t)throw new Error("data cannot be null.");if(null==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++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}apply(){this.update()}update(){let e=this.target.getAttachment();if(!(e instanceof St))return;let s=this.rotateMix,i=this.translateMix,n=s>0;if(!(i>0)&&!n)return;let r=this.data,a=r.spacingMode,o=a==se.Length,l=r.rotateMode,h=l==ie.Tangent,d=l==ie.ChainScale,u=this.bones.length,c=h?u:u+1,p=this.bones,m=N.setArraySize(this.spaces,c),g=null,f=this.spacing;if(d||o){d&&(g=N.setArraySize(this.lengths,u));for(let e=0,s=c-1;e<s;){let s=p[e],i=s.data.length;if(i<t.epsilon)d&&(g[e]=0),m[++e]=0;else{let t=i*s.a,n=i*s.c,r=Math.sqrt(t*t+n*n);d&&(g[e]=r),m[++e]=(o?i+f:f)*r/i}}}else for(let t=1;t<c;t++)m[t]=f;let x=this.computeWorldPositions(e,c,h,r.positionMode==ee.Percent,a==se.Percent),w=x[0],b=x[1],E=r.offsetRotation,y=!1;if(0==E)y=l==ie.Chain;else{y=!1;let t=this.target.bone;E*=t.a*t.d-t.b*t.c>0?P.degRad:-P.degRad}for(let t=0,e=3;t<u;t++,e+=3){let r=p[t];r.worldX+=(w-r.worldX)*i,r.worldY+=(b-r.worldY)*i;let a=x[e],o=x[e+1],l=a-w,u=o-b;if(d){let e=g[t];if(0!=e){let t=(Math.sqrt(l*l+u*u)/e-1)*s+1;r.a*=t,r.c*=t}}if(w=a,b=o,n){let i=r.a,n=r.b,a=r.c,o=r.d,d=0,c=0,p=0;if(d=h?x[e-1]:0==m[t+1]?x[e+2]:Math.atan2(u,l),d-=Math.atan2(a,i),y){c=Math.cos(d),p=Math.sin(d);let t=r.data.length;w+=(t*(c*i-p*a)-l)*s,b+=(t*(p*i+c*a)-u)*s}else d+=E;d>P.PI?d-=P.PI2:d<-P.PI&&(d+=P.PI2),d*=s,c=Math.cos(d),p=Math.sin(d),r.a=c*i-p*a,r.b=c*n-p*o,r.c=p*i+c*a,r.d=p*n+c*o}r.appliedValid=!1}}computeWorldPositions(e,s,i,n,r){let a=this.target,o=this.position,l=this.spaces,h=N.setArraySize(this.positions,3*s+2),d=null,u=e.closed,c=e.worldVerticesLength,p=c/6,m=t.NONE;if(!e.constantSpeed){let g=e.lengths;p-=u?1:2;let f=g[p];if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;d=N.setArraySize(this.world,8);for(let n=0,r=0,x=0;n<s;n++,r+=3){let s=l[n];o+=s;let w=o;if(u)w%=f,w<0&&(w+=f),x=0;else{if(w<0){m!=t.BEFORE&&(m=t.BEFORE,e.computeWorldVertices(a,2,4,d,0,2)),this.addBeforePosition(w,d,0,h,r);continue}if(w>f){m!=t.AFTER&&(m=t.AFTER,e.computeWorldVertices(a,c-6,4,d,0,2)),this.addAfterPosition(w-f,d,0,h,r);continue}}for(;;x++){let t=g[x];if(!(w>t)){if(0==x)w/=t;else{let e=g[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,u&&x==p?(e.computeWorldVertices(a,c-4,4,d,0,2),e.computeWorldVertices(a,0,4,d,4,2)):e.computeWorldVertices(a,6*x+2,8,d,0,2)),this.addCurvePosition(w,d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],h,r,i||n>0&&0==s)}return h}u?(c+=2,d=N.setArraySize(this.world,c),e.computeWorldVertices(a,2,c-4,d,0,2),e.computeWorldVertices(a,0,2,d,c-4,2),d[c-2]=d[0],d[c-1]=d[1]):(p--,c-=4,d=N.setArraySize(this.world,c),e.computeWorldVertices(a,2,c,d,0,2));let g=N.setArraySize(this.curves,p),f=0,x=d[0],w=d[1],b=0,E=0,y=0,T=0,A=0,C=0,M=0,S=0,v=0,R=0,P=0,I=0,k=0,V=0;for(let t=0,e=2;t<p;t++,e+=6)b=d[e],E=d[e+1],y=d[e+2],T=d[e+3],A=d[e+4],C=d[e+5],M=.1875*(x-2*b+y),S=.1875*(w-2*E+T),v=.09375*(3*(b-y)-x+A),R=.09375*(3*(E-T)-w+C),P=2*M+v,I=2*S+R,k=.75*(b-x)+M+.16666667*v,V=.75*(E-w)+S+.16666667*R,f+=Math.sqrt(k*k+V*V),k+=P,V+=I,P+=v,I+=R,f+=Math.sqrt(k*k+V*V),k+=P,V+=I,f+=Math.sqrt(k*k+V*V),k+=P+v,V+=I+R,f+=Math.sqrt(k*k+V*V),g[t]=f,x=A,w=C;if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;let D=this.segments,_=0;for(let t=0,e=0,n=0,r=0;t<s;t++,e+=3){let s=l[t];o+=s;let a=o;if(u)a%=f,a<0&&(a+=f),n=0;else{if(a<0){this.addBeforePosition(a,d,0,h,e);continue}if(a>f){this.addAfterPosition(a-f,d,c-4,h,e);continue}}for(;;n++){let t=g[n];if(!(a>t)){if(0==n)a/=t;else{let e=g[n-1];a=(a-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=d[t],w=d[t+1],b=d[t+2],E=d[t+3],y=d[t+4],T=d[t+5],A=d[t+6],C=d[t+7],M=.03*(x-2*b+y),S=.03*(w-2*E+T),v=.006*(3*(b-y)-x+A),R=.006*(3*(E-T)-w+C),P=2*M+v,I=2*S+R,k=.3*(b-x)+M+.16666667*v,V=.3*(E-w)+S+.16666667*R,_=Math.sqrt(k*k+V*V),D[0]=_,t=1;t<8;t++)k+=P,V+=I,P+=v,I+=R,_+=Math.sqrt(k*k+V*V),D[t]=_;k+=P,V+=I,_+=Math.sqrt(k*k+V*V),D[8]=_,k+=P+v,V+=I+R,_+=Math.sqrt(k*k+V*V),D[9]=_,r=0}for(a*=_;;r++){let t=D[r];if(!(a>t)){if(0==r)a/=t;else{let e=D[r-1];a=r+(a-e)/(t-e)}break}}this.addCurvePosition(.1*a,x,w,b,E,y,T,A,C,h,e,i||t>0&&0==s)}return h}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,d,u){(0==t||isNaN(t))&&(t=1e-4);let c=t*t,p=c*t,m=1-t,g=m*m,f=g*m,x=m*t,w=3*x,b=m*w,E=w*t,y=e*f+i*b+r*E+o*p,T=s*f+n*b+a*E+l*p;h[d]=y,h[d+1]=T,u&&(h[d+2]=Math.atan2(T-(s*g+n*x*2+a*c),y-(e*g+i*x*2+r*c)))}getOrder(){return this.data.order}};E(ne,"NONE",-1),E(ne,"BEFORE",-2),E(ne,"AFTER",-3),E(ne,"epsilon",1e-5);let re=ne;class ae{constructor(t,e){if(E(this,"data"),E(this,"bone"),E(this,"color"),E(this,"darkColor"),E(this,"attachment"),E(this,"attachmentTime"),E(this,"attachmentVertices",new Array),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new v,this.darkColor=null==t.darkColor?null:new v,this.setToSetupPose()}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0)}setAttachmentTime(t){this.attachmentTime=this.bone.skeleton.time-t}getAttachmentTime(){return this.bone.skeleton.time-this.attachmentTime}setToSetupPose(){this.color.setFromColor(this.data.color),null!=this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))}}class oe{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"scaleMix",0),E(this,"shearMix",0),E(this,"temp",new L),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.scaleMix=t.scaleMix,this.shearMix=t.shearMix,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}apply(){this.update()}update(){this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld()}applyAbsoluteWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?P.degRad:-P.degRad,d=this.data.offsetRotation*h,u=this.data.offsetShearY*h,c=this.bones;for(let h=0,p=c.length;h<p;h++){let p=c[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)-Math.atan2(i,e)+d;a>P.PI?a-=P.PI2:a<-P.PI&&(a+=P.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(t.x-p.worldX)*e,p.worldY+=(t.y-p.worldY)*e,m=!0}if(s>0){let t=Math.sqrt(p.a*p.a+p.c*p.c),e=Math.sqrt(r*r+o*o);t>1e-5&&(t=(t+(e-t+this.data.offsetScaleX)*s)/t),p.a*=t,p.c*=t,t=Math.sqrt(p.b*p.b+p.d*p.d),e=Math.sqrt(a*a+l*l),t>1e-5&&(t=(t+(e-t+this.data.offsetScaleY)*s)/t),p.b*=t,p.d*=t,m=!0}if(i>0){let t=p.b,e=p.d,s=Math.atan2(e,t),n=Math.atan2(l,a)-Math.atan2(o,r)-(s-Math.atan2(p.c,p.a));n>P.PI?n-=P.PI2:n<-P.PI&&(n+=P.PI2),n=s+(n+u)*i;let h=Math.sqrt(t*t+e*e);p.b=Math.cos(n)*h,p.d=Math.sin(n)*h,m=!0}m&&(p.appliedValid=!1)}}applyRelativeWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?P.degRad:-P.degRad,d=this.data.offsetRotation*h,u=this.data.offsetShearY*h,c=this.bones;for(let h=0,p=c.length;h<p;h++){let p=c[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)+d;a>P.PI?a-=P.PI2:a<-P.PI&&(a+=P.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=t.x*e,p.worldY+=t.y*e,m=!0}if(s>0){let t=(Math.sqrt(r*r+o*o)-1+this.data.offsetScaleX)*s+1;p.a*=t,p.c*=t,t=(Math.sqrt(a*a+l*l)-1+this.data.offsetScaleY)*s+1,p.b*=t,p.d*=t,m=!0}if(i>0){let t=Math.atan2(l,a)-Math.atan2(o,r);t>P.PI?t-=P.PI2:t<-P.PI&&(t+=P.PI2);let e=p.b,s=p.d;t=Math.atan2(s,e)+(t-P.PI/2+u)*i;let n=Math.sqrt(e*e+s*s);p.b=Math.cos(t)*n,p.d=Math.sin(t)*n,m=!0}m&&(p.appliedValid=!1)}}applyAbsoluteLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;if(0!=t){let e=n.arotation-l+this.data.offsetRotation;e-=360*(16384-(16384.499999999996-e/360|0)),l+=e*t}let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax-h+this.data.offsetX)*e,d+=(n.ay-d+this.data.offsetY)*e);let u=o.ascaleX,c=o.ascaleY;s>0&&(u>1e-5&&(u=(u+(n.ascaleX-u+this.data.offsetScaleX)*s)/u),c>1e-5&&(c=(c+(n.ascaleY-c+this.data.offsetScaleY)*s)/c));let p=o.ashearY;if(i>0){let t=n.ashearY-p+this.data.offsetShearY;t-=360*(16384-(16384.499999999996-t/360|0)),o.shearY+=t*i}o.updateWorldTransformWith(h,d,l,u,c,o.ashearX,p)}}applyRelativeLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;0!=t&&(l+=(n.arotation+this.data.offsetRotation)*t);let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax+this.data.offsetX)*e,d+=(n.ay+this.data.offsetY)*e);let u=o.ascaleX,c=o.ascaleY;s>0&&(u>1e-5&&(u*=(n.ascaleX-1+this.data.offsetScaleX)*s+1),c>1e-5&&(c*=(n.ascaleY-1+this.data.offsetScaleY)*s+1));let p=o.ashearY;i>0&&(p+=(n.ashearY+this.data.offsetShearY)*i),o.updateWorldTransformWith(h,d,l,u,c,o.ashearX,p)}}getOrder(){return this.data.order}}class le{constructor(t){if(E(this,"data"),E(this,"bones"),E(this,"slots"),E(this,"drawOrder"),E(this,"ikConstraints"),E(this,"transformConstraints"),E(this,"pathConstraints"),E(this,"_updateCache",new Array),E(this,"updateCacheReset",new Array),E(this,"skin"),E(this,"color"),E(this,"time",0),E(this,"flipX",!1),E(this,"flipY",!1),E(this,"x",0),E(this,"y",0),null==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(null==i.parent)s=new Nt(i,this,null);else{let t=this.bones[i.parent.index];s=new Nt(i,this,t),t.children.push(s)}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 ae(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 Ht(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new oe(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new re(s,this))}this.color=new v(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.updateCacheReset.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].sorted=!1;let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=e.length,r=s.length,a=i.length,o=n+r+a;t:for(let t=0;t<o;t++){for(let s=0;s<n;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<r;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<a;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),s.length>1){let t=s[s.length-1];this._updateCache.indexOf(t)>-1||this.updateCacheReset.push(t)}this._updateCache.push(t),this.sortReset(i.children),s[s.length-1].sorted=!0}sortPathConstraint(t){let e=t.target,s=e.data.index,i=e.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),null!=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 St&&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){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._updateCache.indexOf(s)>-1||this.updateCacheReset.push(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 St))return;let s=t.bones;if(null==s)this.sortBone(e);else{let t=this.bones,e=0;for(;e<s.length;){let i=s[e++];for(let n=e+i;e<n;e++){let i=s[e];this.sortBone(t[i])}}}}sortBone(t){if(t.sorted)return;let e=t.parent;null!=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.sorted&&this.sortReset(s.children),s.sorted=!1}}updateWorldTransform(){let t=this.updateCacheReset;for(let e=0,s=t.length;e<s;e++){let s=t[e];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,s.appliedValid=!0}let e=this._updateCache;for(let t=0,s=e.length;t<s;t++)e[t].update()}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose();let e=this.ikConstraints;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.bendDirection=s.data.bendDirection,s.mix=s.data.mix}let s=this.transformConstraints;for(let t=0,e=s.length;t<e;t++){let e=s[t],i=e.data;e.rotateMix=i.rotateMix,e.translateMix=i.translateMix,e.scaleMix=i.scaleMix,e.shearMix=i.shearMix}let i=this.pathConstraints;for(let t=0,e=i.length;t<e;t++){let e=i[t],s=e.data;e.position=s.position,e.spacing=s.spacing,e.rotateMix=s.rotateMix,e.translateMix=s.translateMix}}setSlotsToSetupPose(){let t=this.slots;N.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(null==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}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}findSlot(t){if(null==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}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}setSkinByName(t){let e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(null!=t)if(null!=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(null!=n){let e=t.getAttachment(s,n);null!=e&&i.setAttachment(e)}}}this.skin=t}getAttachmentByName(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)}getAttachment(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){let s=this.skin.getAttachment(t,e);if(null!=s)return s}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(null==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(null!=e&&(s=this.getAttachment(i,e),null==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(null==t)throw new 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.data.name==t)return i}return null}findTransformConstraint(t){if(null==t)throw new 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.data.name==t)return i}return null}findPathConstraint(t){if(null==t)throw new 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.data.name==t)return i}return null}getBounds(t,e,s){if(null==t)throw new Error("offset cannot be null.");if(null==e)throw new Error("size cannot be null.");let i=this.drawOrder,n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let t=0,e=i.length;t<e;t++){let e=i[t],l=0,h=null,d=e.getAttachment();if(d instanceof Pt)l=8,h=N.setArraySize(s,l,0),d.computeWorldVertices(e.bone,h,0,2);else if(d instanceof Mt){let t=d;l=t.worldVerticesLength,h=N.setArraySize(s,l,0),t.computeWorldVertices(e,0,l,h,0,2)}if(null!=h)for(let t=0,e=h.length;t<e;t+=2){let e=h[t],s=h[t+1];n=Math.min(n,e),r=Math.min(r,s),a=Math.max(a,e),o=Math.max(o,s)}}t.set(n,r),e.set(a-n,o-r)}update(t){this.time+=t}}class he{constructor(){E(this,"minX",0),E(this,"minY",0),E(this,"maxX",0),E(this,"maxY",0),E(this,"boundingBoxes",new Array),E(this,"polygons",new Array),E(this,"polygonPool",new _((()=>N.newFloatArray(16))))}update(t,e){if(null==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],a=e.getAttachment();if(a instanceof At){let t=a;s.push(t);let r=n.obtain();r.length!=t.worldVerticesLength&&(r=N.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 d=(r-e)/l+t;return d>n&&d<a||(d=(o-e)/l+t,d>n&&d<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,d=r[a-2],u=r[a-1];for(let t=0;t<a;t+=2){let a=r[t],c=r[t+1],p=d*c-u*a,m=d-a,g=u-c,f=o*g-l*m,x=(h*m-o*p)/f;if((x>=d&&x<=a||x>=a&&x<=d)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*g-l*p)/f;if((t>=u&&t<=c||t>=c&&t<=u)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}d=a,u=c}return!1}getPolygon(t){if(null==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}}class de{constructor(){E(this,"convexPolygons",new Array),E(this,"convexPolygonsIndices",new Array),E(this,"indicesArray",new Array),E(this,"isConcaveArray",new Array),E(this,"triangles",new Array),E(this,"polygonPool",new _((()=>new Array))),E(this,"polygonIndicesPool",new _((()=>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]=de.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,d=e[r],u=e[r+1],c=e[l],p=e[l+1],m=e[h],g=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(de.positiveArea(m,g,d,u,s,a)&&de.positiveArea(d,u,c,p,s,a)&&de.positiveArea(c,p,m,g,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]=de.isConcave(l,s,e,i),n[h]=de.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,d=e[t+1]<<1,u=e[t+2]<<1,c=s[h],p=s[h+1],m=s[d],g=s[d+1],f=s[u],x=s[u+1],w=!1;if(o==h){let t=a.length-4,e=de.winding(a[t],a[t+1],a[t+2],a[t+3],f,x),s=de.winding(f,x,a[0],a[1],a[2],a[3]);e==l&&s==l&&(a.push(f),a.push(x),r.push(u),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(c),a.push(p),a.push(m),a.push(g),a.push(f),a.push(x),r=this.polygonIndicesPool.obtain(),r.length=0,r.push(h),r.push(d),r.push(u),l=de.winding(c,p,m,g,f,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],d=a[l+1],u=a[l+2],c=a[l+3],p=a[0],m=a[1],g=a[2],f=a[3],x=de.winding(h,d,u,c,p,m);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],E=e[2],y=i[l],T=y[y.length-2],A=y[y.length-1];if(w!=s||b!=o)continue;let C=de.winding(h,d,u,c,T,A),M=de.winding(T,A,p,m,g,f);C==x&&M==x&&(y.length=0,e.length=0,a.push(T),a.push(A),r.push(E),h=u,d=c,u=T,c=A,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 ue{constructor(){E(this,"triangulator",new de),E(this,"clippingPolygon",new Array),E(this,"clipOutput",new Array),E(this,"clippedVertices",new Array),E(this,"clippedUVs",new Array),E(this,"clippedTriangles",new Array),E(this,"scratch",new Array),E(this,"clipAttachment"),E(this,"clippingPolygons")}clipStart(t,e){if(null!=this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=N.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;ue.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];ue.makeClockwise(e),e.push(e[0]),e.push(e[1])}return r.length}clipEndWithSlot(t){null!=this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){null!=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=this.clipOutput,h=this.clippedVertices,d=this.clippedTriangles,u=this.clippingPolygons,c=this.clippingPolygons.length,p=o?12:8,m=0;h.length=0,d.length=0;t:for(let e=0;e<i;e+=3){let i=s[e]<<1,g=t[i],f=t[i+1],x=n[i],w=n[i+1];i=s[e+1]<<1;let b=t[i],E=t[i+1],y=n[i],T=n[i+1];i=s[e+2]<<1;let A=t[i],C=t[i+1],M=n[i],S=n[i+1];for(let t=0;t<c;t++){let e=h.length;if(!this.clip(g,f,b,E,A,C,u[t],l)){let t=N.setArraySize(h,e+3*p);t[e]=g,t[e+1]=f,t[e+2]=r.r,t[e+3]=r.g,t[e+4]=r.b,t[e+5]=r.a,o?(t[e+6]=x,t[e+7]=w,t[e+8]=a.r,t[e+9]=a.g,t[e+10]=a.b,t[e+11]=a.a,t[e+12]=b,t[e+13]=E,t[e+14]=r.r,t[e+15]=r.g,t[e+16]=r.b,t[e+17]=r.a,t[e+18]=y,t[e+19]=T,t[e+20]=a.r,t[e+21]=a.g,t[e+22]=a.b,t[e+23]=a.a,t[e+24]=A,t[e+25]=C,t[e+26]=r.r,t[e+27]=r.g,t[e+28]=r.b,t[e+29]=r.a,t[e+30]=M,t[e+31]=S,t[e+32]=a.r,t[e+33]=a.g,t[e+34]=a.b,t[e+35]=a.a):(t[e+6]=x,t[e+7]=w,t[e+8]=b,t[e+9]=E,t[e+10]=r.r,t[e+11]=r.g,t[e+12]=r.b,t[e+13]=r.a,t[e+14]=y,t[e+15]=T,t[e+16]=A,t[e+17]=C,t[e+18]=r.r,t[e+19]=r.g,t[e+20]=r.b,t[e+21]=r.a,t[e+22]=M,t[e+23]=S),e=d.length;let s=N.setArraySize(d,e+3);s[e]=m,s[e+1]=m+1,s[e+2]=m+2,m+=3;continue t}{let t=l.length;if(0==t)continue;let s=E-C,i=A-b,n=g-A,u=C-f,c=1/(s*n+i*(f-C)),v=t>>1,R=this.clipOutput,P=N.setArraySize(h,e+v*p);for(let l=0;l<t;l+=2){let t=R[l],h=R[l+1];P[e]=t,P[e+1]=h,P[e+2]=r.r,P[e+3]=r.g,P[e+4]=r.b,P[e+5]=r.a;let d=t-A,m=h-C,g=(s*d+i*m)*c,f=(u*d+n*m)*c,b=1-g-f;P[e+6]=x*g+y*f+M*b,P[e+7]=w*g+T*f+S*b,o&&(P[e+8]=a.r,P[e+9]=a.g,P[e+10]=a.b,P[e+11]=a.a),e+=p}e=d.length;let I=N.setArraySize(d,e+3*(v-2));v--;for(let t=1;t<v;t++)I[e]=m,I[e+1]=m+t,I[e+2]=m+t+1,e+=3;m+=v+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,r=this.clippedVertices,a=this.clippedUVs,o=this.clippedTriangles,l=this.clippingPolygons,h=l.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,c=t[s],p=t[s+1],m=i[s],g=i[s+1];s=e[u+1]<<1;let f=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[u+2]<<1;let E=t[s],y=t[s+1],T=i[s],A=i[s+1];for(let t=0;t<h;t++){let e=r.length;if(!this.clip(c,p,f,x,E,y,l[t],n)){let t=N.setArraySize(r,e+6);t[e]=c,t[e+1]=p,t[e+2]=f,t[e+3]=x,t[e+4]=E,t[e+5]=y;let s=N.setArraySize(a,e+6);s[e]=m,s[e+1]=g,s[e+2]=w,s[e+3]=b,s[e+4]=T,s[e+5]=A,e=o.length;let i=N.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=x-y,i=E-f,l=c-E,h=y-p,u=1/(s*l+i*(p-y)),C=t>>1,M=this.clipOutput,S=N.setArraySize(r,e+2*C),v=N.setArraySize(a,e+2*C);for(let n=0;n<t;n+=2,e+=2){let t=M[n],r=M[n+1];S[e]=t,S[e+1]=r;let a=t-E,o=r-y,d=(s*a+i*o)*u,c=(h*a+l*o)*u,p=1-d-c;v[e]=m*d+w*c+T*p,v[e+1]=g*d+b*c+A*p}e=o.length;let R=N.setArraySize(o,e+3*(C-2));C--;for(let t=1;t<C;t++,e+=3)R[e]=d,R[e+1]=d+t,R[e+2]=d+t+1;d+=C+1}}}}clip(t,e,s,i,n,r,a,o){let l=o,h=!1,d=null;a.length%4>=2?(d=o,o=this.scratch):d=this.scratch,d.length=0,d.push(t),d.push(e),d.push(s),d.push(i),d.push(n),d.push(r),d.push(t),d.push(e),o.length=0;let u=a,c=a.length-4;for(let t=0;;t+=2){let e=u[t],s=u[t+1],i=u[t+2],n=u[t+3],r=e-i,a=s-n,p=d,m=d.length-2,g=o.length;for(let t=0;t<m;t+=2){let l=p[t],d=p[t+1],u=p[t+2],c=p[t+3],m=r*(c-n)-a*(u-i)>0;if(r*(d-n)-a*(l-i)>0){if(m){o.push(u),o.push(c);continue}let t=c-d,r=u-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s)}else if(m){let t=c-d,r=u-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s);o.push(u),o.push(c)}h=!0}if(g==o.length)return l.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==c)break;let f=o;(o=d).length=0,d=f}if(l!=o){l.length=0;for(let t=0,e=o.length-2;t<e;t++)l[t]=o[t]}else l.length=l.length-2;return h}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 ce{constructor(){E(this,"name"),E(this,"bones",new Array),E(this,"slots",new Array),E(this,"skins",new Array),E(this,"defaultSkin"),E(this,"events",new Array),E(this,"animations",new Array),E(this,"ikConstraints",new Array),E(this,"transformConstraints",new Array),E(this,"pathConstraints",new Array),E(this,"width"),E(this,"height"),E(this,"version"),E(this,"hash"),E(this,"fps",0),E(this,"imagesPath")}findBone(t){if(null==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}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSlot(t){if(null==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}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSkin(t){if(null==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(null==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(null==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(null==t)throw new 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(null==t)throw new 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(null==t)throw new 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}findPathConstraintIndex(t){if(null==t)throw new Error("pathConstraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}}var pe,me,ge=((pe=ge||{})[pe.Normal=0]="Normal",pe[pe.Additive=1]="Additive",pe[pe.Multiply=2]="Multiply",pe[pe.Screen=3]="Screen",pe);class fe{constructor(t){if(E(this,"name"),E(this,"attachments",new Array),null==t)throw new Error("name cannot be null.");this.name=t}addAttachment(t,e,s){if(null==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}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}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);null!=t&&n.setAttachment(t);break}}}s++}}}class xe{constructor(t,e,s){if(E(this,"index"),E(this,"name"),E(this,"boneData"),E(this,"color",new v(1,1,1,1)),E(this,"darkColor"),E(this,"attachmentName"),E(this,"blendMode"),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");if(null==s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}class we{constructor(t){if(E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"scaleMix",0),E(this,"shearMix",0),E(this,"offsetRotation",0),E(this,"offsetX",0),E(this,"offsetY",0),E(this,"offsetScaleX",0),E(this,"offsetScaleY",0),E(this,"offsetShearY",0),E(this,"relative",!1),E(this,"local",!1),null==t)throw new Error("name cannot be null.");this.name=t}}class be{constructor(t){E(this,"attachmentLoader"),E(this,"scale",1),E(this,"linkedMeshes",new Array),this.attachmentLoader=t}readSkeletonData(t){let e=this.scale,s=new ce,i="string"==typeof t?JSON.parse(t):t,n=i.skeleton;if(null!=n&&(s.hash=n.hash,s.version=n.spine,s.width=n.width,s.height=n.height,s.fps=n.fps,s.imagesPath=n.images),i.bones)for(let t=0;t<i.bones.length;t++){let n=i.bones[t],r=null,a=this.getValue(n,"parent",null);if(null!=a&&(r=s.findBone(a),null==r))throw new Error("Parent bone not found: "+a);let o=new kt(s.bones.length,n.name,r);o.length=this.getValue(n,"length",0)*e,o.x=this.getValue(n,"x",0)*e,o.y=this.getValue(n,"y",0)*e,o.rotation=this.getValue(n,"rotation",0),o.scaleX=this.getValue(n,"scaleX",1),o.scaleY=this.getValue(n,"scaleY",1),o.shearX=this.getValue(n,"shearX",0),o.shearY=this.getValue(n,"shearY",0),o.transformMode=be.transformModeFromString(this.getValue(n,"transform","normal")),s.bones.push(o)}if(i.slots)for(let t=0;t<i.slots.length;t++){let e=i.slots[t],n=e.name,r=e.bone,a=s.findBone(r);if(null==a)throw new Error("Slot bone not found: "+r);let o=new xe(s.slots.length,n,a),l=this.getValue(e,"color",null);null!=l&&o.color.setFromString(l);let h=this.getValue(e,"dark",null);null!=h&&(o.darkColor=new v(1,1,1,1),o.darkColor.setFromString(h)),o.attachmentName=this.getValue(e,"attachment",null),o.blendMode=be.blendModeFromString(this.getValue(e,"blend","normal")),s.slots.push(o)}if(i.ik)for(let t=0;t<i.ik.length;t++){let e=i.ik[t],n=new Zt(e.name);n.order=this.getValue(e,"order",0);for(let t=0;t<e.bones.length;t++){let i=e.bones[t],r=s.findBone(i);if(null==r)throw new Error("IK bone not found: "+i);n.bones.push(r)}let r=e.target;if(n.target=s.findBone(r),null==n.target)throw new Error("IK target bone not found: "+r);n.bendDirection=this.getValue(e,"bendPositive",!0)?1:-1,n.mix=this.getValue(e,"mix",1),s.ikConstraints.push(n)}if(i.transform)for(let t=0;t<i.transform.length;t++){let n=i.transform[t],r=new we(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findBone(a),null==r.target)throw new Error("Transform constraint target bone not found: "+a);r.local=this.getValue(n,"local",!1),r.relative=this.getValue(n,"relative",!1),r.offsetRotation=this.getValue(n,"rotation",0),r.offsetX=this.getValue(n,"x",0)*e,r.offsetY=this.getValue(n,"y",0)*e,r.offsetScaleX=this.getValue(n,"scaleX",0),r.offsetScaleY=this.getValue(n,"scaleY",0),r.offsetShearY=this.getValue(n,"shearY",0),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),r.scaleMix=this.getValue(n,"scaleMix",1),r.shearMix=this.getValue(n,"shearMix",1),s.transformConstraints.push(r)}if(i.path)for(let t=0;t<i.path.length;t++){let n=i.path[t],r=new Jt(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findSlot(a),null==r.target)throw new Error("Path target slot not found: "+a);r.positionMode=be.positionModeFromString(this.getValue(n,"positionMode","percent")),r.spacingMode=be.spacingModeFromString(this.getValue(n,"spacingMode","length")),r.rotateMode=be.rotateModeFromString(this.getValue(n,"rotateMode","tangent")),r.offsetRotation=this.getValue(n,"rotation",0),r.position=this.getValue(n,"position",0),r.positionMode==ee.Fixed&&(r.position*=e),r.spacing=this.getValue(n,"spacing",0),r.spacingMode!=se.Length&&r.spacingMode!=se.Fixed||(r.spacing*=e),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),s.pathConstraints.push(r)}if(i.skins)for(let t in i.skins){let e=i.skins[t],n=new fe(t);for(let t in e){let i=s.findSlotIndex(t);if(-1==i)throw new Error("Slot not found: "+t);let r=e[t];for(let t in r){let e=this.readAttachment(r[t],n,i,t,s);null!=e&&n.addAttachment(i,t,e)}}s.skins.push(n),"default"==n.name&&(s.defaultSkin=n)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],i=null==e.skin?s.defaultSkin:s.findSkin(e.skin);if(null==i)throw new Error("Skin not found: "+e.skin);let n=i.getAttachment(e.slotIndex,e.parent);if(null==n)throw new Error("Parent mesh not found: "+e.parent);e.mesh.setParentMesh(n),e.mesh.updateUVs()}if(this.linkedMeshes.length=0,i.events)for(let t in i.events){let e=i.events[t],n=new zt(t);n.intValue=this.getValue(e,"int",0),n.floatValue=this.getValue(e,"float",0),n.stringValue=this.getValue(e,"string",""),s.events.push(n)}if(i.animations)for(let t in i.animations){let e=i.animations[t];this.readAnimation(e,t,s)}return s}readAttachment(t,e,s,i,n){let r=this.scale;switch(i=this.getValue(t,"name",i),this.getValue(t,"type","region")){case"region":{let s=this.getValue(t,"path",i),n=this.attachmentLoader.newRegionAttachment(e,i,s);if(null==n)return null;n.path=s,n.x=this.getValue(t,"x",0)*r,n.y=this.getValue(t,"y",0)*r,n.scaleX=this.getValue(t,"scaleX",1),n.scaleY=this.getValue(t,"scaleY",1),n.rotation=this.getValue(t,"rotation",0),n.width=t.width*r,n.height=t.height*r;let a=this.getValue(t,"color",null);return null!=a&&n.color.setFromString(a),n.updateOffset(),n}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(null==s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=this.getValue(t,"path",i),r=this.attachmentLoader.newMeshAttachment(e,i,n);if(null==r)return null;r.path=n;let a=this.getValue(t,"color",null);null!=a&&r.color.setFromString(a);let o=this.getValue(t,"parent",null);if(null!=o)return r.inheritDeform=this.getValue(t,"deform",!0),this.linkedMeshes.push(new Ee(r,this.getValue(t,"skin",null),s,o)),r;let l=t.uvs;return this.readVertices(t,r,l.length),r.triangles=t.triangles,r.regionUVs=l,r.updateUVs(),r.hullLength=2*this.getValue(t,"hull",0),r}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(null==s)return null;s.closed=this.getValue(t,"closed",!1),s.constantSpeed=this.getValue(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let a=N.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)a[e]=t.lengths[e]*r;s.lengths=a;let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(null==s)return null;s.x=this.getValue(t,"x",0)*r,s.y=this.getValue(t,"y",0)*r,s.rotation=this.getValue(t,"rotation",0);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(null==s)return null;let r=this.getValue(t,"end",null);if(null!=r){let t=n.findSlot(r);if(null==t)throw new Error("Clipping end slot not found: "+r);s.endSlot=t}let a=t.vertexCount;this.readVertices(t,s,a<<1);let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}}return null}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=N.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=N.toFloatArray(r)}readAnimation(t,e,s){let i=this.scale,n=new Array,r=0;if(t.slots)for(let e in t.slots){let i=t.slots[e],a=s.findSlotIndex(e);if(-1==a)throw new Error("Slot not found: "+e);for(let t in i){let s=i[t];if("attachment"==t){let t=new st(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e++,n.time,n.name)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}else if("color"==t){let t=new K(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new v;r.setFromString(n.color),t.setFrame(e,n.time,r.r,r.g,r.b,r.a),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*K.ENTRIES])}else{if("twoColor"!=t)throw new Error("Invalid timeline type for a slot: "+t+" ("+e+")");{let t=new et(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new v,a=new v;r.setFromString(n.light),a.setFromString(n.dark),t.setFrame(e,n.time,r.r,r.g,r.b,r.a,a.r,a.g,a.b),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*et.ENTRIES])}}}}if(t.bones)for(let e in t.bones){let a=t.bones[e],o=s.findBoneIndex(e);if(-1==o)throw new Error("Bone not found: "+e);for(let t in a){let s=a[t];if("rotate"===t){let t=new $(s.length);t.boneIndex=o;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e,n.time,n.angle),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*$.ENTRIES])}else{if("translate"!==t&&"scale"!==t&&"shear"!==t)throw new Error("Invalid timeline type for a bone: "+t+" ("+e+")");{let e=null,a=1;"scale"===t?e=new Z(s.length):"shear"===t?e=new J(s.length):(e=new H(s.length),a=i),e.boneIndex=o;let l=0;for(let t=0;t<s.length;t++){let i=s[t],n=this.getValue(i,"x",0),r=this.getValue(i,"y",0);e.setFrame(l,i.time,n*a,r*a),this.readCurve(i,e,l),l++}n.push(e),r=Math.max(r,e.frames[(e.getFrameCount()-1)*H.ENTRIES])}}}}if(t.ik)for(let e in t.ik){let i=t.ik[e],a=s.findIkConstraint(e),o=new lt(i.length);o.ikConstraintIndex=s.ikConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"mix",1),this.getValue(e,"bendPositive",!0)?1:-1),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*lt.ENTRIES])}if(t.transform)for(let e in t.transform){let i=t.transform[e],a=s.findTransformConstraint(e),o=new dt(i.length);o.transformConstraintIndex=s.transformConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"rotateMix",1),this.getValue(e,"translateMix",1),this.getValue(e,"scaleMix",1),this.getValue(e,"shearMix",1)),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*dt.ENTRIES])}if(t.paths)for(let e in t.paths){let a=t.paths[e],o=s.findPathConstraintIndex(e);if(-1==o)throw new Error("Path constraint not found: "+e);let l=s.pathConstraints[o];for(let t in a){let e=a[t];if("position"===t||"spacing"===t){let s=null,a=1;"spacing"===t?(s=new pt(e.length),l.spacingMode!=se.Length&&l.spacingMode!=se.Fixed||(a=i)):(s=new ct(e.length),l.positionMode==ee.Fixed&&(a=i)),s.pathConstraintIndex=o;let h=0;for(let i=0;i<e.length;i++){let n=e[i];s.setFrame(h,n.time,this.getValue(n,t,0)*a),this.readCurve(n,s,h),h++}n.push(s),r=Math.max(r,s.frames[(s.getFrameCount()-1)*ct.ENTRIES])}else if("mix"===t){let t=new gt(e.length);t.pathConstraintIndex=o;let s=0;for(let i=0;i<e.length;i++){let n=e[i];t.setFrame(s,n.time,this.getValue(n,"rotateMix",1),this.getValue(n,"translateMix",1)),this.readCurve(n,t,s),s++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*gt.ENTRIES])}}}if(t.deform)for(let e in t.deform){let a=t.deform[e],o=s.findSkin(e);if(null==o)throw new Error("Skin not found: "+e);for(let t in a){let e=a[t],l=s.findSlotIndex(t);if(-1==l)throw new Error("Slot not found: "+e.name);for(let t in e){let s=e[t],a=o.getAttachment(l,t);if(null==a)throw new Error("Deform attachment not found: "+s.name);let h=null!=a.bones,d=a.vertices,u=h?d.length/3*2:d.length,c=new nt(s.length);c.slotIndex=l,c.attachment=a;let p=0;for(let t=0;t<s.length;t++){let e,n=s[t],r=this.getValue(n,"vertices",null);if(null==r)e=h?N.newFloatArray(u):d;else{e=N.newFloatArray(u);let t=this.getValue(n,"offset",0);if(N.arrayCopy(r,0,e,t,r.length),1!=i)for(let s=t,n=s+r.length;s<n;s++)e[s]*=i;if(!h)for(let t=0;t<u;t++)e[t]+=d[t]}c.setFrame(p,n.time,e),this.readCurve(n,c,p),p++}n.push(c),r=Math.max(r,c.frames[c.getFrameCount()-1])}}}let a=t.drawOrder;if(null==a&&(a=t.draworder),null!=a){let t=new at(a.length),e=s.slots.length,i=0;for(let n=0;n<a.length;n++){let r=a[n],o=null,l=this.getValue(r,"offsets",null);if(null!=l){o=N.newArray(e,-1);let t=N.newArray(e-l.length,0),i=0,n=0;for(let e=0;e<l.length;e++){let r=l[e],a=s.findSlotIndex(r.slot);if(-1==a)throw new Error("Slot not found: "+r.slot);for(;i!=a;)t[n++]=i++;o[i+r.offset]=i++}for(;i<e;)t[n++]=i++;for(let s=e-1;s>=0;s--)-1==o[s]&&(o[s]=t[--n])}t.setFrame(i++,r.time,o)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}if(t.events){let e=new rt(t.events.length),i=0;for(let n=0;n<t.events.length;n++){let r=t.events[n],a=s.findEvent(r.name);if(null==a)throw new Error("Event not found: "+r.name);let o=new $t(N.toSinglePrecision(r.time),a);o.intValue=this.getValue(r,"int",a.intValue),o.floatValue=this.getValue(r,"float",a.floatValue),o.stringValue=this.getValue(r,"string",a.stringValue),e.setFrame(i++,o)}n.push(e),r=Math.max(r,e.frames[e.getFrameCount()-1])}if(isNaN(r))throw new Error("Error while parsing animation, duration is NaN");s.animations.push(new O(e,n,r))}readCurve(t,e,s){if(t.curve)if("stepped"===t.curve)e.setStepped(s);else if("[object Array]"===Object.prototype.toString.call(t.curve)){let i=t.curve;e.setCurve(s,i[0],i[1],i[2],i[3])}}getValue(t,e,s){return void 0!==t[e]?t[e]:s}static blendModeFromString(t){if("normal"==(t=t.toLowerCase()))return ge.Normal;if("additive"==t)return ge.Additive;if("multiply"==t)return ge.Multiply;if("screen"==t)return ge.Screen;throw new Error(`Unknown blend mode: ${t}`)}static positionModeFromString(t){if("fixed"==(t=t.toLowerCase()))return ee.Fixed;if("percent"==t)return ee.Percent;throw new Error(`Unknown position mode: ${t}`)}static spacingModeFromString(t){if("length"==(t=t.toLowerCase()))return se.Length;if("fixed"==t)return se.Fixed;if("percent"==t)return se.Percent;throw new Error(`Unknown position mode: ${t}`)}static rotateModeFromString(t){if("tangent"==(t=t.toLowerCase()))return ie.Tangent;if("chain"==t)return ie.Chain;if("chainscale"==t)return ie.ChainScale;throw new Error(`Unknown rotate mode: ${t}`)}static transformModeFromString(t){if("normal"==(t=t.toLowerCase()))return Dt.Normal;if("onlytranslation"==t)return Dt.OnlyTranslation;if("norotationorreflection"==t)return Dt.NoRotationOrReflection;if("noscale"==t)return Dt.NoScale;if("noscaleorreflection"==t)return Dt.NoScaleOrReflection;throw new Error(`Unknown transform mode: ${t}`)}}class Ee{constructor(t,e,s,i){E(this,"parent"),E(this,"skin"),E(this,"slotIndex"),E(this,"mesh"),this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i}}Math.fround||(Math.fround=(me=new Float32Array(1),function(t){return me[0]=t,me[0]}));class ye{constructor(t){E(this,"clientId"),E(this,"toLoad",new Array),E(this,"assets",{}),E(this,"textureLoader"),this.clientId=t}loaded(){var t=0;for(var e in this.assets)t++;return t}}const Te=class t{constructor(t){E(this,"centerX",0),E(this,"centerY",0),E(this,"radius",0),E(this,"angle",0),E(this,"worldX",0),E(this,"worldY",0),this.radius=t}begin(t){this.worldX=t.x+this.centerX,this.worldY=t.y+this.centerY}transform(e,s,i,n){let r=this.angle*P.degreesToRadians,a=e.x-this.worldX,o=e.y-this.worldY,l=Math.sqrt(a*a+o*o);if(l<this.radius){let s=t.interpolation.apply(0,r,(this.radius-l)/this.radius),i=Math.cos(s),n=Math.sin(s);e.x=i*a-n*o+this.worldX,e.y=n*a+i*o+this.worldY}}end(){}};E(Te,"interpolation",new V(2));let Ae=Te;const Ce=class t extends _t{constructor(t){super(t.resource),E(this,"texture"),this.texture=i.Texture.from(t)}static from(e){return t.textureMap.has(e)?t.textureMap.get(e):new t(e)}setFilters(e,s){const i=this.texture.source.style;i.minFilter=t.toPixiTextureFilter(e),i.magFilter=t.toPixiTextureFilter(s),this.texture.source.autoGenerateMipmaps=t.toPixiMipMap(e),this.texture.source.updateMipmaps()}setWraps(e,s){const i=this.texture.source.style;i.addressModeU=t.toPixiTextureWrap(e),i.addressModeV=t.toPixiTextureWrap(s)}dispose(){this.texture.destroy()}static toPixiMipMap(t){switch(t){case Yt.Nearest:case Yt.Linear:return!1;case Yt.MipMapNearestLinear:case Yt.MipMapNearestNearest:case Yt.MipMapLinearLinear:case Yt.MipMapLinearNearest:return!0;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureFilter(t){switch(t){case Yt.Nearest:case Yt.MipMapNearestLinear:case Yt.MipMapNearestNearest:return"nearest";case Yt.Linear:case Yt.MipMapLinearLinear:case Yt.MipMapLinearNearest:return"linear";default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case Ft.ClampToEdge:return"clamp-to-edge";case Ft.MirroredRepeat:return"mirror-repeat";case Ft.Repeat:return"repeat";default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case ge.Normal:return"normal";case ge.Additive:return"add";case ge.Multiply:return"multiply";case ge.Screen:return"screen";default:throw new Error(`Unknown blendMode: ${String(t)}`)}}};E(Ce,"textureMap",new Map);let Me=Ce;const Se={extension:i.ExtensionType.Asset,resolver:{test:t=>i.checkExtension(t,".atlas"),parse:t=>{var e,s,n;const r=t.split(".");return{resolution:parseFloat(null!=(n=null==(s=null==(e=i.Resolver.RETINA_PREFIX)?void 0:e.exec(t))?void 0:s[1])?n:"1"),format:r[r.length-2],src:t}}},loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineTextureAtlasLoader"},test:t=>i.checkExtension(t,".atlas"),load(t){return y(this,null,(function*(){const e=yield i.DOMAdapter.get().fetch(t);return yield e.text()}))},testParse(t,e){const s=i.checkExtension(e.src,".atlas"),n="string"==typeof t;return Promise.resolve(s&&n)},unload(t){t.dispose()},parse(t,e,s){return y(this,null,(function*(){var n;const r=e.data||{};let a=i.path.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");const o=new Wt(t,(t=>Me.from(e.data.imageTexture.source)));if(r.images instanceof i.TextureSource||"string"==typeof r.images){const t=r.images;r.images={},r.images[o.pages[0].name]=t}const l=[];for(const t of o.pages){if(r.resolve){const e=null==(n=r.resolve())?void 0:n.then((e=>{e&&t.setTexture(Me.from(e.source))}));l.push(e);continue}const o=t.name,u=(null==r?void 0:r.images)?r.images[o]:void 0;if(u instanceof i.TextureSource)t.setTexture(Me.from(u));else{const n=null!=u?u:i.path.normalize([...a.split(i.path.sep),o].join(i.path.sep)),c={src:i.copySearchParams(n,e.src),data:(h=b({},r.imageMetadata),d={alphaMode:t.pma?"premultiplied-alpha":"premultiply-alpha-on-upload"},p(h,m(d)))},g=s.load(c).then((e=>{t.setTexture(Me.from(e.source))}));l.push(g)}}var h,d;return yield Promise.all(l),o}))}}};i.extensions.add(Se);const ve={extension:i.ExtensionType.Asset,loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineSkeletonLoader"},test:t=>i.checkExtension(t,".skel"),load(t){return y(this,null,(function*(){const e=yield i.DOMAdapter.get().fetch(t);return new Uint8Array(yield e.arrayBuffer())}))},testParse(t,e){const s=i.checkExtension(e.src,".json")&&(n=t,Object.prototype.hasOwnProperty.call(n,"bones"));var n;const r=i.checkExtension(e.src,".skel")&&function(t){return t instanceof Uint8Array}(t);return Promise.resolve(s||r)}}};i.extensions.add(ve);const Re=new Float32Array(1),Pe=new Uint32Array(1);class Ie extends i.Geometry{constructor(){const t=new i.Buffer({data:Re,label:"attribute-batch-buffer",usage:i.BufferUsage.VERTEX|i.BufferUsage.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:28,offset:0},aUV:{buffer:t,format:"float32x2",stride:28,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:28,offset:16},aDarkColor:{buffer:t,format:"unorm8x4",stride:28,offset:20},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:28,offset:24}},indexBuffer:new i.Buffer({data:Pe,label:"index-batch-buffer",usage:i.BufferUsage.INDEX|i.BufferUsage.COPY_DST,shrinkToFit:!1})})}}const ke={name:"color-bit",vertex:{header:"\n @in aDarkColor: vec4<f32>;\n @out vDarkColor: vec4<f32>;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n @in vDarkColor: vec4<f32>;\n ",end:"\n\n let alpha = outColor.a * vColor.a;\n let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n\n finalColor = vec4<f32>(rgb, alpha);\n\n "}},Ve={name:"color-bit",vertex:{header:"\n in vec4 aDarkColor;\n out vec4 vDarkColor;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n in vec4 vDarkColor;\n ",end:"\n\n finalColor.a = outColor.a * vColor.a;\n finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n "}};class De extends i.Shader{constructor(t){super({glProgram:i.compileHighShaderGlProgram({name:"dark-tint-batch",bits:[i.colorBitGl,Ve,i.generateTextureBatchBitGl(t),i.roundPixelsBitGl]}),gpuProgram:i.compileHighShaderGpuProgram({name:"dark-tint-batch",bits:[i.colorBit,ke,i.generateTextureBatchBit(t),i.roundPixelsBit]}),resources:{batchSamplers:i.getBatchSamplersUniformGroup(t)}})}}let Ne=null;const _e=class t extends i.Batcher{constructor(){super(...arguments),E(this,"geometry",new Ie),E(this,"shader",Ne||(Ne=new De(this.maxTextures))),E(this,"name",t.extension.name),E(this,"vertexSize",7)}packAttributes(t,e,s,n,r){const a=r<<16|65535&t.roundPixels,o=t.transform,l=o.a,h=o.b,d=o.c,u=o.d,c=o.tx,p=o.ty,{positions:m,uvs:g}=t,f=t.color,x=(f>>24&255)/255,w=i.Color.shared.setValue(t.darkColor).premultiply(x,!0).toPremultiplied(1,!1),b=t.attributeOffset,E=b+t.attributeSize;for(let t=b;t<E;t++){const i=2*t,r=m[i],o=m[i+1];e[n++]=l*r+d*o+c,e[n++]=u*o+h*r+p,e[n++]=g[i],e[n++]=g[i+1],s[n++]=f,s[n++]=w,s[n++]=a}}packQuadAttributes(t,e,s,i,n){const r=t.texture,a=t.transform,o=a.a,l=a.b,h=a.c,d=a.d,u=a.tx,c=a.ty,p=t.bounds,m=p.maxX,g=p.minX,f=p.maxY,x=p.minY,w=r.uvs,b=t.color,E=t.darkColor,y=n<<16|65535&t.roundPixels;e[i+0]=o*g+h*x+u,e[i+1]=d*x+l*g+c,e[i+2]=w.x0,e[i+3]=w.y0,s[i+4]=b,s[i+5]=E,s[i+6]=y,e[i+7]=o*m+h*x+u,e[i+8]=d*x+l*m+c,e[i+9]=w.x1,e[i+10]=w.y1,s[i+11]=b,s[i+12]=E,s[i+13]=y,e[i+14]=o*m+h*f+u,e[i+15]=d*f+l*m+c,e[i+16]=w.x2,e[i+17]=w.y2,s[i+18]=b,s[i+19]=E,s[i+20]=y,e[i+21]=o*g+h*f+u,e[i+22]=d*f+l*g+c,e[i+23]=w.x3,e[i+24]=w.y3,s[i+25]=b,s[i+26]=E,s[i+27]=y}};E(_e,"extension",{type:[i.ExtensionType.Batcher],name:"darkTint"});let Le=_e;i.extensions.add(Le);class Oe{constructor(){E(this,"indexOffset",0),E(this,"attributeOffset",0),E(this,"indexSize"),E(this,"attributeSize"),E(this,"batcherName","darkTint"),E(this,"topology","triangle-list"),E(this,"packAsQuad",!1),E(this,"renderable"),E(this,"positions"),E(this,"indices"),E(this,"uvs"),E(this,"roundPixels"),E(this,"data"),E(this,"blendMode"),E(this,"darkTint"),E(this,"texture"),E(this,"transform"),E(this,"_textureId"),E(this,"_attributeStart"),E(this,"_indexStart"),E(this,"_batcher"),E(this,"_batch")}get color(){const t=this.data.color,e=this.renderable.groupColor,s=this.renderable.groupAlpha;let i;const n=t.a*s*255;if(16777215!==e){const s=e>>16&255,r=e>>8&255,a=255&e,o=t.r*a,l=t.g*r;i=n<<24|t.b*s<<16|l<<8|o}else i=n<<24|255*t.b<<16|255*t.g<<8|255*t.r;return i}get darkColor(){const t=this.data.darkColor;return 255*t.b<<16|255*t.g<<8|255*t.r}get groupTransform(){return this.renderable.groupTransform}setData(t,e,s,i){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const t=e.clippedData;this.indexSize=t.indicesCount,this.attributeSize=t.vertexCount,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=i,this.blendMode=s,this.batcherName=e.darkTint?"darkTint":"default"}}const Ye={0:"normal",1:"add",2:"multiply",3:"screen"};class Fe{constructor(t){E(this,"renderer"),E(this,"gpuSpineData",{}),E(this,"_destroyRenderableBound",this.destroyRenderable.bind(this)),this.renderer=t}validateRenderable(t){if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,s=this.gpuSpineData[t.uid];for(let i=0,n=e.length;i<n;i++){const n=e[i],r=n.getAttachment();if(r instanceof Pt||r instanceof Mt){const e=t._getCachedData(n,r),i=s.slotBatches[e.id],a=e.texture;if(a!==i.texture&&!i._batcher.checkAndUpdateTexture(i,a))return!0}}}return!1}addRenderable(t,e){var s,n;const r=this._getSpineData(t),a=this.renderer.renderPipes.batch,o=t.skeleton.drawOrder,l=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments();for(let h=0,d=o.length;h<d;h++){const d=o[h],u=d.getAttachment(),c=Ye[d.data.blendMode];if(u instanceof Pt||u instanceof Mt){const i=t._getCachedData(d,u),o=(s=r.slotBatches)[n=i.id]||(s[n]=new Oe);o.setData(t,i,c,l),i.skipRender||a.addToBatch(o,e)}const p=t._slotsObject[d.data.name];if(p){const t=p.container;t.includeInBuild=!0,i.collectAllRenderables(t,e,this.renderer),t.includeInBuild=!1}}}updateRenderable(t){var e;const s=this.gpuSpineData[t.uid];t._validateAndTransformAttachments();const i=t.skeleton.drawOrder;for(let n=0,r=i.length;n<r;n++){const r=i[n],a=r.getAttachment();if(a instanceof Pt||a instanceof Mt){if(!t._getCachedData(r,a).skipRender){const i=s.slotBatches[t._getCachedData(r,a).id];null==(e=i._batcher)||e.updateElement(i)}}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}}E(Fe,"extension",{type:[i.ExtensionType.WebGLPipes,i.ExtensionType.WebGPUPipes,i.ExtensionType.CanvasPipes],name:"spine"}),i.extensions.add(Fe);const Xe=new L,Be=new ue,We=new _((()=>new i.Graphics));class Ue extends i.ViewContainer{constructor(t){var e;t instanceof ce&&(t={skeletonData:t}),super(),E(this,"batched",!0),E(this,"buildId",0),E(this,"renderPipeId","spine"),E(this,"_didSpineUpdate",!1),E(this,"beforeUpdateWorldTransforms",(()=>{})),E(this,"afterUpdateWorldTransforms",(()=>{})),E(this,"skeleton"),E(this,"state"),E(this,"skeletonBounds"),E(this,"darkTint",!1),E(this,"_debug"),E(this,"_slotsObject",Object.create(null)),E(this,"clippingSlotToPixiMasks",Object.create(null)),E(this,"spineAttachmentsDirty",!0),E(this,"spineTexturesDirty",!0),E(this,"_lastAttachments",[]),E(this,"_stateChanged",!0),E(this,"attachmentCacheData",[]),E(this,"_autoUpdate",!1),E(this,"hasNeverUpdated",!0),E(this,"currentClippingSlot");const s=t instanceof ce?t:t.skeletonData;this.skeleton=new le(s),this.skeleton.flipY=!0,this.state=new xt(new Tt(s)),this.autoUpdate=null==(e=null==t?void 0:t.autoUpdate)||e,this.darkTint=void 0===(null==t?void 0:t.darkTint)?this.skeleton.slots.some((t=>!!t.data.darkColor)):null==t?void 0:t.darkTint;const i=this.skeleton.slots;for(let t=0;t<i.length;t++)this.attachmentCacheData[t]=Object.create(null)}getSlotFromRef(t){let e;if(e="number"==typeof t?this.skeleton.slots[t]:"string"==typeof t?this.skeleton.findSlot(t):t,!e)throw new Error(`No slot found with the given slot reference: ${t}`);return e}get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t&&!this._autoUpdate?i.Ticker.shared.add(this.internalUpdate,this):i.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=t}update(t){this.internalUpdate(0,t)}internalUpdate(t,e){this._updateAndApplyState(null!=e?e:i.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,e){const s=t;if("string"==typeof t&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(s)} not found`);if(Xe.set(e.x,e.y),t.parent){const e=t.parent.worldToLocal(Xe);t.x=e.x,t.y=-e.y}else t.x=Xe.x,t.y=Xe.y}getBonePosition(t,e){const s=t;return"string"==typeof t&&(t=this.skeleton.findBone(t)),t?(e||(e={x:0,y:0}),e.x=t.worldX,e.y=t.worldY,e):(console.error(`Cant set bone position! Bone ${String(s)} not found`),e)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:e}=this;this.state.apply(e),this.beforeUpdateWorldTransforms(this),e.updateWorldTransform(),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this._boundsDirty=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder,e=this._lastAttachments;let s=0,i=!1;for(let n=0;n<t.length;n++){const r=t[n].getAttachment();r&&(r!==e[s]&&(i=!0,e[s]=r),s++)}s!==e.length&&(i=!0,e.length=s),this.spineAttachmentsDirty=i}updateAndSetPixiMask(t,e){var s,i;const n=t.attachment;if(n&&n instanceof Ct){return((s=this.clippingSlotToPixiMasks)[i=t.data.name]||(s[i]={slot:t,vertices:new Array})).maskComputed=!1,void(this.currentClippingSlot=this.clippingSlotToPixiMasks[t.data.name])}let r=this.currentClippingSlot,a=this._slotsObject[t.data.name];if(r&&a){let t=r.slot,e=t.attachment,s=r.mask;if(s||(s=We.obtain(),r.mask=s,this.addChild(s)),!r.maskComputed){r.maskComputed=!0;const i=e.worldVerticesLength,n=r.vertices;e.computeWorldVertices(t,0,i,n,0,2),s.clear().poly(n).stroke({width:0}).fill({alpha:.25})}a.container.mask=s}else(null==a?void 0:a.container.mask)&&(a.container.mask=null);if(r&&r.slot.attachment.endSlot==t.data&&(this.currentClippingSlot=void 0),e)for(const t in this.clippingSlotToPixiMasks){const e=this.clippingSlotToPixiMasks[t];e.slot.attachment instanceof Ct&&e.maskComputed||!e.mask||(this.removeChild(e.mask),We.free(e.mask),e.mask=void 0)}}transformAttachments(){var t;const e=this.skeleton.drawOrder;for(let s=0;s<e.length;s++){const n=e[s];this.updateAndSetPixiMask(n,s===e.length-1);const r=n.getAttachment();if(r)if(r instanceof Mt||r instanceof Pt){const e=this._getCachedData(n,r);r instanceof Pt?r.computeWorldVertices(n.bone,e.vertices,0,2):r.computeWorldVertices(n,0,r.worldVerticesLength,e.vertices,0,2),e.uvs.length<r.uvs.length&&(e.uvs=new Float32Array(r.uvs.length)),i.fastCopy(r.uvs.buffer,e.uvs.buffer);const s=n.bone.skeleton.color,a=n.color,o=r.color;e.color.set(s.r*a.r*o.r,s.g*a.g*o.g,s.b*a.b*o.b,s.a*a.a*o.a),n.darkColor&&e.darkColor.setFromColor(n.darkColor),e.skipRender=e.clipped=!1;const l=(null==(t=r.region)?void 0:t.texture.texture)||i.Texture.EMPTY;e.texture!==l&&(e.texture=l,this.spineTexturesDirty=!0),Be.isClipping()&&this.updateClippingData(e)}else if(r instanceof Ct){Be.clipStart(n,r);continue}Be.clipEndWithSlot(n)}Be.clipEnd()}updateClippingData(t){t.clipped=!0,Be.clipTrianglesUnpacked(t.vertices,t.indices,t.indices.length,t.uvs);const{clippedVertices:e,clippedUVs:s,clippedTriangles:i}=Be,n=e.length/2,r=i.length;t.clippedData||(t.clippedData={vertices:new Float32Array(2*n),uvs:new Float32Array(2*n),vertexCount:n,indices:new Uint16Array(r),indicesCount:r},this.spineAttachmentsDirty=!0);const a=t.clippedData,o=a.vertexCount!==n||r!==a.indicesCount;t.skipRender=0===n,o&&(this.spineAttachmentsDirty=!0,a.vertexCount<n&&(a.vertices=new Float32Array(2*n),a.uvs=new Float32Array(2*n)),a.indices.length<r&&(a.indices=new Uint16Array(r)));const{vertices:l,uvs:h,indices:d}=a;for(let t=0;t<n;t++)l[2*t]=e[2*t],l[2*t+1]=e[2*t+1],h[2*t]=s[2*t],h[2*t+1]=s[2*t+1];a.vertexCount=n;for(let t=0;t<r;t++)d[t]!==i[t]&&(this.spineAttachmentsDirty=!0,d[t]=i[t]);a.indicesCount=r}updateSlotObjects(){for(const t in this._slotsObject){const e=this._slotsObject[t];e&&this.updateSlotObject(e)}}updateSlotObject(t){const{slot:e,container:s}=t;if(s.visible=this.skeleton.drawOrder.includes(e),s.visible){const t=e.bone;s.position.set(t.worldX,t.worldY),s.scale.x=t.getWorldScaleX(),s.scale.y=t.getWorldScaleY(),s.rotation=t.getWorldRotationX()*i.DEG_TO_RAD,s.alpha=this.skeleton.color.a*e.color.a}}_getCachedData(t,e){return this.attachmentCacheData[t.data.index][e.name]||this.initCachedData(t,e)}initCachedData(t,e){var s,i;let n;return e instanceof Pt?(n=new Float32Array(8),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(e.uvs.length),color:new v(1,1,1,1),darkColor:new v(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(s=e.region)?void 0:s.texture.texture}):(n=new Float32Array(e.worldVerticesLength),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:e.triangles,uvs:new Float32Array(e.uvs.length),color:new v(1,1,1,1),darkColor:new v(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(i=e.region)?void 0:i.texture.texture}),this.attachmentCacheData[t.data.index][e.name]}onViewUpdate(){var t;if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this),null==(t=this.debug)||t.renderDebug(this)}addSlotObject(t,e){var s;t=this.getSlotFromRef(t);for(const t in this._slotsObject)(null==(s=this._slotsObject[t])?void 0:s.container)===e&&this.removeSlotObject(this._slotsObject[t].slot);this.removeSlotObject(t),e.includeInBuild=!1,this.addChild(e);const i={container:e,slot:t};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){var e,s;let n;if(t instanceof i.Container){for(const s in this._slotsObject)if((null==(e=this._slotsObject[s])?void 0:e.container)===t){this._slotsObject[s]=null,n=t;break}}else{const e=this.getSlotFromRef(t);n=null==(s=this._slotsObject[e.data.name])?void 0:s.container,this._slotsObject[e.data.name]=null}n&&(this.removeChild(n),n.includeInBuild=!0)}getSlotObject(t){var e;return t=this.getSlotFromRef(t),null==(e=this._slotsObject[t.data.name])?void 0:e.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||(this.skeletonBounds=new he);const t=this.skeletonBounds;if(t.update(this.skeleton,!0),t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const t=this.skeleton.drawOrder,e=this._bounds;e.clear();for(let s=0;s<t.length;s++){const i=t[s],n=i.getAttachment();if(n&&(n instanceof Pt||n instanceof Mt)){const t=this._getCachedData(i,n);e.addVertexData(t.vertices,0,t.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),i.Ticker.shared.remove(this.internalUpdate,this),this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this._lastAttachments.length=0,this.attachmentCacheData=null}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,e){this.pixiWorldCoordinatesToSkeleton(t),e.parent?e.parent.worldToLocal(t):e.worldToLocal(t)}static from({skeleton:t,atlas:e,scale:s=1,darkTint:n,autoUpdate:r=!0}){const a=`${t}-${e}-${s}`;if(i.Cache.has(a))return new Ue(i.Cache.get(a));const o=i.Assets.get(t),l=i.Assets.get(e),h=new It(l),d=new be(h).readSkeletonData(o);return i.Cache.set(a,d),new Ue({skeletonData:d,darkTint:n,autoUpdate:r})}}var je=Object.freeze({__proto__:null,Animation:O,AnimationState:xt,AnimationStateAdapter2:class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},AnimationStateData:Tt,AssetManager:Gt,AtlasAttachmentLoader:It,Attachment:T,AttachmentTimeline:st,BlendMode:ge,Bone:Nt,BoneData:kt,BoundingBoxAttachment:At,ClippingAttachment:Ct,Color:v,ColorTimeline:K,CurveTimeline:q,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)}}},DeformTimeline:nt,DrawOrderTimeline:at,Event:$t,EventData:zt,EventQueue:bt,EventTimeline:rt,EventType:yt,FakeTexture:Bt,IkConstraint:Ht,IkConstraintData:Zt,IkConstraintTimeline:lt,IntSet:M,Interpolation:I,JitterEffect:class{constructor(t,e){E(this,"jitterX",0),E(this,"jitterY",0),this.jitterX=t,this.jitterY=e}begin(t){}transform(t,e,s,i){t.x+=P.randomTriangular(-this.jitterX,this.jitterY),t.y+=P.randomTriangular(-this.jitterX,this.jitterY)}end(){}},MathUtils:P,MeshAttachment:Mt,MixDirection:W,MixPose:B,PathAttachment:St,PathConstraint:re,PathConstraintData:Jt,PathConstraintMixTimeline:gt,PathConstraintPositionTimeline:ct,PathConstraintSpacingTimeline:pt,PointAttachment:vt,Pool:_,PositionMode:ee,Pow:k,PowOut:V,RegionAttachment:Pt,RotateMode:ie,RotateTimeline:$,ScaleTimeline:Z,SharedAssetManager:class{constructor(t=""){E(this,"pathPrefix"),E(this,"clientAssets",{}),E(this,"queuedAssets",{}),E(this,"rawAssets",{}),E(this,"errors",{}),this.pathPrefix=t}queueAsset(t,e,s){var i=this.clientAssets[t];return null==i&&(i=new ye(t),this.clientAssets[t]=i),null!==e&&(i.textureLoader=e),i.toLoad.push(s),this.queuedAssets[s]!==s&&(this.queuedAssets[s]=s,!0)}loadText(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=s.responseText:this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadJson(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=JSON.parse(s.responseText):this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadTexture(t,e,s){if(s=this.pathPrefix+s,!this.queueAsset(t,e,s))return;let i=new Image;i.src=s,i.crossOrigin="anonymous",i.onload=t=>{this.rawAssets[s]=i},i.onerror=t=>{this.errors[s]=`Couldn't load image ${s}`}}get(t,e){e=this.pathPrefix+e;var s=this.clientAssets[t];return null==s||s.assets[e]}updateClientAssets(t){for(var e=0;e<t.toLoad.length;e++){var s=t.toLoad[e],i=t.assets[s];if(null==i){var n=this.rawAssets[s];if(null==n)continue;n instanceof HTMLImageElement?t.assets[s]=t.textureLoader(n):t.assets[s]=n}}}isLoadingComplete(t){var e=this.clientAssets[t];return null==e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())}dispose(){}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},ShearTimeline:J,Skeleton:le,SkeletonBounds:he,SkeletonClipping:ue,SkeletonData:ce,SkeletonJson:be,Skin:fe,Slot:ae,SlotData:xe,SpacingMode:se,Spine:Ue,SpineDebugRenderer:class{constructor(){E(this,"registeredSpines",new Map),E(this,"drawMeshHull",!0),E(this,"drawMeshTriangles",!0),E(this,"drawBones",!0),E(this,"drawPaths",!0),E(this,"drawBoundingBoxes",!0),E(this,"drawClipping",!0),E(this,"drawRegionAttachments",!0),E(this,"drawEvents",!0),E(this,"lineWidth",1),E(this,"regionAttachmentsColor",30975),E(this,"meshHullColor",30975),E(this,"meshTrianglesColor",16763904),E(this,"clippingPolygonColor",16711935),E(this,"boundingBoxesRectColor",65280),E(this,"boundingBoxesPolygonColor",65280),E(this,"boundingBoxesCircleColor",65280),E(this,"pathsCurveColor",16711680),E(this,"pathsLineColor",16711935),E(this,"skeletonXYColor",16711680),E(this,"bonesColor",61132),E(this,"eventFontSize",24),E(this,"eventFontColor",0)}registerSpine(t){if(this.registeredSpines.has(t))return void console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",t);const e={parentDebugContainer:new i.Container,bones:new i.Container,skeletonXY:new i.Graphics,regionAttachmentsShape:new i.Graphics,meshTrianglesLine:new i.Graphics,meshHullLine:new i.Graphics,clippingPolygon:new i.Graphics,boundingBoxesRect:new i.Graphics,boundingBoxesCircle:new i.Graphics,boundingBoxesPolygon:new i.Graphics,pathsCurve:new i.Graphics,pathsLine:new i.Graphics,eventText:new i.Container,eventCallback:{event:(s,n)=>{if(this.drawEvents){const s=Math.abs(t.scale.x||t.scale.y||1),r=new i.Text({text:n.data.name,style:{fontSize:this.eventFontSize/s,fill:this.eventFontColor,fontFamily:"monospace"}});r.scale.x=Math.sign(t.scale.x),r.anchor.set(.5),e.eventText.addChild(r),setTimeout((()=>{r.destroyed||r.destroy()}),250)}}}};e.parentDebugContainer.addChild(e.bones),e.parentDebugContainer.addChild(e.skeletonXY),e.parentDebugContainer.addChild(e.regionAttachmentsShape),e.parentDebugContainer.addChild(e.meshTrianglesLine),e.parentDebugContainer.addChild(e.meshHullLine),e.parentDebugContainer.addChild(e.clippingPolygon),e.parentDebugContainer.addChild(e.boundingBoxesRect),e.parentDebugContainer.addChild(e.boundingBoxesCircle),e.parentDebugContainer.addChild(e.boundingBoxesPolygon),e.parentDebugContainer.addChild(e.pathsCurve),e.parentDebugContainer.addChild(e.pathsLine),e.parentDebugContainer.addChild(e.eventText),e.parentDebugContainer.zIndex=9999999,e.parentDebugContainer.accessibleChildren=!1,e.parentDebugContainer.eventMode="none",e.parentDebugContainer.interactiveChildren=!1,t.addChild(e.parentDebugContainer),t.state.addListener(e.eventCallback),this.registeredSpines.set(t,e)}renderDebug(t){this.registeredSpines.has(t)||this.registerSpine(t);const e=this.registeredSpines.get(t);if(!e)return;t.addChild(e.parentDebugContainer),e.skeletonXY.clear(),e.regionAttachmentsShape.clear(),e.meshTrianglesLine.clear(),e.meshHullLine.clear(),e.clippingPolygon.clear(),e.boundingBoxesRect.clear(),e.boundingBoxesCircle.clear(),e.boundingBoxesPolygon.clear(),e.pathsCurve.clear(),e.pathsLine.clear();for(let t=e.bones.children.length;t>0;t--)e.bones.children[t-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(t.scale.x||t.scale.y||1),i=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(t,e,i,s),this.drawPaths&&this.drawPathsFunc(t,e,i),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(t,e,i),this.drawClipping&&this.drawClippingFunc(t,e,i),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(t,e,i),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(t,e,i),this.drawEvents)for(const t of e.eventText.children)t.alpha-=.05,t.y-=2}drawBonesFunc(t,e,s,n){const r=t.skeleton,a=r.x,o=r.y,l=r.bones;e.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let t=0,r=l.length;t<r;t++){const r=l[t],h=r.data.length,d=a+r.worldX,u=o+r.worldY,c=a+h*r.a+r.worldX,p=o+h*r.b+r.worldY;if("root"===r.data.name||null===r.data.parent)continue;const m=Math.abs(d-c),g=Math.abs(u-p),f=Math.pow(m,2),x=g,w=Math.pow(g,2),b=Math.sqrt(f+w),E=Math.pow(b,2),y=Math.PI/180,T=Math.acos((E+w-f)/(2*x*b))||0;if(0===b)continue;const A=new i.Graphics;e.bones.addChild(A);const C=b/50/n;A.context.poly([0,0,0-C,b-3*C,0,b-C,0+C,b-3*C]).fill(this.bonesColor),A.x=d,A.y=u,A.pivot.y=b;let M=0;d<c&&u<p?M=180*y-T:d>c&&u<p?M=180*y+T:d>c&&u>p?M=-T:d<c&&u>p?M=T:u===p&&d<c?M=90*y:u===p&&d>c?M=-90*y:d===c&&u<p?M=180*y:d===c&&u>p&&(M=0),A.rotation=M,A.circle(0,b,1.2*C).fill({color:0,alpha:.6}).stroke({width:s+C/2.4,color:this.bonesColor})}const h=3*s;e.skeletonXY.context.moveTo(a-h,o-h).lineTo(a+h,o+h).moveTo(a+h,o-h).lineTo(a-h,o+h).stroke()}drawRegionAttachmentsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t],n=s.getAttachment();if(null===n||!(n instanceof Pt))continue;const r=n,a=new Float32Array(8);r.computeWorldVertices(s.bone,a,0,2),e.regionAttachmentsShape.poly(Array.from(a.slice(0,8)))}e.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Mt))continue;const r=n,a=new Float32Array(r.worldVerticesLength),o=r.triangles;let l=r.hullLength;if(r.computeWorldVertices(s,0,r.worldVerticesLength,a,0,2),this.drawMeshTriangles)for(let t=0,s=o.length;t<s;t+=3){const s=2*o[t],i=2*o[t+1],n=2*o[t+2];e.meshTrianglesLine.context.moveTo(a[s],a[s+1]).lineTo(a[i],a[i+1]).lineTo(a[n],a[n+1])}if(this.drawMeshHull&&l>0){l=2*(l>>1);let t=a[l-2],s=a[l-1];for(let i=0,n=l;i<n;i+=2){const n=a[i],r=a[i+1];e.meshHullLine.context.moveTo(n,r).lineTo(t,s),t=n,s=r}}}e.meshHullLine.stroke({width:s,color:this.meshHullColor}),e.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Ct))continue;const r=n,a=r.worldVerticesLength,o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2),e.clippingPolygon.poly(Array.from(o))}e.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(t,e,s){const i=new he;i.update(t.skeleton,!0),i.minX!==1/0&&e.boundingBoxesRect.rect(i.minX,i.minY,i.getWidth(),i.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const n=i.polygons,r=(t,i,n)=>{if(n<3)throw new Error("Polygon must contain at least 3 vertices");const r=[],a=2*s;for(let s=0,i=t.length;s<i;s+=2){const i=t[s],n=t[s+1];e.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),e.boundingBoxesCircle.drawCircle(i,n,a),e.boundingBoxesCircle.fill(0),e.boundingBoxesCircle.circle(i,n,a).fill({color:this.boundingBoxesCircleColor}),r.push(i,n)}e.boundingBoxesPolygon.poly(r).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let t=0,e=n.length;t<e;t++){const e=n[t];r(e,0,e.length)}}drawPathsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof St))continue;const r=n;let a=r.worldVerticesLength;const o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2);let l=o[2],h=o[3],d=0,u=0;if(r.closed){const t=o[0],s=o[1],i=o[a-2],n=o[a-1];d=o[a-4],u=o[a-3],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(t,s,i,n,d,u),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(t,s),e.pathsLine.moveTo(d,u),e.pathsLine.lineTo(i,n)}a-=4;for(let t=4;t<a;t+=6){const s=o[t],i=o[t+1],n=o[t+2],r=o[t+3];d=o[t+4],u=o[t+5],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(s,i,n,r,d,u),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(s,i),e.pathsLine.moveTo(d,u),e.pathsLine.lineTo(n,r),l=d,h=u}}e.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),e.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(t){this.registeredSpines.has(t)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",t);const e=this.registeredSpines.get(t);e&&(t.state.removeListener(e.eventCallback),e.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(t))}},SpinePipe:Fe,SpineTexture:Me,SwirlEffect:Ae,Texture:_t,TextureAtlas:Wt,TextureAtlasPage:jt,TextureAtlasRegion:qt,TextureFilter:Yt,TextureRegion:Xt,TextureWrap:Ft,TimeKeeper:class{constructor(){E(this,"maxDelta",.064),E(this,"framesPerSecond",0),E(this,"delta",0),E(this,"totalTime",0),E(this,"lastTime",Date.now()/1e3),E(this,"frameCount",0),E(this,"frameTime",0)}update(){var 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)}},TimelineType:U,TrackEntry:wt,TransformConstraint:oe,TransformConstraintData:we,TransformConstraintTimeline:dt,TransformMode:Dt,TranslateTimeline:H,Triangulator:de,TwoColorTimeline:et,Utils:N,Vector2:L,VertexAttachment:C,WindowedMean:class{constructor(t=32){E(this,"values"),E(this,"addedValues",0),E(this,"lastValue",0),E(this,"mean",0),E(this,"dirty",!0),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}}});return t.Spine=class extends o{},t.SpineSystem=class extends u{init(){super.init({pixiSpine:je})}},t.pixiSpine=je,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,PIXI);globalThis.EVA.plugin.renderer.spine36=globalThis.EVA.plugin.renderer.spine36||_EVA_IIFE_spine36;
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_spine36=function(t,e,s,i){"use strict";function n(t){return function(e,s){var i=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,s);i.key=s,i.type=t}}function r(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 a(t,e,s,i){return new(s||(s=Promise))((function(n,r){function a(t){try{l(i.next(t))}catch(t){r(t)}}function o(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){t.done?n(t.value):new s((function(e){e(t.value)})).then(a,o)}l((i=i.apply(t,e||[])).next())}))}class o extends e.Component{constructor(){super(...arguments),this.resource="",this.scale=1,this.animationName="",this.autoPlay=!0,this.waitExecuteInfos=[]}set armature(t){if(this._armature=t,t){this.autoPlay&&this.play(this.animationName);for(const t of this.waitExecuteInfos)if(t.playType){const{name:e,loop:s,track:i}=t;this.play(e,s,i)}else this.stop(t.track);this.waitExecuteInfos=[]}}get armature(){return this._armature}init(t){t&&_extends(this,t)}onDestroy(){this.destroied=!0}play(t,e,s){try{const i=null!=e?e:this.autoPlay;t&&(this.animationName=t),this.armature?(void 0===s&&(s=0),this.armature.state.setAnimation(s,this.animationName,i)):this.waitExecuteInfos.push({playType:!0,name:t,loop:i,track:s})}catch(t){console.log(t)}}stop(t){this.armature?(void 0===t&&(t=0),this.armature.state.setEmptyAnimation(t,0)):this.waitExecuteInfos.push({playType:!1,track:t})}addAnimation(t,e,s,i){try{this.armature&&(void 0===i&&(i=0),this.armature.state.addAnimation(i,t,s,e))}catch(t){console.log(t)}}setMix(t,e,s){this.armature&&this.armature.state.data.setMix(t,e,s)}getAnim(t=0){try{if(this.armature)return this.armature.state.tracks[t].animation.name}catch(t){console.log(t)}}setDefaultMix(t){this.armature&&(this.armature.state.data.defaultMix=t)}setAttachment(t,e){this.armature&&this.armature.skeleton.setAttachment(t,e)}getBone(t){if(this.armature)return this.armature.skeleton.findBone(t)}}o.componentName="Spine",r([n("string")],o.prototype,"resource",void 0),r([n("number")],o.prototype,"scale",void 0),r([n("string")],o.prototype,"animationName",void 0),r([n("boolean")],o.prototype,"autoPlay",void 0);let l={};function h(t,e,s){return a(this,void 0,void 0,(function*(){let i=l[t.name];if(!i)if(t.complete)i=function(t,e,s,i){const n=e.ske,r=e.atlas,a=new i.AtlasAttachmentLoader(r),o=n instanceof Uint8Array?new i.SkeletonBinary(a):new i.SkeletonJson(a);o.scale=s||1;const h={spineData:o.readSkeletonData(n),ref:0,imageSrc:e.image.label};return l[t]=h,h}(t.name,t.data,e,s);else if(!i)return;return i.ref++,i.spineData}))}let d=class extends s.Renderer{constructor(){super(...arguments),this.armatures={}}init({pixiSpine:t}){this.renderSystem=this.game.getSystem(s.RendererSystem),this.renderSystem.rendererManager.register(this),this.pixiSpine=t,this.game.canvas.addEventListener("webglcontextrestored",(()=>{const t=this.game.gameObjects;let s=[];for(let i in this.armatures){const n=+i;for(let i=0;i<t.length;++i){let r=t[i];if(r.id===n){let t=r.getComponent(o);t&&(this.remove({type:e.OBSERVER_TYPE.REMOVE,gameObject:r,component:t,componentName:o.componentName}),s.push({type:e.OBSERVER_TYPE.ADD,gameObject:r,component:t,componentName:o.componentName}));break}}}setTimeout((()=>{s.forEach((t=>{this.add(t)}))}),1e3)}),!1)}update(t){for(let e in this.armatures)this.armatures[e].update(.001*t.deltaTime);super.update()}componentChanged(t){return a(this,void 0,void 0,(function*(){if("Spine"===t.componentName)if(t.type===e.OBSERVER_TYPE.ADD)this.add(t);else if(t.type===e.OBSERVER_TYPE.CHANGE){if("resource"===t.prop.prop[0])this.change(t)}else t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t)}))}add(t,s){var i,n;return a(this,void 0,void 0,(function*(){const r=t.component;clearTimeout(r.addHandler);const a=t.gameObject.id,o=this.increaseAsyncId(a),l=yield e.resource.getResource(r.resource);if(!this.validateAsyncId(a,o))return;const d=yield h(l,r.scale,this.pixiSpine);if(!this.validateAsyncId(a,o))return;if(!d)return void(r.addHandler=setTimeout((()=>{r.destroied||(void 0===s&&(s=20),--s>0?this.add(t,s):console.log("retry exceed max times",r.resource))}),1e3));this.remove(t);const u=null===(n=null===(i=this.renderSystem)||void 0===i?void 0:i.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id);if(!u)return;r.lastResource=r.resource;const c=new this.pixiSpine.Spine({skeletonData:d,autoUpdate:!1});if(this.armatures[t.gameObject.id]=c,t.gameObject&&t.gameObject.transform){const e=t.gameObject.transform;c.x=e.size.width*e.origin.x,c.y=e.size.height*e.origin.y}u.addChildAt(c,0),c.update(),r.armature=c,r.emit("loaded",{resource:r.resource}),c.state.addListener({start:(t,e)=>{r.emit("start",{track:t,name:t.animation.name})},complete:(t,e)=>{r.emit("complete",{track:t,name:t.animation.name})},interrupt:(t,e)=>{r.emit("interrupt",{track:t,name:t.animation.name})},end:(t,e)=>{r.emit("end",{track:t,name:t.animation.name})},event:(t,e)=>{r.emit("event",t,e)}})}))}change(t){this.remove(t),this.add(t)}remove(t){var s,n,r,o,h,d;return a(this,void 0,void 0,(function*(){this.increaseAsyncId(t.gameObject.id);const u=t.component;clearTimeout(u.addHandler);const c=this.armatures[t.gameObject.id],p=null===(n=null===(s=this.renderSystem)||void 0===s?void 0:s.containerManager)||void 0===n?void 0:n.getContainer(t.gameObject.id);if(p&&c&&p.removeChild(c),u.armature){u.armature.destroy({children:!0});const t=yield e.resource.getResource(u.lastResource);(null===(o=null===(r=t.data)||void 0===r?void 0:r.image)||void 0===o?void 0:o.src)||null===(d=null===(h=t.data)||void 0===h?void 0:h.image)||void 0===d||d.label,function(t){const s=t.name,n=l[s];n&&(n.ref--,setTimeout((()=>a(this,void 0,void 0,(function*(){if(n.ref<=0){yield i.Assets.unload([t.src.image.url,t.src.atlas.url,t.src.ske.url]);const n=i.Assets.resolver;delete n._assetMap[t.src.image.url],delete n._assetMap[t.src.atlas.url],delete n._assetMap[t.src.ske.url],delete n._resolverHash[t.src.image.url],delete n._resolverHash[t.src.atlas.url],delete n._resolverHash[t.src.ske.url],e.resource.destroy(s),delete l[s]}}))),100))}(t)}u.armature=null,delete this.armatures[t.gameObject.id],t.type,e.OBSERVER_TYPE.CHANGE}))}};d.systemName="SpineSystem",d=r([e.decorators.componentObserver({Spine:["resource"]})],d);var u=d;e.resource.registerResourceType("SPINE");var c=Object.defineProperty,p=Object.defineProperties,m=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,w=(t,e,s)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,b=(t,e)=>{for(var s in e||(e={}))f.call(e,s)&&w(t,s,e[s]);if(g)for(var s of g(e))x.call(e,s)&&w(t,s,e[s]);return t},E=(t,e,s)=>w(t,"symbol"!=typeof e?e+"":e,s),y=(t,e,s)=>new Promise(((i,n)=>{var r=t=>{try{o(s.next(t))}catch(t){n(t)}},a=t=>{try{o(s.throw(t))}catch(t){n(t)}},o=t=>t.done?i(t.value):Promise.resolve(t.value).then(r,a);o((s=s.apply(t,e)).next())}));if("undefined"!=typeof window&&window.PIXI){const t=window.require;window.require=e=>t?t(e):e.startsWith("@pixi/")||e.startsWith("pixi.js")?window.PIXI:void 0}class T{constructor(t){if(E(this,"name"),null==t)throw new Error("name cannot be null.");this.name=t}}const A=class t extends T{constructor(e){super(e),E(this,"id",(65535&t.nextID++)<<11),E(this,"bones"),E(this,"vertices"),E(this,"worldVerticesLength",0)}computeWorldVertices(t,e,s,i,n,r){s=n+(s>>1)*r;let a=t.bone.skeleton,o=t.attachmentVertices,l=this.vertices,h=this.bones;if(null==h){o.length>0&&(l=o);let a=t.bone,h=a.worldX,d=a.worldY,u=a.a,c=a.b,p=a.c,m=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*u+s*c+h,i[a+1]=e*p+s*m+d}return}let d=0,u=0;for(let t=0;t<e;t+=2){let t=h[d];d+=t+1,u+=t}let c=a.bones;if(0==o.length)for(let t=n,e=3*u;t<s;t+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,e+=3){let t=c[h[d]],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*u,o=u<<1;e<s;e+=r){let s=0,n=0,r=h[d++];for(r+=d;d<r;d++,a+=3,o+=2){let e=c[h[d]],i=l[a]+t[o],r=l[a+1]+t[o+1],u=l[a+2];s+=(i*e.a+r*e.b+e.worldX)*u,n+=(i*e.c+r*e.d+e.worldY)*u}i[e]=s,i[e+1]=n}}}applyDeform(t){return this==t}};E(A,"nextID",0);let C=A;class M{constructor(){E(this,"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}}const S=class{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(),this}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?255: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(),this}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}};E(S,"WHITE",new S(1,1,1,1)),E(S,"RED",new S(1,0,0,1)),E(S,"GREEN",new S(0,1,0,1)),E(S,"BLUE",new S(0,0,1,1)),E(S,"MAGENTA",new S(1,0,1,1));let v=S;const R=class t{static clamp(t,e,s){return t<e?e:t>s?s:t}static cosDeg(e){return Math.cos(e*t.degRad)}static sinDeg(e){return Math.sin(e*t.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){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e}static randomTriangular(e,s){return t.randomTriangularWith(e,s,.5*(e+s))}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))}};E(R,"PI",3.1415927),E(R,"PI2",2*R.PI),E(R,"radiansToDegrees",180/R.PI),E(R,"radDeg",R.radiansToDegrees),E(R,"degreesToRadians",R.PI/180),E(R,"degRad",R.degreesToRadians);let P=R;class I{apply(t,e,s){return t+(e-t)*this.applyInternal(s)}}class k extends I{constructor(t){super(),E(this,"power",2),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 V extends k{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}}const D=class t{static arrayCopy(t,e,s,i,n){for(let r=e,a=i;r<e+n;r++,a++)s[a]=t[r]}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(e,s,i=0){return e.length>=s?e:t.setArraySize(e,s,i)}static newArray(t,e){let s=new Array(t);for(let i=0;i<t;i++)s[i]=e;return s}static newFloatArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Float32Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static newShortArray(e){if(t.SUPPORTS_TYPED_ARRAYS)return new Int16Array(e);{let t=new Array(e);for(let e=0;e<t.length;e++)t[e]=0;return t}}static toFloatArray(e){return t.SUPPORTS_TYPED_ARRAYS?new Float32Array(e):e}static toSinglePrecision(e){return t.SUPPORTS_TYPED_ARRAYS?Math.fround(e):e}static webkit602BugfixHelper(t,e){}};E(D,"SUPPORTS_TYPED_ARRAYS","undefined"!=typeof Float32Array);let N=D;class _{constructor(t){E(this,"items",new Array),E(this,"instantiator"),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++)t[e].reset&&t[e].reset(),this.items[e]=t[e]}clear(){this.items.length=0}}class L{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 O{constructor(t,e,s){if(E(this,"name"),E(this,"timelines"),E(this,"duration"),null==t)throw new Error("name cannot be null.");if(null==e)throw new Error("timelines cannot be null.");this.name=t,this.timelines=e,this.duration=s}apply(t,e,s,i,n,r,a,o){if(null==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)}static binarySearch(t,e,s=1){let i=0,n=t.length/s-2;if(0==n)return s;let r=n>>>1;for(;;){if(t[(r+1)*s]<=e?i=r+1:n=r,i==n)return(i+1)*s;r=i+n>>>1}}static linearSearch(t,e,s){for(let i=0,n=t.length-s;i<=n;i+=s)if(t[i]>e)return i;return-1}}var Y,F,X,B=((Y=B||{})[Y.setup=0]="setup",Y[Y.current=1]="current",Y[Y.currentLayered=2]="currentLayered",Y),W=((F=W||{})[F.in=0]="in",F[F.out=1]="out",F),U=((X=U||{})[X.rotate=0]="rotate",X[X.translate=1]="translate",X[X.scale=2]="scale",X[X.shear=3]="shear",X[X.attachment=4]="attachment",X[X.color=5]="color",X[X.deform=6]="deform",X[X.event=7]="event",X[X.drawOrder=8]="drawOrder",X[X.ikConstraint=9]="ikConstraint",X[X.transformConstraint=10]="transformConstraint",X[X.pathConstraintPosition=11]="pathConstraintPosition",X[X.pathConstraintSpacing=12]="pathConstraintSpacing",X[X.pathConstraintMix=13]="pathConstraintMix",X[X.twoColor=14]="twoColor",X);const j=class t{constructor(e){if(E(this,"curves"),e<=0)throw new Error("frameCount must be > 0: "+e);this.curves=N.newFloatArray((e-1)*t.BEZIER_SIZE)}getFrameCount(){return this.curves.length/t.BEZIER_SIZE+1}setLinear(e){this.curves[e*t.BEZIER_SIZE]=t.LINEAR}setStepped(e){this.curves[e*t.BEZIER_SIZE]=t.STEPPED}getCurveType(e){let s=e*t.BEZIER_SIZE;if(s==this.curves.length)return t.LINEAR;let i=this.curves[s];return i==t.LINEAR?t.LINEAR:i==t.STEPPED?t.STEPPED:t.BEZIER}setCurve(e,s,i,n,r){let a=.03*(2*-s+n),o=.03*(2*-i+r),l=.006*(3*(s-n)+1),h=.006*(3*(i-r)+1),d=2*a+l,u=2*o+h,c=.3*s+a+.16666667*l,p=.3*i+o+.16666667*h,m=e*t.BEZIER_SIZE,g=this.curves;g[m++]=t.BEZIER;let f=c,x=p;for(let e=m+t.BEZIER_SIZE-1;m<e;m+=2)g[m]=f,g[m+1]=x,c+=d,p+=u,d+=l,u+=h,f+=c,x+=p}getCurvePercent(e,s){s=P.clamp(s,0,1);let i=this.curves,n=e*t.BEZIER_SIZE,r=i[n];if(r==t.LINEAR)return s;if(r==t.STEPPED)return 0;n++;let a=0;for(let e=n,r=n+t.BEZIER_SIZE-1;n<r;n+=2)if(a=i[n],a>=s){let t,r;return n==e?(t=0,r=0):(t=i[n-2],r=i[n-1]),r+(i[n+1]-r)*(s-t)/(a-t)}let o=i[n-1];return o+(1-o)*(s-a)/(1-a)}};E(j,"LINEAR",0),E(j,"STEPPED",1),E(j,"BEZIER",2),E(j,"BEZIER_SIZE",19);let q=j;const G=class t extends q{constructor(t){super(t),E(this,"boneIndex"),E(this,"frames"),this.frames=N.newFloatArray(t<<1)}getPropertyId(){return 0+this.boneIndex}setFrame(e,s,i){e<<=1,this.frames[e]=s,this.frames[e+t.ROTATION]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return void(h.rotation=h.data.rotation);case 1:let t=h.data.rotation-h.rotation;t-=360*(16384-(16384.499999999996-t/360|0)),h.rotation+=t*r}return}if(i>=l[l.length-t.ENTRIES]){if(0==a)h.rotation=h.data.rotation+l[l.length+t.PREV_ROTATION]*r;else{let e=h.data.rotation+l[l.length+t.PREV_ROTATION]-h.rotation;e-=360*(16384-(16384.499999999996-e/360|0)),h.rotation+=e*r}return}let d=O.binarySearch(l,i,t.ENTRIES),u=l[d+t.PREV_ROTATION],c=l[d],p=this.getCurvePercent((d>>1)-1,1-(i-c)/(l[d+t.PREV_TIME]-c)),m=l[d+t.ROTATION]-u;m-=360*(16384-(16384.499999999996-m/360|0)),m=u+m*p,0==a?(m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation=h.data.rotation+m*r):(m=h.data.rotation+m-h.rotation,m-=360*(16384-(16384.499999999996-m/360|0)),h.rotation+=m*r)}};E(G,"ENTRIES",2),E(G,"PREV_TIME",-2),E(G,"PREV_ROTATION",-1),E(G,"ROTATION",1);let $=G;const z=class t extends q{constructor(e){super(e),E(this,"boneIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(1<<24)+this.boneIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.X]=i,this.frames[e+t.Y]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.bones[this.boneIndex];if(i<l[0]){switch(a){case 0:return h.x=h.data.x,void(h.y=h.data.y);case 1:h.x+=(h.data.x-h.x)*r,h.y+=(h.data.y-h.y)*r}return}let d=0,u=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_X],u=l[l.length+t.PREV_Y];else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_X],u=l[e+t.PREV_Y];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.X]-d)*n,u+=(l[e+t.Y]-u)*n}0==a?(h.x=h.data.x+d*r,h.y=h.data.y+u*r):(h.x+=(h.data.x+d-h.x)*r,h.y+=(h.data.y+u-h.y)*r)}};E(z,"ENTRIES",3),E(z,"PREV_TIME",-3),E(z,"PREV_X",-2),E(z,"PREV_Y",-1),E(z,"X",1),E(z,"Y",2);let H=z;class Z extends H{constructor(t){super(t)}getPropertyId(){return(2<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.scaleX=l.data.scaleX,void(l.scaleY=l.data.scaleY);case 1:l.scaleX+=(l.data.scaleX-l.scaleX)*n,l.scaleY+=(l.data.scaleY-l.scaleY)*n}return}let h=0,d=0;if(s>=o[o.length-Z.ENTRIES])h=o[o.length+Z.PREV_X]*l.data.scaleX,d=o[o.length+Z.PREV_Y]*l.data.scaleY;else{let t=O.binarySearch(o,s,Z.ENTRIES);h=o[t+Z.PREV_X],d=o[t+Z.PREV_Y];let e=o[t],i=this.getCurvePercent(t/Z.ENTRIES-1,1-(s-e)/(o[t+Z.PREV_TIME]-e));h=(h+(o[t+Z.X]-h)*i)*l.data.scaleX,d=(d+(o[t+Z.Y]-d)*i)*l.data.scaleY}if(1==n)l.scaleX=h,l.scaleY=d;else{let t=0,e=0;0==r?(t=l.data.scaleX,e=l.data.scaleY):(t=l.scaleX,e=l.scaleY),1==a?(h=Math.abs(h)*P.signum(t),d=Math.abs(d)*P.signum(e)):(t=Math.abs(t)*P.signum(h),e=Math.abs(e)*P.signum(d)),l.scaleX=t+(h-t)*n,l.scaleY=e+(d-e)*n}}}class J extends H{constructor(t){super(t)}getPropertyId(){return(3<<24)+this.boneIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.bones[this.boneIndex];if(s<o[0]){switch(r){case 0:return l.shearX=l.data.shearX,void(l.shearY=l.data.shearY);case 1:l.shearX+=(l.data.shearX-l.shearX)*n,l.shearY+=(l.data.shearY-l.shearY)*n}return}let h=0,d=0;if(s>=o[o.length-J.ENTRIES])h=o[o.length+J.PREV_X],d=o[o.length+J.PREV_Y];else{let t=O.binarySearch(o,s,J.ENTRIES);h=o[t+J.PREV_X],d=o[t+J.PREV_Y];let e=o[t],i=this.getCurvePercent(t/J.ENTRIES-1,1-(s-e)/(o[t+J.PREV_TIME]-e));h+=(o[t+J.X]-h)*i,d+=(o[t+J.Y]-d)*i}0==r?(l.shearX=l.data.shearX+h*n,l.shearY=l.data.shearY+d*n):(l.shearX+=(l.data.shearX+h-l.shearX)*n,l.shearY+=(l.data.shearY+d-l.shearY)*n)}}const Q=class t extends q{constructor(e){super(e),E(this,"slotIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(5<<24)+this.slotIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return void l.color.setFromColor(l.data.color);case 1:let t=l.color,e=l.data.color;t.add((e.r-t.r)*r,(e.g-t.g)*r,(e.b-t.b)*r,(e.a-t.a)*r)}return}let d=0,u=0,c=0,p=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A]}else{let e=O.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,u+=(h[e+t.G]-u)*n,c+=(h[e+t.B]-c)*n,p+=(h[e+t.A]-p)*n}if(1==r)l.color.set(d,u,c,p);else{let t=l.color;0==a&&t.setFromColor(l.data.color),t.add((d-t.r)*r,(u-t.g)*r,(c-t.b)*r,(p-t.a)*r)}}};E(Q,"ENTRIES",5),E(Q,"PREV_TIME",-5),E(Q,"PREV_R",-4),E(Q,"PREV_G",-3),E(Q,"PREV_B",-2),E(Q,"PREV_A",-1),E(Q,"R",1),E(Q,"G",2),E(Q,"B",3),E(Q,"A",4);let K=Q;const tt=class t extends q{constructor(e){super(e),E(this,"slotIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(14<<24)+this.slotIndex}setFrame(e,s,i,n,r,a,o,l,h){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.R]=i,this.frames[e+t.G]=n,this.frames[e+t.B]=r,this.frames[e+t.A]=a,this.frames[e+t.R2]=o,this.frames[e+t.G2]=l,this.frames[e+t.B2]=h}apply(e,s,i,n,r,a,o){let l=e.slots[this.slotIndex],h=this.frames;if(i<h[0]){switch(a){case 0:return l.color.setFromColor(l.data.color),void l.darkColor.setFromColor(l.data.darkColor);case 1:let t=l.color,e=l.darkColor,s=l.data.color,i=l.data.darkColor;t.add((s.r-t.r)*r,(s.g-t.g)*r,(s.b-t.b)*r,(s.a-t.a)*r),e.add((i.r-e.r)*r,(i.g-e.g)*r,(i.b-e.b)*r,0)}return}let d=0,u=0,c=0,p=0,m=0,g=0,f=0;if(i>=h[h.length-t.ENTRIES]){let e=h.length;d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2]}else{let e=O.binarySearch(h,i,t.ENTRIES);d=h[e+t.PREV_R],u=h[e+t.PREV_G],c=h[e+t.PREV_B],p=h[e+t.PREV_A],m=h[e+t.PREV_R2],g=h[e+t.PREV_G2],f=h[e+t.PREV_B2];let s=h[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(h[e+t.PREV_TIME]-s));d+=(h[e+t.R]-d)*n,u+=(h[e+t.G]-u)*n,c+=(h[e+t.B]-c)*n,p+=(h[e+t.A]-p)*n,m+=(h[e+t.R2]-m)*n,g+=(h[e+t.G2]-g)*n,f+=(h[e+t.B2]-f)*n}if(1==r)l.color.set(d,u,c,p),l.darkColor.set(m,g,f,1);else{let t=l.color,e=l.darkColor;0==a&&(t.setFromColor(l.data.color),e.setFromColor(l.data.darkColor)),t.add((d-t.r)*r,(u-t.g)*r,(c-t.b)*r,(p-t.a)*r),e.add((m-e.r)*r,(g-e.g)*r,(f-e.b)*r,0)}}};E(tt,"ENTRIES",8),E(tt,"PREV_TIME",-8),E(tt,"PREV_R",-7),E(tt,"PREV_G",-6),E(tt,"PREV_B",-5),E(tt,"PREV_A",-4),E(tt,"PREV_R2",-3),E(tt,"PREV_G2",-2),E(tt,"PREV_B2",-1),E(tt,"R",1),E(tt,"G",2),E(tt,"B",3),E(tt,"A",4),E(tt,"R2",5),E(tt,"G2",6),E(tt,"B2",7);let et=tt;class st{constructor(t){E(this,"slotIndex"),E(this,"frames"),E(this,"attachmentNames"),this.frames=N.newFloatArray(t),this.attachmentNames=new Array(t)}getPropertyId(){return(4<<24)+this.slotIndex}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.attachmentNames[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex];if(1==a&&0==r){let e=o.data.attachmentName;return void o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}let l=this.frames;if(s<l[0]){if(0==r){let e=o.data.attachmentName;o.setAttachment(null==e?null:t.getAttachment(this.slotIndex,e))}return}let h=0;h=s>=l[l.length-1]?l.length-1:O.binarySearch(l,s,1)-1;let d=this.attachmentNames[h];t.slots[this.slotIndex].setAttachment(null==d?null:t.getAttachment(this.slotIndex,d))}}var it=null;class nt extends q{constructor(t){super(t),E(this,"slotIndex"),E(this,"attachment"),E(this,"frames"),E(this,"frameVertices"),this.frames=N.newFloatArray(t),this.frameVertices=new Array(t),null==it&&(it=N.newFloatArray(64))}getPropertyId(){return(6<<27)+ +this.attachment.id+this.slotIndex}setFrame(t,e,s){this.frames[t]=e,this.frameVertices[t]=s}apply(t,e,s,i,n,r,a){let o=t.slots[this.slotIndex],l=o.getAttachment();if(!(l instanceof C&&l.applyDeform(this.attachment)))return;let h=o.attachmentVertices;0==h.length&&(n=1);let d=this.frameVertices,u=d[0].length,c=this.frames;if(s<c[0]){let t=l;switch(r){case 0:return void(h.length=0);case 1:if(1==n){h.length=0;break}let e=N.setArraySize(h,u);if(null==t.bones)for(var p=t.vertices,m=0;m<u;m++)e[m]+=(p[m]-e[m])*n;else{n=1-n;for(m=0;m<u;m++)e[m]*=n}}return}let g=N.setArraySize(h,u);if(s>=c[c.length-1]){let t=d[c.length-1];if(1==n)N.arrayCopy(t,0,g,0,u);else if(0==r){let e=l;if(null==e.bones){let s=e.vertices;for(let e=0;e<u;e++){let i=s[e];g[e]=i+(t[e]-i)*n}}else for(let e=0;e<u;e++)g[e]=t[e]*n}else for(let e=0;e<u;e++)g[e]+=(t[e]-g[e])*n;return}let f=O.binarySearch(c,s),x=d[f-1],w=d[f],b=c[f],E=this.getCurvePercent(f-1,1-(s-b)/(c[f-1]-b));if(1==n)for(let t=0;t<u;t++){let e=x[t];g[t]=e+(w[t]-e)*E}else if(0==r){let t=l;if(null==t.bones){let e=t.vertices;for(let t=0;t<u;t++){let s=x[t],i=e[t];g[t]=i+(s+(w[t]-s)*E-i)*n}}else for(let t=0;t<u;t++){let e=x[t];g[t]=(e+(w[t]-e)*E)*n}}else for(let t=0;t<u;t++){let e=x[t];g[t]+=(e+(w[t]-e)*E-g[t])*n}}}class rt{constructor(t){E(this,"frames"),E(this,"events"),this.frames=N.newFloatArray(t),this.events=new Array(t)}getPropertyId(){return 7<<24}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(null==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=O.binarySearch(o,e);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 at{constructor(t){E(this,"frames"),E(this,"drawOrders"),this.frames=N.newFloatArray(t),this.drawOrders=new Array(t)}getPropertyId(){return 8<<24}getFrameCount(){return this.frames.length}setFrame(t,e,s){this.frames[t]=e,this.drawOrders[t]=s}apply(t,e,s,i,n,r,a){let o=t.drawOrder,l=t.slots;if(1==a&&0==r)return void N.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length);let h=this.frames;if(s<h[0])return void(0==r&&N.arrayCopy(t.slots,0,t.drawOrder,0,t.slots.length));let d=0;d=s>=h[h.length-1]?h.length-1:O.binarySearch(h,s)-1;let u=this.drawOrders[d];if(null==u)N.arrayCopy(l,0,o,0,l.length);else for(let t=0,e=u.length;t<e;t++)o[t]=l[u[t]]}}const ot=class t extends q{constructor(e){super(e),E(this,"ikConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(9<<24)+this.ikConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.MIX]=i,this.frames[e+t.BEND_DIRECTION]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.ikConstraints[this.ikConstraintIndex];if(i<l[0]){switch(a){case 0:return h.mix=h.data.mix,void(h.bendDirection=h.data.bendDirection);case 1:h.mix+=(h.data.mix-h.mix)*r,h.bendDirection=h.data.bendDirection}return}if(i>=l[l.length-t.ENTRIES])return void(0==a?(h.mix=h.data.mix+(l[l.length+t.PREV_MIX]-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[l.length+t.PREV_BEND_DIRECTION]):(h.mix+=(l[l.length+t.PREV_MIX]-h.mix)*r,0==o&&(h.bendDirection=l[l.length+t.PREV_BEND_DIRECTION])));let d=O.binarySearch(l,i,t.ENTRIES),u=l[d+t.PREV_MIX],c=l[d],p=this.getCurvePercent(d/t.ENTRIES-1,1-(i-c)/(l[d+t.PREV_TIME]-c));0==a?(h.mix=h.data.mix+(u+(l[d+t.MIX]-u)*p-h.data.mix)*r,h.bendDirection=1==o?h.data.bendDirection:l[d+t.PREV_BEND_DIRECTION]):(h.mix+=(u+(l[d+t.MIX]-u)*p-h.mix)*r,0==o&&(h.bendDirection=l[d+t.PREV_BEND_DIRECTION]))}};E(ot,"ENTRIES",3),E(ot,"PREV_TIME",-3),E(ot,"PREV_MIX",-2),E(ot,"PREV_BEND_DIRECTION",-1),E(ot,"MIX",1),E(ot,"BEND_DIRECTION",2);let lt=ot;const ht=class t extends q{constructor(e){super(e),E(this,"transformConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(10<<24)+this.transformConstraintIndex}setFrame(e,s,i,n,r,a){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n,this.frames[e+t.SCALE]=r,this.frames[e+t.SHEAR]=a}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.transformConstraints[this.transformConstraintIndex];if(i<l[0]){let t=h.data;switch(a){case 0:return h.rotateMix=t.rotateMix,h.translateMix=t.translateMix,h.scaleMix=t.scaleMix,void(h.shearMix=t.shearMix);case 1:h.rotateMix+=(t.rotateMix-h.rotateMix)*r,h.translateMix+=(t.translateMix-h.translateMix)*r,h.scaleMix+=(t.scaleMix-h.scaleMix)*r,h.shearMix+=(t.shearMix-h.shearMix)*r}return}let d=0,u=0,c=0,p=0;if(i>=l[l.length-t.ENTRIES]){let e=l.length;d=l[e+t.PREV_ROTATE],u=l[e+t.PREV_TRANSLATE],c=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR]}else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],u=l[e+t.PREV_TRANSLATE],c=l[e+t.PREV_SCALE],p=l[e+t.PREV_SHEAR];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,u+=(l[e+t.TRANSLATE]-u)*n,c+=(l[e+t.SCALE]-c)*n,p+=(l[e+t.SHEAR]-p)*n}if(0==a){let t=h.data;h.rotateMix=t.rotateMix+(d-t.rotateMix)*r,h.translateMix=t.translateMix+(u-t.translateMix)*r,h.scaleMix=t.scaleMix+(c-t.scaleMix)*r,h.shearMix=t.shearMix+(p-t.shearMix)*r}else h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(u-h.translateMix)*r,h.scaleMix+=(c-h.scaleMix)*r,h.shearMix+=(p-h.shearMix)*r}};E(ht,"ENTRIES",5),E(ht,"PREV_TIME",-5),E(ht,"PREV_ROTATE",-4),E(ht,"PREV_TRANSLATE",-3),E(ht,"PREV_SCALE",-2),E(ht,"PREV_SHEAR",-1),E(ht,"ROTATE",1),E(ht,"TRANSLATE",2),E(ht,"SCALE",3),E(ht,"SHEAR",4);let dt=ht;const ut=class t extends q{constructor(e){super(e),E(this,"pathConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(11<<24)+this.pathConstraintIndex}setFrame(e,s,i){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.VALUE]=i}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return void(h.position=h.data.position);case 1:h.position+=(h.data.position-h.position)*r}return}let d=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_VALUE];else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_VALUE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.VALUE]-d)*n}0==a?h.position=h.data.position+(d-h.data.position)*r:h.position+=(d-h.position)*r}};E(ut,"ENTRIES",2),E(ut,"PREV_TIME",-2),E(ut,"PREV_VALUE",-1),E(ut,"VALUE",1);let ct=ut;class pt extends ct{constructor(t){super(t)}getPropertyId(){return(12<<24)+this.pathConstraintIndex}apply(t,e,s,i,n,r,a){let o=this.frames,l=t.pathConstraints[this.pathConstraintIndex];if(s<o[0]){switch(r){case 0:return void(l.spacing=l.data.spacing);case 1:l.spacing+=(l.data.spacing-l.spacing)*n}return}let h=0;if(s>=o[o.length-pt.ENTRIES])h=o[o.length+pt.PREV_VALUE];else{let t=O.binarySearch(o,s,pt.ENTRIES);h=o[t+pt.PREV_VALUE];let e=o[t],i=this.getCurvePercent(t/pt.ENTRIES-1,1-(s-e)/(o[t+pt.PREV_TIME]-e));h+=(o[t+pt.VALUE]-h)*i}0==r?l.spacing=l.data.spacing+(h-l.data.spacing)*n:l.spacing+=(h-l.spacing)*n}}const mt=class t extends q{constructor(e){super(e),E(this,"pathConstraintIndex"),E(this,"frames"),this.frames=N.newFloatArray(e*t.ENTRIES)}getPropertyId(){return(13<<24)+this.pathConstraintIndex}setFrame(e,s,i,n){e*=t.ENTRIES,this.frames[e]=s,this.frames[e+t.ROTATE]=i,this.frames[e+t.TRANSLATE]=n}apply(e,s,i,n,r,a,o){let l=this.frames,h=e.pathConstraints[this.pathConstraintIndex];if(i<l[0]){switch(a){case 0:return h.rotateMix=h.data.rotateMix,void(h.translateMix=h.data.translateMix);case 1:h.rotateMix+=(h.data.rotateMix-h.rotateMix)*r,h.translateMix+=(h.data.translateMix-h.translateMix)*r}return}let d=0,u=0;if(i>=l[l.length-t.ENTRIES])d=l[l.length+t.PREV_ROTATE],u=l[l.length+t.PREV_TRANSLATE];else{let e=O.binarySearch(l,i,t.ENTRIES);d=l[e+t.PREV_ROTATE],u=l[e+t.PREV_TRANSLATE];let s=l[e],n=this.getCurvePercent(e/t.ENTRIES-1,1-(i-s)/(l[e+t.PREV_TIME]-s));d+=(l[e+t.ROTATE]-d)*n,u+=(l[e+t.TRANSLATE]-u)*n}0==a?(h.rotateMix=h.data.rotateMix+(d-h.data.rotateMix)*r,h.translateMix=h.data.translateMix+(u-h.data.translateMix)*r):(h.rotateMix+=(d-h.rotateMix)*r,h.translateMix+=(u-h.translateMix)*r)}};E(mt,"ENTRIES",3),E(mt,"PREV_TIME",-3),E(mt,"PREV_ROTATE",-2),E(mt,"PREV_TRANSLATE",-1),E(mt,"ROTATE",1),E(mt,"TRANSLATE",2);let gt=mt;const ft=class t{constructor(t){E(this,"data"),E(this,"tracks",new Array),E(this,"events",new Array),E(this,"listeners",new Array),E(this,"queue",new bt(this)),E(this,"propertyIDs",new M),E(this,"mixingTo",new Array),E(this,"animationsChanged",!1),E(this,"timeScale",1),E(this,"trackEntryPool",new _((()=>new wt))),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(null==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(null!=r){let e=i.trackLast-r.delay;if(e>=0){for(r.delay=0,r.trackTime=e+t*r.timeScale,i.trackTime+=n,this.setCurrent(s,r,!0);null!=r.mixingFrom;)r.mixTime+=n,r=r.mixingFrom;continue}}else if(i.trackLast>=i.trackEnd&&null==i.mixingFrom){e[s]=null,this.queue.end(i),this.disposeNext(i);continue}if(null!=i.mixingFrom&&this.updateMixingFrom(i,t)){let t=i.mixingFrom;for(i.mixingFrom=null;null!=t;)this.queue.end(t),t=t.mixingFrom}i.trackTime+=n}this.queue.drain()}updateMixingFrom(t,e){let s=t.mixingFrom;if(null==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==t.timeScale)?(0!=s.totalAlpha&&0!=t.mixDuration||(t.mixingFrom=s.mixingFrom,t.interruptAlpha=s.interruptAlpha,this.queue.end(s)),i):(s.trackTime+=e*s.timeScale,t.mixTime+=e*t.timeScale,!1)}apply(e){if(null==e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let s=this.events,i=this.tracks,n=!1;for(let r=0,a=i.length;r<a;r++){let a=i[r];if(null==a||a.delay>0)continue;n=!0;let o=0==r?B.current:B.currentLayered,l=a.alpha;null!=a.mixingFrom?l*=this.applyMixingFrom(a,e,o):a.trackTime>=a.trackEnd&&null==a.next&&(l=0);let h=a.animationLast,d=a.getAnimationTime(),u=a.animation.timelines.length,c=a.animation.timelines;if(1==l)for(let t=0;t<u;t++)c[t].apply(e,h,d,s,1,B.setup,W.in);else{let i=a.timelineData,n=0==a.timelinesRotation.length;n&&N.setArraySize(a.timelinesRotation,u<<1,null);let r=a.timelinesRotation;for(let a=0;a<u;a++){let u=c[a],p=i[a]>=t.FIRST?B.setup:o;u instanceof $?this.applyRotateTimeline(u,e,d,l,p,r,a<<1,n):(N.webkit602BugfixHelper(l,p),u.apply(e,h,d,s,l,p,W.in))}}this.queueEvents(a,d),s.length=0,a.nextAnimationLast=d,a.nextTrackLast=a.trackTime}return this.queue.drain(),n}applyMixingFrom(e,s,i){let n=e.mixingFrom;null!=n.mixingFrom&&this.applyMixingFrom(n,s,i);let r=0;0==e.mixDuration?(r=1,i=B.setup):(r=e.mixTime/e.mixDuration,r>1&&(r=1));let a=r<n.eventThreshold?this.events:null,o=r<n.attachmentThreshold,l=r<n.drawOrderThreshold,h=n.animationLast,d=n.getAnimationTime(),u=n.animation.timelines.length,c=n.animation.timelines,p=n.timelineData,m=n.timelineDipMix,g=0==n.timelinesRotation.length;g&&N.setArraySize(n.timelinesRotation,u<<1,null);let f,x=n.timelinesRotation,w=n.alpha*e.interruptAlpha,b=w*(1-r),E=0;n.totalAlpha=0;for(var y=0;y<u;y++){let e=c[y];switch(p[y]){case t.SUBSEQUENT:if(!o&&e instanceof st)continue;if(!l&&e instanceof at)continue;f=i,E=b;break;case t.FIRST:f=B.setup,E=b;break;case t.DIP:f=B.setup,E=w;break;default:f=B.setup,E=w;let s=m[y];E*=Math.max(0,1-s.mixTime/s.mixDuration)}n.totalAlpha+=E,e instanceof $?this.applyRotateTimeline(e,s,d,E,f,x,y<<1,g):(N.webkit602BugfixHelper(E,f),e.apply(s,h,d,a,E,f,W.out))}return e.mixDuration>0&&this.queueEvents(n,d),this.events.length=0,n.nextAnimationLast=d,n.nextTrackLast=n.trackTime,r}applyRotateTimeline(t,e,s,i,n,r,a,o){if(o&&(r[a]=0),1==i)return void t.apply(e,0,s,null,1,n,W.in);let l=t,h=l.frames,d=e.bones[l.boneIndex];if(s<h[0])return void(n==B.setup&&(d.rotation=d.data.rotation));let u=0;if(s>=h[h.length-$.ENTRIES])u=d.data.rotation+h[h.length+$.PREV_ROTATION];else{let t=O.binarySearch(h,s,$.ENTRIES),e=h[t+$.PREV_ROTATION],i=h[t],n=l.getCurvePercent((t>>1)-1,1-(s-i)/(h[t+$.PREV_TIME]-i));u=h[t+$.ROTATION]-e,u-=360*(16384-(16384.499999999996-u/360|0)),u=e+u*n+d.data.rotation,u-=360*(16384-(16384.499999999996-u/360|0))}let c=n==B.setup?d.data.rotation:d.rotation,p=0,m=u-c;if(0==m)p=r[a];else{m-=360*(16384-(16384.499999999996-m/360|0));let t=0,e=0;o?(t=0,e=m):(t=r[a],e=r[a+1]);let s=m>0,i=t>=0;P.signum(e)!=P.signum(m)&&Math.abs(e)<=90&&(Math.abs(t)>180&&(t+=360*P.signum(t)),i=s),p=m+t-t%360,i!=s&&(p+=360*P.signum(t)),r[a]=p}r[a+1]=m,c+=p*i,d.rotation=c-360*(16384-(16384.499999999996-c/360|0))}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)}for((t.loop?0==n||r>t.trackTime%n:e>=i&&t.animationLast<i)&&this.queue.complete(t);o<l;o++){a[o].time<s||this.queue.event(t,a[o])}}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(null==e)return;this.queue.end(e),this.disposeNext(e);let s=e;for(;;){let t=s.mixingFrom;if(null==t)break;this.queue.end(t),s.mixingFrom=null,s=t}this.tracks[e.trackIndex]=null,this.queue.drain()}setCurrent(t,e,s){let i=this.expandToIndex(t);this.tracks[t]=e,null!=i&&(s&&this.queue.interrupt(i),e.mixingFrom=i,e.mixTime=0,null!=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){let i=this.data.skeletonData.findAnimation(e);if(null==i)throw new Error("Animation not found: "+e);return this.setAnimationWith(t,i,s)}setAnimationWith(t,e,s){if(null==e)throw new Error("animation cannot be null.");let i=!0,n=this.expandToIndex(t);null!=n&&(-1==n.nextTrackLast?(this.tracks[t]=n.mixingFrom,this.queue.interrupt(n),this.queue.end(n),this.disposeNext(n),n=n.mixingFrom,i=!1):this.disposeNext(n));let r=this.trackEntry(t,e,s,n);return this.setCurrent(t,r,i),this.queue.drain(),r}addAnimation(t,e,s,i){let n=this.data.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);return this.addAnimationWith(t,n,s,i)}addAnimationWith(t,e,s,i){if(null==e)throw new Error("animation cannot be null.");let n=this.expandToIndex(t);if(null!=n)for(;null!=n.next;)n=n.next;let r=this.trackEntry(t,e,s,n);if(null==n)this.setCurrent(t,r,!0),this.queue.drain();else if(n.next=r,i<=0){let t=n.animationEnd-n.animationStart;0!=t?(n.loop?i+=t*(1+(n.trackTime/t|0)):i+=t,i-=this.data.getMix(n.animation,e)):i=0}return r.delay=i,r}setEmptyAnimation(e,s){let i=this.setAnimationWith(e,t.emptyAnimation,!1);return i.mixDuration=s,i.trackEnd=s,i}addEmptyAnimation(e,s,i){i<=0&&(i-=s);let n=this.addAnimationWith(e,t.emptyAnimation,!1,i);return n.mixDuration=s,n.trackEnd=s,n}setEmptyAnimations(t){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];null!=s&&this.setEmptyAnimation(s.trackIndex,t)}this.queue.drainDisabled=e,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(N.ensureArrayCapacity(this.tracks,t-this.tracks.length+1,null),this.tracks.length=t+1,null)}trackEntry(t,e,s,i){let n=this.trackEntryPool.obtain();return n.trackIndex=t,n.animation=e,n.loop=s,n.eventThreshold=0,n.attachmentThreshold=0,n.drawOrderThreshold=0,n.animationStart=0,n.animationEnd=e.duration,n.animationLast=-1,n.nextAnimationLast=-1,n.delay=0,n.trackTime=0,n.trackLast=-1,n.nextTrackLast=-1,n.trackEnd=Number.MAX_VALUE,n.timeScale=1,n.alpha=1,n.interruptAlpha=1,n.mixTime=0,n.mixDuration=null==i?0:this.data.getMix(i.animation,e),n}disposeNext(t){let e=t.next;for(;null!=e;)this.queue.dispose(e),e=e.next;t.next=null}_animationsChanged(){this.animationsChanged=!1;let t=this.propertyIDs;t.clear();let e=this.mixingTo;for(var s=0,i=this.tracks.length;s<i;s++){let i=this.tracks[s];null!=i&&i.setTimelineData(null,e,t)}}getCurrent(t){return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(null==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()}};E(ft,"emptyAnimation",new O("<empty>",[],0)),E(ft,"SUBSEQUENT",0),E(ft,"FIRST",1),E(ft,"DIP",2),E(ft,"DIP_MIX",3);let xt=ft;class wt{constructor(){E(this,"animation"),E(this,"next"),E(this,"mixingFrom"),E(this,"listener"),E(this,"trackIndex"),E(this,"loop"),E(this,"eventThreshold"),E(this,"attachmentThreshold"),E(this,"drawOrderThreshold"),E(this,"animationStart"),E(this,"animationEnd"),E(this,"animationLast"),E(this,"nextAnimationLast"),E(this,"delay"),E(this,"trackTime"),E(this,"trackLast"),E(this,"nextTrackLast"),E(this,"trackEnd"),E(this,"timeScale"),E(this,"alpha"),E(this,"mixTime"),E(this,"mixDuration"),E(this,"interruptAlpha"),E(this,"totalAlpha"),E(this,"timelineData",new Array),E(this,"timelineDipMix",new Array),E(this,"timelinesRotation",new Array)}reset(){this.next=null,this.mixingFrom=null,this.animation=null,this.listener=null,this.timelineData.length=0,this.timelineDipMix.length=0,this.timelinesRotation.length=0}setTimelineData(t,e,s){null!=t&&e.push(t);let i=null!=this.mixingFrom?this.mixingFrom.setTimelineData(this,e,s):this;null!=t&&e.pop();let n=e,r=e.length-1,a=this.animation.timelines,o=this.animation.timelines.length,l=N.setArraySize(this.timelineData,o);this.timelineDipMix.length=0;let h=N.setArraySize(this.timelineDipMix,o);t:for(var d=0;d<o;d++){let e=a[d].getPropertyId();if(s.add(e))if(null!=t&&t.hasTimeline(e)){for(var u=r;u>=0;u--){let t=n[u];if(!t.hasTimeline(e)&&t.mixDuration>0){l[d]=xt.DIP_MIX,h[d]=t;continue t}}l[d]=xt.DIP}else l[d]=xt.FIRST;else l[d]=xt.SUBSEQUENT}return i}hasTimeline(t){let e=this.animation.timelines;for(var s=0,i=e.length;s<i;s++)if(e[s].getPropertyId()==t)return!0;return!1}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}}class bt{constructor(t){E(this,"objects",[]),E(this,"drainDisabled",!1),E(this,"animState"),this.animState=t}start(t){this.objects.push(0),this.objects.push(t),this.animState.animationsChanged=!0}interrupt(t){this.objects.push(1),this.objects.push(t)}end(t){this.objects.push(2),this.objects.push(t),this.animState.animationsChanged=!0}dispose(t){this.objects.push(3),this.objects.push(t)}complete(t){this.objects.push(4),this.objects.push(t)}event(t,e){this.objects.push(5),this.objects.push(t),this.objects.push(e)}drain(){if(this.drainDisabled)return;this.drainDisabled=!0;let t=this.objects,e=this.animState.listeners;for(let s=0;s<t.length;s+=2){let i=t[s],n=t[s+1];switch(i){case 0:null!=n.listener&&n.listener.start&&n.listener.start(n);for(let t=0;t<e.length;t++)e[t].start&&e[t].start(n);break;case 1:null!=n.listener&&n.listener.interrupt&&n.listener.interrupt(n);for(let t=0;t<e.length;t++)e[t].interrupt&&e[t].interrupt(n);break;case 2:null!=n.listener&&n.listener.end&&n.listener.end(n);for(let t=0;t<e.length;t++)e[t].end&&e[t].end(n);case 3:null!=n.listener&&n.listener.dispose&&n.listener.dispose(n);for(let t=0;t<e.length;t++)e[t].dispose&&e[t].dispose(n);this.animState.trackEntryPool.free(n);break;case 4:null!=n.listener&&n.listener.complete&&n.listener.complete(n);for(let t=0;t<e.length;t++)e[t].complete&&e[t].complete(n);break;case 5:let i=t[2+s++];null!=n.listener&&n.listener.event&&n.listener.event(n,i);for(let t=0;t<e.length;t++)e[t].event&&e[t].event(n,i)}}this.clear(),this.drainDisabled=!1}clear(){this.objects.length=0}}var Et,yt=((Et=yt||{})[Et.start=0]="start",Et[Et.interrupt=1]="interrupt",Et[Et.end=2]="end",Et[Et.dispose=3]="dispose",Et[Et.complete=4]="complete",Et[Et.event=5]="event",Et);class Tt{constructor(t){if(E(this,"skeletonData"),E(this,"animationToMixTime",{}),E(this,"defaultMix",0),null==t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,s){let i=this.skeletonData.findAnimation(t);if(null==i)throw new Error("Animation not found: "+t);let n=this.skeletonData.findAnimation(e);if(null==n)throw new Error("Animation not found: "+e);this.setMixWith(i,n,s)}setMixWith(t,e,s){if(null==t)throw new Error("from cannot be null.");if(null==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 At extends C{constructor(t){super(t),E(this,"color",new v(1,1,1,1))}}class Ct extends C{constructor(t){super(t),E(this,"endSlot"),E(this,"color",new v(.2275,.2275,.8078,1))}}class Mt extends C{constructor(t){super(t),E(this,"region"),E(this,"path"),E(this,"regionUVs"),E(this,"uvs"),E(this,"triangles"),E(this,"color",new v(1,1,1,1)),E(this,"hullLength"),E(this,"parentMesh"),E(this,"inheritDeform",!1),E(this,"tempColor",new v(0,0,0,0))}updateUVs(){let t=0,e=0,s=0,i=0;null==this.region?(t=e=0,s=i=1):(t=this.region.u,e=this.region.v,s=this.region.u2-t,i=this.region.v2-e);let n=this.regionUVs;null!=this.uvs&&this.uvs.length==n.length||(this.uvs=N.newFloatArray(n.length));let r=this.uvs;if(this.region.rotate)for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a+1]*s,r[a+1]=e+i-n[a]*i;else for(let a=0,o=r.length;a<o;a+=2)r[a]=t+n[a]*s,r[a+1]=e+n[a+1]*i}applyDeform(t){return this==t||this.inheritDeform&&this.parentMesh==t}getParentMesh(){return this.parentMesh}setParentMesh(t){this.parentMesh=t,null!=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)}}class St extends C{constructor(t){super(t),E(this,"lengths"),E(this,"closed",!1),E(this,"constantSpeed",!1),E(this,"color",new v(1,1,1,1))}}class vt extends C{constructor(t){super(t),E(this,"x"),E(this,"y"),E(this,"rotation"),E(this,"color",new v(.38,.94,0,1))}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=P.cosDeg(this.rotation),s=P.sinDeg(this.rotation),i=e*t.a+s*t.b,n=e*t.c+s*t.d;return Math.atan2(n,i)*P.radDeg}}const Rt=class t extends T{constructor(t){super(t),E(this,"x",0),E(this,"y",0),E(this,"scaleX",1),E(this,"scaleY",1),E(this,"rotation",0),E(this,"width",0),E(this,"height",0),E(this,"color",new v(1,1,1,1)),E(this,"path"),E(this,"rendererObject"),E(this,"region"),E(this,"offset",N.newFloatArray(8)),E(this,"uvs",N.newFloatArray(8)),E(this,"tempColor",new v(1,1,1,1))}updateOffset(){let e=this.width/this.region.originalWidth*this.scaleX,s=this.height/this.region.originalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.region.offsetX*e,n=-this.height/2*this.scaleY+this.region.offsetY*s,r=i+this.region.width*e,a=n+this.region.height*s,o=this.rotation*Math.PI/180,l=Math.cos(o),h=Math.sin(o),d=i*l+this.x,u=i*h,c=n*l+this.y,p=n*h,m=r*l+this.x,g=r*h,f=a*l+this.y,x=a*h,w=this.offset;w[t.OX1]=d-p,w[t.OY1]=c+u,w[t.OX2]=d-x,w[t.OY2]=f+u,w[t.OX3]=m-x,w[t.OY3]=f+g,w[t.OX4]=m-p,w[t.OY4]=c+g}setRegion(t){this.region=t;let e=this.uvs;t.rotate?(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(e,s,i,n){let r=this.offset,a=e.worldX,o=e.worldY,l=e.a,h=e.b,d=e.c,u=e.d,c=0,p=0;c=r[t.OX1],p=r[t.OY1],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o,i+=n,c=r[t.OX2],p=r[t.OY2],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o,i+=n,c=r[t.OX3],p=r[t.OY3],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o,i+=n,c=r[t.OX4],p=r[t.OY4],s[i]=c*l+p*h+a,s[i+1]=c*d+p*u+o}};E(Rt,"OX1",0),E(Rt,"OY1",1),E(Rt,"OX2",2),E(Rt,"OY2",3),E(Rt,"OX3",4),E(Rt,"OY3",5),E(Rt,"OX4",6),E(Rt,"OY4",7),E(Rt,"X1",0),E(Rt,"Y1",1),E(Rt,"C1R",2),E(Rt,"C1G",3),E(Rt,"C1B",4),E(Rt,"C1A",5),E(Rt,"U1",6),E(Rt,"V1",7),E(Rt,"X2",8),E(Rt,"Y2",9),E(Rt,"C2R",10),E(Rt,"C2G",11),E(Rt,"C2B",12),E(Rt,"C2A",13),E(Rt,"U2",14),E(Rt,"V2",15),E(Rt,"X3",16),E(Rt,"Y3",17),E(Rt,"C3R",18),E(Rt,"C3G",19),E(Rt,"C3B",20),E(Rt,"C3A",21),E(Rt,"U3",22),E(Rt,"V3",23),E(Rt,"X4",24),E(Rt,"Y4",25),E(Rt,"C4R",26),E(Rt,"C4G",27),E(Rt,"C4B",28),E(Rt,"C4A",29),E(Rt,"U4",30),E(Rt,"V4",31);let Pt=Rt;class It{constructor(t){E(this,"atlas"),this.atlas=t}newRegionAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (region attachment: "+e+")");i.renderObject=i;let n=new Pt(e);return n.setRegion(i),n}newMeshAttachment(t,e,s){let i=this.atlas.findRegion(s);if(null==i)throw new Error("Region not found in atlas: "+s+" (mesh attachment: "+e+")");i.renderObject=i;let n=new Mt(e);return n.region=i,n}newBoundingBoxAttachment(t,e){return new At(e)}newPathAttachment(t,e){return new St(e)}newPointAttachment(t,e){return new vt(e)}newClippingAttachment(t,e){return new Ct(e)}}class kt{constructor(t,e,s){if(E(this,"index"),E(this,"name"),E(this,"parent"),E(this,"length"),E(this,"x",0),E(this,"y",0),E(this,"rotation",0),E(this,"scaleX",1),E(this,"scaleY",1),E(this,"shearX",0),E(this,"shearY",0),E(this,"transformMode",0),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=s}}var Vt,Dt=((Vt=Dt||{})[Vt.Normal=0]="Normal",Vt[Vt.OnlyTranslation=1]="OnlyTranslation",Vt[Vt.NoRotationOrReflection=2]="NoRotationOrReflection",Vt[Vt.NoScale=3]="NoScale",Vt[Vt.NoScaleOrReflection=4]="NoScaleOrReflection",Vt);class Nt{constructor(t,e,s){if(E(this,"data"),E(this,"skeleton"),E(this,"parent"),E(this,"children",new Array),E(this,"x",0),E(this,"y",0),E(this,"rotation",0),E(this,"scaleX",0),E(this,"scaleY",0),E(this,"shearX",0),E(this,"shearY",0),E(this,"ax",0),E(this,"ay",0),E(this,"arotation",0),E(this,"ascaleX",0),E(this,"ascaleY",0),E(this,"ashearX",0),E(this,"ashearY",0),E(this,"appliedValid",!1),E(this,"a",0),E(this,"b",0),E(this,"worldX",0),E(this,"c",0),E(this,"d",0),E(this,"worldY",0),E(this,"sorted",!1),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=s,this.setToSetupPose()}update(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(t,e,s,i,n,r,a){this.ax=t,this.ay=e,this.arotation=s,this.ascaleX=i,this.ascaleY=n,this.ashearX=r,this.ashearY=a,this.appliedValid=!0;let o=this.parent;if(null==o){let o=s+90+a,l=P.cosDeg(s+r)*i,h=P.cosDeg(o)*n,d=P.sinDeg(s+r)*i,u=P.sinDeg(o)*n,c=this.skeleton;return c.flipX&&(t=-t,l=-l,h=-h),c.flipY&&(e=-e,d=-d,u=-u),this.a=l,this.b=h,this.c=d,this.d=u,this.worldX=t+c.x,void(this.worldY=e+c.y)}let l=o.a,h=o.b,d=o.c,u=o.d;switch(this.worldX=l*t+h*e+o.worldX,this.worldY=d*t+u*e+o.worldY,this.data.transformMode){case Dt.Normal:{let t=s+90+a,e=P.cosDeg(s+r)*i,o=P.cosDeg(t)*n,c=P.sinDeg(s+r)*i,p=P.sinDeg(t)*n;return this.a=l*e+h*c,this.b=l*o+h*p,this.c=d*e+u*c,void(this.d=d*o+u*p)}case Dt.OnlyTranslation:{let t=s+90+a;this.a=P.cosDeg(s+r)*i,this.b=P.cosDeg(t)*n,this.c=P.sinDeg(s+r)*i,this.d=P.sinDeg(t)*n;break}case Dt.NoRotationOrReflection:{let t=l*l+d*d,e=0;t>1e-4?(t=Math.abs(l*u-h*d)/t,h=d*t,u=l*t,e=Math.atan2(d,l)*P.radDeg):(l=0,d=0,e=90-Math.atan2(u,h)*P.radDeg);let o=s+r-e,c=s+a-e+90,p=P.cosDeg(o)*i,m=P.cosDeg(c)*n,g=P.sinDeg(o)*i,f=P.sinDeg(c)*n;this.a=l*p-h*g,this.b=l*m-h*f,this.c=d*p+u*g,this.d=d*m+u*f;break}case Dt.NoScale:case Dt.NoScaleOrReflection:{let t=P.cosDeg(s),e=P.sinDeg(s),o=l*t+h*e,c=d*t+u*e,p=Math.sqrt(o*o+c*c);p>1e-5&&(p=1/p),o*=p,c*=p,p=Math.sqrt(o*o+c*c);let m=Math.PI/2+Math.atan2(c,o),g=Math.cos(m)*p,f=Math.sin(m)*p,x=P.cosDeg(r)*i,w=P.cosDeg(90+a)*n,b=P.sinDeg(r)*i,E=P.sinDeg(90+a)*n;return(this.data.transformMode!=Dt.NoScaleOrReflection?l*u-h*d<0:this.skeleton.flipX!=this.skeleton.flipY)&&(g=-g,f=-f),this.a=o*x+g*b,this.b=o*w+g*E,this.c=c*x+f*b,void(this.d=c*w+f*E)}}this.skeleton.flipX&&(this.a=-this.a,this.b=-this.b),this.skeleton.flipY&&(this.c=-this.c,this.d=-this.d)}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}getWorldRotationX(){return Math.atan2(this.c,this.a)*P.radDeg}getWorldRotationY(){return Math.atan2(this.d,this.b)*P.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)}updateAppliedTransform(){this.appliedValid=!0;let t=this.parent;if(null==t)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*P.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)*P.radDeg);let e=t.a,s=t.b,i=t.c,n=t.d,r=1/(e*n-s*i),a=this.worldX-t.worldX,o=this.worldY-t.worldY;this.ax=a*n*r-o*s*r,this.ay=o*e*r-a*i*r;let l=r*n,h=r*e,d=r*s,u=r*i,c=l*this.a-d*this.c,p=l*this.b-d*this.d,m=h*this.c-u*this.a,g=h*this.d-u*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(c*c+m*m),this.ascaleX>1e-4){let t=c*g-p*m;this.ascaleY=t/this.ascaleX,this.ashearY=Math.atan2(c*p+m*g,t)*P.radDeg,this.arotation=Math.atan2(m,c)*P.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(p*p+g*g),this.ashearY=0,this.arotation=90-Math.atan2(g,p)*P.radDeg}worldToLocal(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=1/(e*n-s*i),a=t.x-this.worldX,o=t.y-this.worldY;return t.x=a*n*r-o*s*r,t.y=o*e*r-a*i*r,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}worldToLocalRotation(t){let e=P.sinDeg(t),s=P.cosDeg(t);return Math.atan2(this.a*e-this.c*s,this.d*s-this.b*e)*P.radDeg}localToWorldRotation(t){let e=P.sinDeg(t),s=P.cosDeg(t);return Math.atan2(s*this.c+e*this.d,s*this.a+e*this.b)*P.radDeg}rotateWorld(t){let e=this.a,s=this.b,i=this.c,n=this.d,r=P.cosDeg(t),a=P.sinDeg(t);this.a=r*e-a*i,this.b=r*s-a*n,this.c=a*e+r*i,this.d=a*s+r*n,this.appliedValid=!1}}class _t{constructor(t){E(this,"_image"),this._image=t}getImage(){return this._image}static filterFromString(t){switch(t.toLowerCase()){case"nearest":return 9728;case"linear":return 9729;case"mipmap":case"mipmaplinearlinear":return 9987;case"mipmapnearestnearest":return 9984;case"mipmaplinearnearest":return 9985;case"mipmapnearestlinear":return 9986;default:throw new Error(`Unknown texture filter ${t}`)}}static wrapFromString(t){switch(t.toLowerCase()){case"mirroredtepeat":return 33648;case"clamptoedge":return 33071;case"repeat":return 10497;default:throw new Error(`Unknown texture wrap ${t}`)}}}var Lt,Ot,Yt=((Lt=Yt||{})[Lt.Nearest=9728]="Nearest",Lt[Lt.Linear=9729]="Linear",Lt[Lt.MipMap=9987]="MipMap",Lt[Lt.MipMapNearestNearest=9984]="MipMapNearestNearest",Lt[Lt.MipMapLinearNearest=9985]="MipMapLinearNearest",Lt[Lt.MipMapNearestLinear=9986]="MipMapNearestLinear",Lt[Lt.MipMapLinearLinear=9987]="MipMapLinearLinear",Lt),Ft=((Ot=Ft||{})[Ot.MirroredRepeat=33648]="MirroredRepeat",Ot[Ot.ClampToEdge=33071]="ClampToEdge",Ot[Ot.Repeat=10497]="Repeat",Ot);class Xt{constructor(){E(this,"renderObject"),E(this,"u",0),E(this,"v",0),E(this,"u2",0),E(this,"v2",0),E(this,"width",0),E(this,"height",0),E(this,"rotate",!1),E(this,"offsetX",0),E(this,"offsetY",0),E(this,"originalWidth",0),E(this,"originalHeight",0),E(this,"texture")}}class Bt extends _t{setFilters(t,e){}setWraps(t,e){}dispose(){}}class Wt{constructor(t,e){E(this,"pages",new Array),E(this,"regions",new Array),this.load(t,e)}load(t,e){if(null==e)throw new Error("textureLoader cannot be null.");let s=new Ut(t),i=new Array(4),n=null;for(;;){let t=s.readLine();if(null==t)break;if(t=t.trim(),0==t.length)n=null;else if(n){let e=new qt;e.name=t,e.page=n,e.rotate="true"==s.readValue(),s.readTuple(i);let r=parseInt(i[0]),a=parseInt(i[1]);s.readTuple(i);let o=parseInt(i[0]),l=parseInt(i[1]);e.u=r/n.width,e.v=a/n.height,e.rotate?(e.u2=(r+l)/n.width,e.v2=(a+o)/n.height):(e.u2=(r+o)/n.width,e.v2=(a+l)/n.height),e.x=r,e.y=a,e.width=Math.abs(o),e.height=Math.abs(l),4==s.readTuple(i)&&4==s.readTuple(i)&&s.readTuple(i),e.originalWidth=parseInt(i[0]),e.originalHeight=parseInt(i[1]),s.readTuple(i),e.offsetX=parseInt(i[0]),e.offsetY=parseInt(i[1]),e.index=parseInt(s.readValue()),e.texture=n.texture,this.regions.push(e)}else{n=new jt,n.name=t,2==s.readTuple(i)&&(n.width=parseInt(i[0]),n.height=parseInt(i[1]),s.readTuple(i)),s.readTuple(i),n.minFilter=_t.filterFromString(i[0]),n.magFilter=_t.filterFromString(i[1]);let r=s.readValue();n.uWrap=Ft.ClampToEdge,n.vWrap=Ft.ClampToEdge,"x"==r?n.uWrap=Ft.Repeat:"y"==r?n.vWrap=Ft.Repeat:"xy"==r&&(n.uWrap=n.vWrap=Ft.Repeat),n.texture=e(t),n.texture.setFilters(n.minFilter,n.magFilter),n.texture.setWraps(n.uWrap,n.vWrap),n.width=n.texture.getImage().width,n.height=n.texture.getImage().height,this.pages.push(n)}}}findRegion(t){for(let e=0;e<this.regions.length;e++)if(this.regions[e].name==t)return this.regions[e];return null}dispose(){for(let t=0;t<this.pages.length;t++)this.pages[t].texture.dispose()}}class Ut{constructor(t){E(this,"lines"),E(this,"index",0),this.lines=t.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readValue(){let t=this.readLine(),e=t.indexOf(":");if(-1==e)throw new Error("Invalid line: "+t);return t.substring(e+1).trim()}readTuple(t){let e=this.readLine(),s=e.indexOf(":");if(-1==s)throw new Error("Invalid line: "+e);let i=0,n=s+1;for(;i<3;i++){let s=e.indexOf(",",n);if(-1==s)break;t[i]=e.substr(n,s-n).trim(),n=s+1}return t[i]=e.substring(n).trim(),i+1}}class jt{constructor(){E(this,"name"),E(this,"minFilter"),E(this,"magFilter"),E(this,"uWrap"),E(this,"vWrap"),E(this,"texture"),E(this,"width"),E(this,"height")}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap),this.width=this.texture.getImage().width,this.height=this.texture.getImage().height}}class qt extends Xt{constructor(){super(...arguments),E(this,"page"),E(this,"name"),E(this,"x"),E(this,"y"),E(this,"index"),E(this,"rotate"),E(this,"texture")}}class Gt{constructor(t,e=""){E(this,"pathPrefix"),E(this,"textureLoader"),E(this,"assets",{}),E(this,"errors",{}),E(this,"toLoad",0),E(this,"loaded",0),this.textureLoader=t,this.pathPrefix=e}static downloadText(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.onload=()=>{200==i.status?e(i.responseText):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}static downloadBinary(t,e,s){let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status?e(new Uint8Array(i.response)):s(i.status,i.responseText)},i.onerror=()=>{s(i.status,i.responseText)},i.send()}loadText(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++,Gt.downloadText(t,(s=>{this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++}),((e,i)=>{this.errors[t]=`Couldn't load text ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load text ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++}))}loadTexture(t,e=null,s=null){t=this.pathPrefix+t,this.toLoad++;let i=new Image;i.crossOrigin="anonymous",i.onload=s=>{let n=this.textureLoader(i);this.assets[t]=n,this.toLoad--,this.loaded++,e&&e(t,i)},i.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,s&&s(t,`Couldn't load image ${t}`)},i.src=t}loadTextureData(t,e,s=null,i=null){t=this.pathPrefix+t,this.toLoad++;let n=new Image;n.onload=e=>{let i=this.textureLoader(n);this.assets[t]=i,this.toLoad--,this.loaded++,s&&s(t,n)},n.onerror=e=>{this.errors[t]=`Couldn't load image ${t}`,this.toLoad--,this.loaded++,i&&i(t,`Couldn't load image ${t}`)},n.src=e}loadTextureAtlas(t,e=null,s=null){let i=t.lastIndexOf("/")>=0?t.substring(0,t.lastIndexOf("/")):"";t=this.pathPrefix+t,this.toLoad++,Gt.downloadText(t,(n=>{var r={count:0},a=new Array;try{new Wt(n,(t=>{a.push(i+"/"+t);let e=document.createElement("img");return e.width=16,e.height=16,new Bt(e)}))}catch(e){let i=e;return this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,void this.loaded++}for(let o of a){let l=!1;this.loadTexture(o,((o,h)=>{if(r.count++,r.count==a.length)if(l)this.errors[t]=`Couldn't load texture atlas page ${o}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${o} of atlas ${t}`),this.toLoad--,this.loaded++;else try{let s=new Wt(n,(t=>this.get(i+"/"+t)));this.assets[t]=s,e&&e(t,s),this.toLoad--,this.loaded++}catch(e){let i=e;this.errors[t]=`Couldn't load texture atlas ${t}: ${i.message}`,s&&s(t,`Couldn't load texture atlas ${t}: ${i.message}`),this.toLoad--,this.loaded++}}),((e,i)=>{l=!0,r.count++,r.count==a.length&&(this.errors[t]=`Couldn't load texture atlas page ${e}} of atlas ${t}`,s&&s(t,`Couldn't load texture atlas page ${e} of atlas ${t}`),this.toLoad--,this.loaded++)}))}}),((e,i)=>{this.errors[t]=`Couldn't load texture atlas ${t}: status ${status}, ${i}`,s&&s(t,`Couldn't load texture atlas ${t}: status ${status}, ${i}`),this.toLoad--,this.loaded++}))}get(t){return t=this.pathPrefix+t,this.assets[t]}remove(t){t=this.pathPrefix+t;let e=this.assets[t];e.dispose&&e.dispose(),this.assets[t]=null}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}}class $t{constructor(t,e){if(E(this,"data"),E(this,"intValue"),E(this,"floatValue"),E(this,"stringValue"),E(this,"time"),null==e)throw new Error("data cannot be null.");this.time=t,this.data=e}}class zt{constructor(t){E(this,"name"),E(this,"intValue"),E(this,"floatValue"),E(this,"stringValue"),this.name=t}}class Ht{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"mix",1),E(this,"bendDirection",0),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.mix=t.mix,this.bendDirection=t.bendDirection,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}getOrder(){return this.data.order}apply(){this.update()}update(){let t=this.target,e=this.bones;switch(e.length){case 1:this.apply1(e[0],t.worldX,t.worldY,this.mix);break;case 2:this.apply2(e[0],e[1],t.worldX,t.worldY,this.bendDirection,this.mix)}}apply1(t,e,s,i){t.appliedValid||t.updateAppliedTransform();let n=t.parent,r=1/(n.a*n.d-n.b*n.c),a=e-n.worldX,o=s-n.worldY,l=(a*n.d-o*n.b)*r-t.ax,h=(o*n.a-a*n.c)*r-t.ay,d=Math.atan2(h,l)*P.radDeg-t.ashearX-t.arotation;t.ascaleX<0&&(d+=180),d>180?d-=360:d<-180&&(d+=360),t.updateWorldTransformWith(t.ax,t.ay,t.arotation+d*i,t.ascaleX,t.ascaleY,t.ashearX,t.ashearY)}apply2(t,e,s,i,n,r){if(0==r)return void e.updateWorldTransform();t.appliedValid||t.updateAppliedTransform(),e.appliedValid||e.updateAppliedTransform();let a=t.ax,o=t.ay,l=t.ascaleX,h=t.ascaleY,d=e.ascaleX,u=0,c=0,p=0;l<0?(l=-l,u=180,p=-1):(u=0,p=1),h<0&&(h=-h,p=-p),d<0?(d=-d,c=180):c=0;let m=e.ax,g=0,f=0,x=0,w=t.a,b=t.b,E=t.c,y=t.d,T=Math.abs(l-h)<=1e-4;T?(g=e.ay,f=w*m+b*g+t.worldX,x=E*m+y*g+t.worldY):(g=0,f=w*m+t.worldX,x=E*m+t.worldY);let A=t.parent;w=A.a,b=A.b,E=A.c,y=A.d;let C=1/(w*y-b*E),M=s-A.worldX,S=i-A.worldY,v=(M*y-S*b)*C-a,R=(S*w-M*E)*C-o;M=f-A.worldX,S=x-A.worldY;let I=(M*y-S*b)*C-a,k=(S*w-M*E)*C-o,V=Math.sqrt(I*I+k*k),D=e.data.length*d,N=0,_=0;t:if(T){D*=l;let t=(v*v+R*R-V*V-D*D)/(2*V*D);t<-1?t=-1:t>1&&(t=1),_=Math.acos(t)*n,w=V+D*t,b=D*Math.sin(_),N=Math.atan2(R*w-v*b,v*w+R*b)}else{w=l*D,b=h*D;let t=w*w,e=b*b,s=v*v+R*R,i=Math.atan2(R,v);E=e*V*V+t*s-t*e;let r=-2*e*V,a=e-t;if(y=r*r-4*a*E,y>=0){let t=Math.sqrt(y);r<0&&(t=-t),t=-(r+t)/2;let e=t/a,o=E/t,d=Math.abs(e)<Math.abs(o)?e:o;if(d*d<=s){S=Math.sqrt(s-d*d)*n,N=i-Math.atan2(S,d),_=Math.atan2(S/h,(d-V)/l);break t}}let o=P.PI,d=V-w,u=d*d,c=0,p=0,m=V+w,g=m*m,f=0;E=-w*V/(t-e),E>=-1&&E<=1&&(E=Math.acos(E),M=w*Math.cos(E)+V,S=b*Math.sin(E),y=M*M+S*S,y<u&&(o=E,u=y,d=M,c=S),y>g&&(p=E,g=y,m=M,f=S)),s<=(u+g)/2?(N=i-Math.atan2(c*n,d),_=o*n):(N=i-Math.atan2(f*n,m),_=p*n)}let L=Math.atan2(g,m)*p,O=t.arotation;N=(N-L)*P.radDeg+u-O,N>180?N-=360:N<-180&&(N+=360),t.updateWorldTransformWith(a,o,O+N*r,t.ascaleX,t.ascaleY,0,0),O=e.arotation,_=((_+L)*P.radDeg-e.ashearX)*p+c-O,_>180?_-=360:_<-180&&(_+=360),e.updateWorldTransformWith(m,g,O+_*r,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)}}class Zt{constructor(t){E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"bendDirection",1),E(this,"mix",1),this.name=t}}class Jt{constructor(t){E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"positionMode"),E(this,"spacingMode"),E(this,"rotateMode"),E(this,"offsetRotation"),E(this,"position"),E(this,"spacing"),E(this,"rotateMix"),E(this,"translateMix"),this.name=t}}var Qt,Kt,te,ee=((Qt=ee||{})[Qt.Fixed=0]="Fixed",Qt[Qt.Percent=1]="Percent",Qt),se=((Kt=se||{})[Kt.Length=0]="Length",Kt[Kt.Fixed=1]="Fixed",Kt[Kt.Percent=2]="Percent",Kt),ie=((te=ie||{})[te.Tangent=0]="Tangent",te[te.Chain=1]="Chain",te[te.ChainScale=2]="ChainScale",te);const ne=class t{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"position",0),E(this,"spacing",0),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"spaces",new Array),E(this,"positions",new Array),E(this,"world",new Array),E(this,"curves",new Array),E(this,"lengths",new Array),E(this,"segments",new Array),null==t)throw new Error("data cannot be null.");if(null==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++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findSlot(t.target.name),this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix}apply(){this.update()}update(){let e=this.target.getAttachment();if(!(e instanceof St))return;let s=this.rotateMix,i=this.translateMix,n=s>0;if(!(i>0)&&!n)return;let r=this.data,a=r.spacingMode,o=a==se.Length,l=r.rotateMode,h=l==ie.Tangent,d=l==ie.ChainScale,u=this.bones.length,c=h?u:u+1,p=this.bones,m=N.setArraySize(this.spaces,c),g=null,f=this.spacing;if(d||o){d&&(g=N.setArraySize(this.lengths,u));for(let e=0,s=c-1;e<s;){let s=p[e],i=s.data.length;if(i<t.epsilon)d&&(g[e]=0),m[++e]=0;else{let t=i*s.a,n=i*s.c,r=Math.sqrt(t*t+n*n);d&&(g[e]=r),m[++e]=(o?i+f:f)*r/i}}}else for(let t=1;t<c;t++)m[t]=f;let x=this.computeWorldPositions(e,c,h,r.positionMode==ee.Percent,a==se.Percent),w=x[0],b=x[1],E=r.offsetRotation,y=!1;if(0==E)y=l==ie.Chain;else{y=!1;let t=this.target.bone;E*=t.a*t.d-t.b*t.c>0?P.degRad:-P.degRad}for(let t=0,e=3;t<u;t++,e+=3){let r=p[t];r.worldX+=(w-r.worldX)*i,r.worldY+=(b-r.worldY)*i;let a=x[e],o=x[e+1],l=a-w,u=o-b;if(d){let e=g[t];if(0!=e){let t=(Math.sqrt(l*l+u*u)/e-1)*s+1;r.a*=t,r.c*=t}}if(w=a,b=o,n){let i=r.a,n=r.b,a=r.c,o=r.d,d=0,c=0,p=0;if(d=h?x[e-1]:0==m[t+1]?x[e+2]:Math.atan2(u,l),d-=Math.atan2(a,i),y){c=Math.cos(d),p=Math.sin(d);let t=r.data.length;w+=(t*(c*i-p*a)-l)*s,b+=(t*(p*i+c*a)-u)*s}else d+=E;d>P.PI?d-=P.PI2:d<-P.PI&&(d+=P.PI2),d*=s,c=Math.cos(d),p=Math.sin(d),r.a=c*i-p*a,r.b=c*n-p*o,r.c=p*i+c*a,r.d=p*n+c*o}r.appliedValid=!1}}computeWorldPositions(e,s,i,n,r){let a=this.target,o=this.position,l=this.spaces,h=N.setArraySize(this.positions,3*s+2),d=null,u=e.closed,c=e.worldVerticesLength,p=c/6,m=t.NONE;if(!e.constantSpeed){let g=e.lengths;p-=u?1:2;let f=g[p];if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;d=N.setArraySize(this.world,8);for(let n=0,r=0,x=0;n<s;n++,r+=3){let s=l[n];o+=s;let w=o;if(u)w%=f,w<0&&(w+=f),x=0;else{if(w<0){m!=t.BEFORE&&(m=t.BEFORE,e.computeWorldVertices(a,2,4,d,0,2)),this.addBeforePosition(w,d,0,h,r);continue}if(w>f){m!=t.AFTER&&(m=t.AFTER,e.computeWorldVertices(a,c-6,4,d,0,2)),this.addAfterPosition(w-f,d,0,h,r);continue}}for(;;x++){let t=g[x];if(!(w>t)){if(0==x)w/=t;else{let e=g[x-1];w=(w-e)/(t-e)}break}}x!=m&&(m=x,u&&x==p?(e.computeWorldVertices(a,c-4,4,d,0,2),e.computeWorldVertices(a,0,4,d,4,2)):e.computeWorldVertices(a,6*x+2,8,d,0,2)),this.addCurvePosition(w,d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],h,r,i||n>0&&0==s)}return h}u?(c+=2,d=N.setArraySize(this.world,c),e.computeWorldVertices(a,2,c-4,d,0,2),e.computeWorldVertices(a,0,2,d,c-4,2),d[c-2]=d[0],d[c-1]=d[1]):(p--,c-=4,d=N.setArraySize(this.world,c),e.computeWorldVertices(a,2,c,d,0,2));let g=N.setArraySize(this.curves,p),f=0,x=d[0],w=d[1],b=0,E=0,y=0,T=0,A=0,C=0,M=0,S=0,v=0,R=0,P=0,I=0,k=0,V=0;for(let t=0,e=2;t<p;t++,e+=6)b=d[e],E=d[e+1],y=d[e+2],T=d[e+3],A=d[e+4],C=d[e+5],M=.1875*(x-2*b+y),S=.1875*(w-2*E+T),v=.09375*(3*(b-y)-x+A),R=.09375*(3*(E-T)-w+C),P=2*M+v,I=2*S+R,k=.75*(b-x)+M+.16666667*v,V=.75*(E-w)+S+.16666667*R,f+=Math.sqrt(k*k+V*V),k+=P,V+=I,P+=v,I+=R,f+=Math.sqrt(k*k+V*V),k+=P,V+=I,f+=Math.sqrt(k*k+V*V),k+=P+v,V+=I+R,f+=Math.sqrt(k*k+V*V),g[t]=f,x=A,w=C;if(n&&(o*=f),r)for(let t=0;t<s;t++)l[t]*=f;let D=this.segments,_=0;for(let t=0,e=0,n=0,r=0;t<s;t++,e+=3){let s=l[t];o+=s;let a=o;if(u)a%=f,a<0&&(a+=f),n=0;else{if(a<0){this.addBeforePosition(a,d,0,h,e);continue}if(a>f){this.addAfterPosition(a-f,d,c-4,h,e);continue}}for(;;n++){let t=g[n];if(!(a>t)){if(0==n)a/=t;else{let e=g[n-1];a=(a-e)/(t-e)}break}}if(n!=m){m=n;let t=6*n;for(x=d[t],w=d[t+1],b=d[t+2],E=d[t+3],y=d[t+4],T=d[t+5],A=d[t+6],C=d[t+7],M=.03*(x-2*b+y),S=.03*(w-2*E+T),v=.006*(3*(b-y)-x+A),R=.006*(3*(E-T)-w+C),P=2*M+v,I=2*S+R,k=.3*(b-x)+M+.16666667*v,V=.3*(E-w)+S+.16666667*R,_=Math.sqrt(k*k+V*V),D[0]=_,t=1;t<8;t++)k+=P,V+=I,P+=v,I+=R,_+=Math.sqrt(k*k+V*V),D[t]=_;k+=P,V+=I,_+=Math.sqrt(k*k+V*V),D[8]=_,k+=P+v,V+=I+R,_+=Math.sqrt(k*k+V*V),D[9]=_,r=0}for(a*=_;;r++){let t=D[r];if(!(a>t)){if(0==r)a/=t;else{let e=D[r-1];a=r+(a-e)/(t-e)}break}}this.addCurvePosition(.1*a,x,w,b,E,y,T,A,C,h,e,i||t>0&&0==s)}return h}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,d,u){(0==t||isNaN(t))&&(t=1e-4);let c=t*t,p=c*t,m=1-t,g=m*m,f=g*m,x=m*t,w=3*x,b=m*w,E=w*t,y=e*f+i*b+r*E+o*p,T=s*f+n*b+a*E+l*p;h[d]=y,h[d+1]=T,u&&(h[d+2]=Math.atan2(T-(s*g+n*x*2+a*c),y-(e*g+i*x*2+r*c)))}getOrder(){return this.data.order}};E(ne,"NONE",-1),E(ne,"BEFORE",-2),E(ne,"AFTER",-3),E(ne,"epsilon",1e-5);let re=ne;class ae{constructor(t,e){if(E(this,"data"),E(this,"bone"),E(this,"color"),E(this,"darkColor"),E(this,"attachment"),E(this,"attachmentTime"),E(this,"attachmentVertices",new Array),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new v,this.darkColor=null==t.darkColor?null:new v,this.setToSetupPose()}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&(this.attachment=t,this.attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0)}setAttachmentTime(t){this.attachmentTime=this.bone.skeleton.time-t}getAttachmentTime(){return this.bone.skeleton.time-this.attachmentTime}setToSetupPose(){this.color.setFromColor(this.data.color),null!=this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),null==this.data.attachmentName?this.attachment=null:(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName)))}}class oe{constructor(t,e){if(E(this,"data"),E(this,"bones"),E(this,"target"),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"scaleMix",0),E(this,"shearMix",0),E(this,"temp",new L),null==t)throw new Error("data cannot be null.");if(null==e)throw new Error("skeleton cannot be null.");this.data=t,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.scaleMix=t.scaleMix,this.shearMix=t.shearMix,this.bones=new Array;for(let s=0;s<t.bones.length;s++)this.bones.push(e.findBone(t.bones[s].name));this.target=e.findBone(t.target.name)}apply(){this.update()}update(){this.data.local?this.data.relative?this.applyRelativeLocal():this.applyAbsoluteLocal():this.data.relative?this.applyRelativeWorld():this.applyAbsoluteWorld()}applyAbsoluteWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?P.degRad:-P.degRad,d=this.data.offsetRotation*h,u=this.data.offsetShearY*h,c=this.bones;for(let h=0,p=c.length;h<p;h++){let p=c[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)-Math.atan2(i,e)+d;a>P.PI?a-=P.PI2:a<-P.PI&&(a+=P.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(t.x-p.worldX)*e,p.worldY+=(t.y-p.worldY)*e,m=!0}if(s>0){let t=Math.sqrt(p.a*p.a+p.c*p.c),e=Math.sqrt(r*r+o*o);t>1e-5&&(t=(t+(e-t+this.data.offsetScaleX)*s)/t),p.a*=t,p.c*=t,t=Math.sqrt(p.b*p.b+p.d*p.d),e=Math.sqrt(a*a+l*l),t>1e-5&&(t=(t+(e-t+this.data.offsetScaleY)*s)/t),p.b*=t,p.d*=t,m=!0}if(i>0){let t=p.b,e=p.d,s=Math.atan2(e,t),n=Math.atan2(l,a)-Math.atan2(o,r)-(s-Math.atan2(p.c,p.a));n>P.PI?n-=P.PI2:n<-P.PI&&(n+=P.PI2),n=s+(n+u)*i;let h=Math.sqrt(t*t+e*e);p.b=Math.cos(n)*h,p.d=Math.sin(n)*h,m=!0}m&&(p.appliedValid=!1)}}applyRelativeWorld(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target,r=n.a,a=n.b,o=n.c,l=n.d,h=r*l-a*o>0?P.degRad:-P.degRad,d=this.data.offsetRotation*h,u=this.data.offsetShearY*h,c=this.bones;for(let h=0,p=c.length;h<p;h++){let p=c[h],m=!1;if(0!=t){let e=p.a,s=p.b,i=p.c,n=p.d,a=Math.atan2(o,r)+d;a>P.PI?a-=P.PI2:a<-P.PI&&(a+=P.PI2),a*=t;let l=Math.cos(a),h=Math.sin(a);p.a=l*e-h*i,p.b=l*s-h*n,p.c=h*e+l*i,p.d=h*s+l*n,m=!0}if(0!=e){let t=this.temp;n.localToWorld(t.set(this.data.offsetX,this.data.offsetY)),p.worldX+=t.x*e,p.worldY+=t.y*e,m=!0}if(s>0){let t=(Math.sqrt(r*r+o*o)-1+this.data.offsetScaleX)*s+1;p.a*=t,p.c*=t,t=(Math.sqrt(a*a+l*l)-1+this.data.offsetScaleY)*s+1,p.b*=t,p.d*=t,m=!0}if(i>0){let t=Math.atan2(l,a)-Math.atan2(o,r);t>P.PI?t-=P.PI2:t<-P.PI&&(t+=P.PI2);let e=p.b,s=p.d;t=Math.atan2(s,e)+(t-P.PI/2+u)*i;let n=Math.sqrt(e*e+s*s);p.b=Math.cos(t)*n,p.d=Math.sin(t)*n,m=!0}m&&(p.appliedValid=!1)}}applyAbsoluteLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;if(0!=t){let e=n.arotation-l+this.data.offsetRotation;e-=360*(16384-(16384.499999999996-e/360|0)),l+=e*t}let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax-h+this.data.offsetX)*e,d+=(n.ay-d+this.data.offsetY)*e);let u=o.ascaleX,c=o.ascaleY;s>0&&(u>1e-5&&(u=(u+(n.ascaleX-u+this.data.offsetScaleX)*s)/u),c>1e-5&&(c=(c+(n.ascaleY-c+this.data.offsetScaleY)*s)/c));let p=o.ashearY;if(i>0){let t=n.ashearY-p+this.data.offsetShearY;t-=360*(16384-(16384.499999999996-t/360|0)),o.shearY+=t*i}o.updateWorldTransformWith(h,d,l,u,c,o.ashearX,p)}}applyRelativeLocal(){let t=this.rotateMix,e=this.translateMix,s=this.scaleMix,i=this.shearMix,n=this.target;n.appliedValid||n.updateAppliedTransform();let r=this.bones;for(let a=0,o=r.length;a<o;a++){let o=r[a];o.appliedValid||o.updateAppliedTransform();let l=o.arotation;0!=t&&(l+=(n.arotation+this.data.offsetRotation)*t);let h=o.ax,d=o.ay;0!=e&&(h+=(n.ax+this.data.offsetX)*e,d+=(n.ay+this.data.offsetY)*e);let u=o.ascaleX,c=o.ascaleY;s>0&&(u>1e-5&&(u*=(n.ascaleX-1+this.data.offsetScaleX)*s+1),c>1e-5&&(c*=(n.ascaleY-1+this.data.offsetScaleY)*s+1));let p=o.ashearY;i>0&&(p+=(n.ashearY+this.data.offsetShearY)*i),o.updateWorldTransformWith(h,d,l,u,c,o.ashearX,p)}}getOrder(){return this.data.order}}class le{constructor(t){if(E(this,"data"),E(this,"bones"),E(this,"slots"),E(this,"drawOrder"),E(this,"ikConstraints"),E(this,"transformConstraints"),E(this,"pathConstraints"),E(this,"_updateCache",new Array),E(this,"updateCacheReset",new Array),E(this,"skin"),E(this,"color"),E(this,"time",0),E(this,"flipX",!1),E(this,"flipY",!1),E(this,"x",0),E(this,"y",0),null==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(null==i.parent)s=new Nt(i,this,null);else{let t=this.bones[i.parent.index];s=new Nt(i,this,t),t.children.push(s)}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 ae(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 Ht(s,this))}this.transformConstraints=new Array;for(let e=0;e<t.transformConstraints.length;e++){let s=t.transformConstraints[e];this.transformConstraints.push(new oe(s,this))}this.pathConstraints=new Array;for(let e=0;e<t.pathConstraints.length;e++){let s=t.pathConstraints[e];this.pathConstraints.push(new re(s,this))}this.color=new v(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.updateCacheReset.length=0;let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].sorted=!1;let e=this.ikConstraints,s=this.transformConstraints,i=this.pathConstraints,n=e.length,r=s.length,a=i.length,o=n+r+a;t:for(let t=0;t<o;t++){for(let s=0;s<n;s++){let i=e[s];if(i.data.order==t){this.sortIkConstraint(i);continue t}}for(let e=0;e<r;e++){let i=s[e];if(i.data.order==t){this.sortTransformConstraint(i);continue t}}for(let e=0;e<a;e++){let s=i[e];if(s.data.order==t){this.sortPathConstraint(s);continue t}}}for(let e=0,s=t.length;e<s;e++)this.sortBone(t[e])}sortIkConstraint(t){let e=t.target;this.sortBone(e);let s=t.bones,i=s[0];if(this.sortBone(i),s.length>1){let t=s[s.length-1];this._updateCache.indexOf(t)>-1||this.updateCacheReset.push(t)}this._updateCache.push(t),this.sortReset(i.children),s[s.length-1].sorted=!0}sortPathConstraint(t){let e=t.target,s=e.data.index,i=e.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,s,i),null!=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 St&&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){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._updateCache.indexOf(s)>-1||this.updateCacheReset.push(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 St))return;let s=t.bones;if(null==s)this.sortBone(e);else{let t=this.bones,e=0;for(;e<s.length;){let i=s[e++];for(let n=e+i;e<n;e++){let i=s[e];this.sortBone(t[i])}}}}sortBone(t){if(t.sorted)return;let e=t.parent;null!=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.sorted&&this.sortReset(s.children),s.sorted=!1}}updateWorldTransform(){let t=this.updateCacheReset;for(let e=0,s=t.length;e<s;e++){let s=t[e];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,s.appliedValid=!0}let e=this._updateCache;for(let t=0,s=e.length;t<s;t++)e[t].update()}setToSetupPose(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()}setBonesToSetupPose(){let t=this.bones;for(let e=0,s=t.length;e<s;e++)t[e].setToSetupPose();let e=this.ikConstraints;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.bendDirection=s.data.bendDirection,s.mix=s.data.mix}let s=this.transformConstraints;for(let t=0,e=s.length;t<e;t++){let e=s[t],i=e.data;e.rotateMix=i.rotateMix,e.translateMix=i.translateMix,e.scaleMix=i.scaleMix,e.shearMix=i.shearMix}let i=this.pathConstraints;for(let t=0,e=i.length;t<e;t++){let e=i[t],s=e.data;e.position=s.position,e.spacing=s.spacing,e.rotateMix=s.rotateMix,e.translateMix=s.translateMix}}setSlotsToSetupPose(){let t=this.slots;N.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(null==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}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}findSlot(t){if(null==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}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].data.name==t)return s;return-1}setSkinByName(t){let e=this.data.findSkin(t);if(null==e)throw new Error("Skin not found: "+t);this.setSkin(e)}setSkin(t){if(null!=t)if(null!=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(null!=n){let e=t.getAttachment(s,n);null!=e&&i.setAttachment(e)}}}this.skin=t}getAttachmentByName(t,e){return this.getAttachment(this.data.findSlotIndex(t),e)}getAttachment(t,e){if(null==e)throw new Error("attachmentName cannot be null.");if(null!=this.skin){let s=this.skin.getAttachment(t,e);if(null!=s)return s}return null!=this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null}setAttachment(t,e){if(null==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(null!=e&&(s=this.getAttachment(i,e),null==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(null==t)throw new 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.data.name==t)return i}return null}findTransformConstraint(t){if(null==t)throw new 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.data.name==t)return i}return null}findPathConstraint(t){if(null==t)throw new 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.data.name==t)return i}return null}getBounds(t,e,s){if(null==t)throw new Error("offset cannot be null.");if(null==e)throw new Error("size cannot be null.");let i=this.drawOrder,n=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let t=0,e=i.length;t<e;t++){let e=i[t],l=0,h=null,d=e.getAttachment();if(d instanceof Pt)l=8,h=N.setArraySize(s,l,0),d.computeWorldVertices(e.bone,h,0,2);else if(d instanceof Mt){let t=d;l=t.worldVerticesLength,h=N.setArraySize(s,l,0),t.computeWorldVertices(e,0,l,h,0,2)}if(null!=h)for(let t=0,e=h.length;t<e;t+=2){let e=h[t],s=h[t+1];n=Math.min(n,e),r=Math.min(r,s),a=Math.max(a,e),o=Math.max(o,s)}}t.set(n,r),e.set(a-n,o-r)}update(t){this.time+=t}}class he{constructor(){E(this,"minX",0),E(this,"minY",0),E(this,"maxX",0),E(this,"maxY",0),E(this,"boundingBoxes",new Array),E(this,"polygons",new Array),E(this,"polygonPool",new _((()=>N.newFloatArray(16))))}update(t,e){if(null==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],a=e.getAttachment();if(a instanceof At){let t=a;s.push(t);let r=n.obtain();r.length!=t.worldVerticesLength&&(r=N.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 d=(r-e)/l+t;return d>n&&d<a||(d=(o-e)/l+t,d>n&&d<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,d=r[a-2],u=r[a-1];for(let t=0;t<a;t+=2){let a=r[t],c=r[t+1],p=d*c-u*a,m=d-a,g=u-c,f=o*g-l*m,x=(h*m-o*p)/f;if((x>=d&&x<=a||x>=a&&x<=d)&&(x>=e&&x<=i||x>=i&&x<=e)){let t=(h*g-l*p)/f;if((t>=u&&t<=c||t>=c&&t<=u)&&(t>=s&&t<=n||t>=n&&t<=s))return!0}d=a,u=c}return!1}getPolygon(t){if(null==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}}class de{constructor(){E(this,"convexPolygons",new Array),E(this,"convexPolygonsIndices",new Array),E(this,"indicesArray",new Array),E(this,"isConcaveArray",new Array),E(this,"triangles",new Array),E(this,"polygonPool",new _((()=>new Array))),E(this,"polygonIndicesPool",new _((()=>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]=de.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,d=e[r],u=e[r+1],c=e[l],p=e[l+1],m=e[h],g=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(de.positiveArea(m,g,d,u,s,a)&&de.positiveArea(d,u,c,p,s,a)&&de.positiveArea(c,p,m,g,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]=de.isConcave(l,s,e,i),n[h]=de.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,d=e[t+1]<<1,u=e[t+2]<<1,c=s[h],p=s[h+1],m=s[d],g=s[d+1],f=s[u],x=s[u+1],w=!1;if(o==h){let t=a.length-4,e=de.winding(a[t],a[t+1],a[t+2],a[t+3],f,x),s=de.winding(f,x,a[0],a[1],a[2],a[3]);e==l&&s==l&&(a.push(f),a.push(x),r.push(u),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(c),a.push(p),a.push(m),a.push(g),a.push(f),a.push(x),r=this.polygonIndicesPool.obtain(),r.length=0,r.push(h),r.push(d),r.push(u),l=de.winding(c,p,m,g,f,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],d=a[l+1],u=a[l+2],c=a[l+3],p=a[0],m=a[1],g=a[2],f=a[3],x=de.winding(h,d,u,c,p,m);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],E=e[2],y=i[l],T=y[y.length-2],A=y[y.length-1];if(w!=s||b!=o)continue;let C=de.winding(h,d,u,c,T,A),M=de.winding(T,A,p,m,g,f);C==x&&M==x&&(y.length=0,e.length=0,a.push(T),a.push(A),r.push(E),h=u,d=c,u=T,c=A,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 ue{constructor(){E(this,"triangulator",new de),E(this,"clippingPolygon",new Array),E(this,"clipOutput",new Array),E(this,"clippedVertices",new Array),E(this,"clippedUVs",new Array),E(this,"clippedTriangles",new Array),E(this,"scratch",new Array),E(this,"clipAttachment"),E(this,"clippingPolygons")}clipStart(t,e){if(null!=this.clipAttachment)return 0;this.clipAttachment=e;let s=e.worldVerticesLength,i=N.setArraySize(this.clippingPolygon,s);e.computeWorldVertices(t,0,s,i,0,2);let n=this.clippingPolygon;ue.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];ue.makeClockwise(e),e.push(e[0]),e.push(e[1])}return r.length}clipEndWithSlot(t){null!=this.clipAttachment&&this.clipAttachment.endSlot==t.data&&this.clipEnd()}clipEnd(){null!=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=this.clipOutput,h=this.clippedVertices,d=this.clippedTriangles,u=this.clippingPolygons,c=this.clippingPolygons.length,p=o?12:8,m=0;h.length=0,d.length=0;t:for(let e=0;e<i;e+=3){let i=s[e]<<1,g=t[i],f=t[i+1],x=n[i],w=n[i+1];i=s[e+1]<<1;let b=t[i],E=t[i+1],y=n[i],T=n[i+1];i=s[e+2]<<1;let A=t[i],C=t[i+1],M=n[i],S=n[i+1];for(let t=0;t<c;t++){let e=h.length;if(!this.clip(g,f,b,E,A,C,u[t],l)){let t=N.setArraySize(h,e+3*p);t[e]=g,t[e+1]=f,t[e+2]=r.r,t[e+3]=r.g,t[e+4]=r.b,t[e+5]=r.a,o?(t[e+6]=x,t[e+7]=w,t[e+8]=a.r,t[e+9]=a.g,t[e+10]=a.b,t[e+11]=a.a,t[e+12]=b,t[e+13]=E,t[e+14]=r.r,t[e+15]=r.g,t[e+16]=r.b,t[e+17]=r.a,t[e+18]=y,t[e+19]=T,t[e+20]=a.r,t[e+21]=a.g,t[e+22]=a.b,t[e+23]=a.a,t[e+24]=A,t[e+25]=C,t[e+26]=r.r,t[e+27]=r.g,t[e+28]=r.b,t[e+29]=r.a,t[e+30]=M,t[e+31]=S,t[e+32]=a.r,t[e+33]=a.g,t[e+34]=a.b,t[e+35]=a.a):(t[e+6]=x,t[e+7]=w,t[e+8]=b,t[e+9]=E,t[e+10]=r.r,t[e+11]=r.g,t[e+12]=r.b,t[e+13]=r.a,t[e+14]=y,t[e+15]=T,t[e+16]=A,t[e+17]=C,t[e+18]=r.r,t[e+19]=r.g,t[e+20]=r.b,t[e+21]=r.a,t[e+22]=M,t[e+23]=S),e=d.length;let s=N.setArraySize(d,e+3);s[e]=m,s[e+1]=m+1,s[e+2]=m+2,m+=3;continue t}{let t=l.length;if(0==t)continue;let s=E-C,i=A-b,n=g-A,u=C-f,c=1/(s*n+i*(f-C)),v=t>>1,R=this.clipOutput,P=N.setArraySize(h,e+v*p);for(let l=0;l<t;l+=2){let t=R[l],h=R[l+1];P[e]=t,P[e+1]=h,P[e+2]=r.r,P[e+3]=r.g,P[e+4]=r.b,P[e+5]=r.a;let d=t-A,m=h-C,g=(s*d+i*m)*c,f=(u*d+n*m)*c,b=1-g-f;P[e+6]=x*g+y*f+M*b,P[e+7]=w*g+T*f+S*b,o&&(P[e+8]=a.r,P[e+9]=a.g,P[e+10]=a.b,P[e+11]=a.a),e+=p}e=d.length;let I=N.setArraySize(d,e+3*(v-2));v--;for(let t=1;t<v;t++)I[e]=m,I[e+1]=m+t,I[e+2]=m+t+1,e+=3;m+=v+1}}}}clipTrianglesUnpacked(t,e,s,i){let n=this.clipOutput,r=this.clippedVertices,a=this.clippedUVs,o=this.clippedTriangles,l=this.clippingPolygons,h=l.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,c=t[s],p=t[s+1],m=i[s],g=i[s+1];s=e[u+1]<<1;let f=t[s],x=t[s+1],w=i[s],b=i[s+1];s=e[u+2]<<1;let E=t[s],y=t[s+1],T=i[s],A=i[s+1];for(let t=0;t<h;t++){let e=r.length;if(!this.clip(c,p,f,x,E,y,l[t],n)){let t=N.setArraySize(r,e+6);t[e]=c,t[e+1]=p,t[e+2]=f,t[e+3]=x,t[e+4]=E,t[e+5]=y;let s=N.setArraySize(a,e+6);s[e]=m,s[e+1]=g,s[e+2]=w,s[e+3]=b,s[e+4]=T,s[e+5]=A,e=o.length;let i=N.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=x-y,i=E-f,l=c-E,h=y-p,u=1/(s*l+i*(p-y)),C=t>>1,M=this.clipOutput,S=N.setArraySize(r,e+2*C),v=N.setArraySize(a,e+2*C);for(let n=0;n<t;n+=2,e+=2){let t=M[n],r=M[n+1];S[e]=t,S[e+1]=r;let a=t-E,o=r-y,d=(s*a+i*o)*u,c=(h*a+l*o)*u,p=1-d-c;v[e]=m*d+w*c+T*p,v[e+1]=g*d+b*c+A*p}e=o.length;let R=N.setArraySize(o,e+3*(C-2));C--;for(let t=1;t<C;t++,e+=3)R[e]=d,R[e+1]=d+t,R[e+2]=d+t+1;d+=C+1}}}}clip(t,e,s,i,n,r,a,o){let l=o,h=!1,d=null;a.length%4>=2?(d=o,o=this.scratch):d=this.scratch,d.length=0,d.push(t),d.push(e),d.push(s),d.push(i),d.push(n),d.push(r),d.push(t),d.push(e),o.length=0;let u=a,c=a.length-4;for(let t=0;;t+=2){let e=u[t],s=u[t+1],i=u[t+2],n=u[t+3],r=e-i,a=s-n,p=d,m=d.length-2,g=o.length;for(let t=0;t<m;t+=2){let l=p[t],d=p[t+1],u=p[t+2],c=p[t+3],m=r*(c-n)-a*(u-i)>0;if(r*(d-n)-a*(l-i)>0){if(m){o.push(u),o.push(c);continue}let t=c-d,r=u-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s)}else if(m){let t=c-d,r=u-l,a=t*(i-e)-r*(n-s);if(Math.abs(a)>1e-6){let h=(r*(s-d)-t*(e-l))/a;o.push(e+(i-e)*h),o.push(s+(n-s)*h)}else o.push(e),o.push(s);o.push(u),o.push(c)}h=!0}if(g==o.length)return l.length=0,!0;if(o.push(o[0]),o.push(o[1]),t==c)break;let f=o;(o=d).length=0,d=f}if(l!=o){l.length=0;for(let t=0,e=o.length-2;t<e;t++)l[t]=o[t]}else l.length=l.length-2;return h}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 ce{constructor(){E(this,"name"),E(this,"bones",new Array),E(this,"slots",new Array),E(this,"skins",new Array),E(this,"defaultSkin"),E(this,"events",new Array),E(this,"animations",new Array),E(this,"ikConstraints",new Array),E(this,"transformConstraints",new Array),E(this,"pathConstraints",new Array),E(this,"width"),E(this,"height"),E(this,"version"),E(this,"hash"),E(this,"fps",0),E(this,"imagesPath")}findBone(t){if(null==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}findBoneIndex(t){if(null==t)throw new Error("boneName cannot be null.");let e=this.bones;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSlot(t){if(null==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}findSlotIndex(t){if(null==t)throw new Error("slotName cannot be null.");let e=this.slots;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}findSkin(t){if(null==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(null==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(null==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(null==t)throw new 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(null==t)throw new 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(null==t)throw new 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}findPathConstraintIndex(t){if(null==t)throw new Error("pathConstraintName cannot be null.");let e=this.pathConstraints;for(let s=0,i=e.length;s<i;s++)if(e[s].name==t)return s;return-1}}var pe,me,ge=((pe=ge||{})[pe.Normal=0]="Normal",pe[pe.Additive=1]="Additive",pe[pe.Multiply=2]="Multiply",pe[pe.Screen=3]="Screen",pe);class fe{constructor(t){if(E(this,"name"),E(this,"attachments",new Array),null==t)throw new Error("name cannot be null.");this.name=t}addAttachment(t,e,s){if(null==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}getAttachment(t,e){let s=this.attachments[t];return s?s[e]:null}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);null!=t&&n.setAttachment(t);break}}}s++}}}class xe{constructor(t,e,s){if(E(this,"index"),E(this,"name"),E(this,"boneData"),E(this,"color",new v(1,1,1,1)),E(this,"darkColor"),E(this,"attachmentName"),E(this,"blendMode"),t<0)throw new Error("index must be >= 0.");if(null==e)throw new Error("name cannot be null.");if(null==s)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=s}}class we{constructor(t){if(E(this,"name"),E(this,"order",0),E(this,"bones",new Array),E(this,"target"),E(this,"rotateMix",0),E(this,"translateMix",0),E(this,"scaleMix",0),E(this,"shearMix",0),E(this,"offsetRotation",0),E(this,"offsetX",0),E(this,"offsetY",0),E(this,"offsetScaleX",0),E(this,"offsetScaleY",0),E(this,"offsetShearY",0),E(this,"relative",!1),E(this,"local",!1),null==t)throw new Error("name cannot be null.");this.name=t}}class be{constructor(t){E(this,"attachmentLoader"),E(this,"scale",1),E(this,"linkedMeshes",new Array),this.attachmentLoader=t}readSkeletonData(t){let e=this.scale,s=new ce,i="string"==typeof t?JSON.parse(t):t,n=i.skeleton;if(null!=n&&(s.hash=n.hash,s.version=n.spine,s.width=n.width,s.height=n.height,s.fps=n.fps,s.imagesPath=n.images),i.bones)for(let t=0;t<i.bones.length;t++){let n=i.bones[t],r=null,a=this.getValue(n,"parent",null);if(null!=a&&(r=s.findBone(a),null==r))throw new Error("Parent bone not found: "+a);let o=new kt(s.bones.length,n.name,r);o.length=this.getValue(n,"length",0)*e,o.x=this.getValue(n,"x",0)*e,o.y=this.getValue(n,"y",0)*e,o.rotation=this.getValue(n,"rotation",0),o.scaleX=this.getValue(n,"scaleX",1),o.scaleY=this.getValue(n,"scaleY",1),o.shearX=this.getValue(n,"shearX",0),o.shearY=this.getValue(n,"shearY",0),o.transformMode=be.transformModeFromString(this.getValue(n,"transform","normal")),s.bones.push(o)}if(i.slots)for(let t=0;t<i.slots.length;t++){let e=i.slots[t],n=e.name,r=e.bone,a=s.findBone(r);if(null==a)throw new Error("Slot bone not found: "+r);let o=new xe(s.slots.length,n,a),l=this.getValue(e,"color",null);null!=l&&o.color.setFromString(l);let h=this.getValue(e,"dark",null);null!=h&&(o.darkColor=new v(1,1,1,1),o.darkColor.setFromString(h)),o.attachmentName=this.getValue(e,"attachment",null),o.blendMode=be.blendModeFromString(this.getValue(e,"blend","normal")),s.slots.push(o)}if(i.ik)for(let t=0;t<i.ik.length;t++){let e=i.ik[t],n=new Zt(e.name);n.order=this.getValue(e,"order",0);for(let t=0;t<e.bones.length;t++){let i=e.bones[t],r=s.findBone(i);if(null==r)throw new Error("IK bone not found: "+i);n.bones.push(r)}let r=e.target;if(n.target=s.findBone(r),null==n.target)throw new Error("IK target bone not found: "+r);n.bendDirection=this.getValue(e,"bendPositive",!0)?1:-1,n.mix=this.getValue(e,"mix",1),s.ikConstraints.push(n)}if(i.transform)for(let t=0;t<i.transform.length;t++){let n=i.transform[t],r=new we(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findBone(a),null==r.target)throw new Error("Transform constraint target bone not found: "+a);r.local=this.getValue(n,"local",!1),r.relative=this.getValue(n,"relative",!1),r.offsetRotation=this.getValue(n,"rotation",0),r.offsetX=this.getValue(n,"x",0)*e,r.offsetY=this.getValue(n,"y",0)*e,r.offsetScaleX=this.getValue(n,"scaleX",0),r.offsetScaleY=this.getValue(n,"scaleY",0),r.offsetShearY=this.getValue(n,"shearY",0),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),r.scaleMix=this.getValue(n,"scaleMix",1),r.shearMix=this.getValue(n,"shearMix",1),s.transformConstraints.push(r)}if(i.path)for(let t=0;t<i.path.length;t++){let n=i.path[t],r=new Jt(n.name);r.order=this.getValue(n,"order",0);for(let t=0;t<n.bones.length;t++){let e=n.bones[t],i=s.findBone(e);if(null==i)throw new Error("Transform constraint bone not found: "+e);r.bones.push(i)}let a=n.target;if(r.target=s.findSlot(a),null==r.target)throw new Error("Path target slot not found: "+a);r.positionMode=be.positionModeFromString(this.getValue(n,"positionMode","percent")),r.spacingMode=be.spacingModeFromString(this.getValue(n,"spacingMode","length")),r.rotateMode=be.rotateModeFromString(this.getValue(n,"rotateMode","tangent")),r.offsetRotation=this.getValue(n,"rotation",0),r.position=this.getValue(n,"position",0),r.positionMode==ee.Fixed&&(r.position*=e),r.spacing=this.getValue(n,"spacing",0),r.spacingMode!=se.Length&&r.spacingMode!=se.Fixed||(r.spacing*=e),r.rotateMix=this.getValue(n,"rotateMix",1),r.translateMix=this.getValue(n,"translateMix",1),s.pathConstraints.push(r)}if(i.skins)for(let t in i.skins){let e=i.skins[t],n=new fe(t);for(let t in e){let i=s.findSlotIndex(t);if(-1==i)throw new Error("Slot not found: "+t);let r=e[t];for(let t in r){let e=this.readAttachment(r[t],n,i,t,s);null!=e&&n.addAttachment(i,t,e)}}s.skins.push(n),"default"==n.name&&(s.defaultSkin=n)}for(let t=0,e=this.linkedMeshes.length;t<e;t++){let e=this.linkedMeshes[t],i=null==e.skin?s.defaultSkin:s.findSkin(e.skin);if(null==i)throw new Error("Skin not found: "+e.skin);let n=i.getAttachment(e.slotIndex,e.parent);if(null==n)throw new Error("Parent mesh not found: "+e.parent);e.mesh.setParentMesh(n),e.mesh.updateUVs()}if(this.linkedMeshes.length=0,i.events)for(let t in i.events){let e=i.events[t],n=new zt(t);n.intValue=this.getValue(e,"int",0),n.floatValue=this.getValue(e,"float",0),n.stringValue=this.getValue(e,"string",""),s.events.push(n)}if(i.animations)for(let t in i.animations){let e=i.animations[t];this.readAnimation(e,t,s)}return s}readAttachment(t,e,s,i,n){let r=this.scale;switch(i=this.getValue(t,"name",i),this.getValue(t,"type","region")){case"region":{let s=this.getValue(t,"path",i),n=this.attachmentLoader.newRegionAttachment(e,i,s);if(null==n)return null;n.path=s,n.x=this.getValue(t,"x",0)*r,n.y=this.getValue(t,"y",0)*r,n.scaleX=this.getValue(t,"scaleX",1),n.scaleY=this.getValue(t,"scaleY",1),n.rotation=this.getValue(t,"rotation",0),n.width=t.width*r,n.height=t.height*r;let a=this.getValue(t,"color",null);return null!=a&&n.color.setFromString(a),n.updateOffset(),n}case"boundingbox":{let s=this.attachmentLoader.newBoundingBoxAttachment(e,i);if(null==s)return null;this.readVertices(t,s,t.vertexCount<<1);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"mesh":case"linkedmesh":{let n=this.getValue(t,"path",i),r=this.attachmentLoader.newMeshAttachment(e,i,n);if(null==r)return null;r.path=n;let a=this.getValue(t,"color",null);null!=a&&r.color.setFromString(a);let o=this.getValue(t,"parent",null);if(null!=o)return r.inheritDeform=this.getValue(t,"deform",!0),this.linkedMeshes.push(new Ee(r,this.getValue(t,"skin",null),s,o)),r;let l=t.uvs;return this.readVertices(t,r,l.length),r.triangles=t.triangles,r.regionUVs=l,r.updateUVs(),r.hullLength=2*this.getValue(t,"hull",0),r}case"path":{let s=this.attachmentLoader.newPathAttachment(e,i);if(null==s)return null;s.closed=this.getValue(t,"closed",!1),s.constantSpeed=this.getValue(t,"constantSpeed",!0);let n=t.vertexCount;this.readVertices(t,s,n<<1);let a=N.newArray(n/3,0);for(let e=0;e<t.lengths.length;e++)a[e]=t.lengths[e]*r;s.lengths=a;let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}case"point":{let s=this.attachmentLoader.newPointAttachment(e,i);if(null==s)return null;s.x=this.getValue(t,"x",0)*r,s.y=this.getValue(t,"y",0)*r,s.rotation=this.getValue(t,"rotation",0);let n=this.getValue(t,"color",null);return null!=n&&s.color.setFromString(n),s}case"clipping":{let s=this.attachmentLoader.newClippingAttachment(e,i);if(null==s)return null;let r=this.getValue(t,"end",null);if(null!=r){let t=n.findSlot(r);if(null==t)throw new Error("Clipping end slot not found: "+r);s.endSlot=t}let a=t.vertexCount;this.readVertices(t,s,a<<1);let o=this.getValue(t,"color",null);return null!=o&&s.color.setFromString(o),s}}return null}readVertices(t,e,s){let i=this.scale;e.worldVerticesLength=s;let n=t.vertices;if(s==n.length){let t=N.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=N.toFloatArray(r)}readAnimation(t,e,s){let i=this.scale,n=new Array,r=0;if(t.slots)for(let e in t.slots){let i=t.slots[e],a=s.findSlotIndex(e);if(-1==a)throw new Error("Slot not found: "+e);for(let t in i){let s=i[t];if("attachment"==t){let t=new st(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e++,n.time,n.name)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}else if("color"==t){let t=new K(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new v;r.setFromString(n.color),t.setFrame(e,n.time,r.r,r.g,r.b,r.a),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*K.ENTRIES])}else{if("twoColor"!=t)throw new Error("Invalid timeline type for a slot: "+t+" ("+e+")");{let t=new et(s.length);t.slotIndex=a;let e=0;for(let i=0;i<s.length;i++){let n=s[i],r=new v,a=new v;r.setFromString(n.light),a.setFromString(n.dark),t.setFrame(e,n.time,r.r,r.g,r.b,r.a,a.r,a.g,a.b),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*et.ENTRIES])}}}}if(t.bones)for(let e in t.bones){let a=t.bones[e],o=s.findBoneIndex(e);if(-1==o)throw new Error("Bone not found: "+e);for(let t in a){let s=a[t];if("rotate"===t){let t=new $(s.length);t.boneIndex=o;let e=0;for(let i=0;i<s.length;i++){let n=s[i];t.setFrame(e,n.time,n.angle),this.readCurve(n,t,e),e++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*$.ENTRIES])}else{if("translate"!==t&&"scale"!==t&&"shear"!==t)throw new Error("Invalid timeline type for a bone: "+t+" ("+e+")");{let e=null,a=1;"scale"===t?e=new Z(s.length):"shear"===t?e=new J(s.length):(e=new H(s.length),a=i),e.boneIndex=o;let l=0;for(let t=0;t<s.length;t++){let i=s[t],n=this.getValue(i,"x",0),r=this.getValue(i,"y",0);e.setFrame(l,i.time,n*a,r*a),this.readCurve(i,e,l),l++}n.push(e),r=Math.max(r,e.frames[(e.getFrameCount()-1)*H.ENTRIES])}}}}if(t.ik)for(let e in t.ik){let i=t.ik[e],a=s.findIkConstraint(e),o=new lt(i.length);o.ikConstraintIndex=s.ikConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"mix",1),this.getValue(e,"bendPositive",!0)?1:-1),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*lt.ENTRIES])}if(t.transform)for(let e in t.transform){let i=t.transform[e],a=s.findTransformConstraint(e),o=new dt(i.length);o.transformConstraintIndex=s.transformConstraints.indexOf(a);let l=0;for(let t=0;t<i.length;t++){let e=i[t];o.setFrame(l,e.time,this.getValue(e,"rotateMix",1),this.getValue(e,"translateMix",1),this.getValue(e,"scaleMix",1),this.getValue(e,"shearMix",1)),this.readCurve(e,o,l),l++}n.push(o),r=Math.max(r,o.frames[(o.getFrameCount()-1)*dt.ENTRIES])}if(t.paths)for(let e in t.paths){let a=t.paths[e],o=s.findPathConstraintIndex(e);if(-1==o)throw new Error("Path constraint not found: "+e);let l=s.pathConstraints[o];for(let t in a){let e=a[t];if("position"===t||"spacing"===t){let s=null,a=1;"spacing"===t?(s=new pt(e.length),l.spacingMode!=se.Length&&l.spacingMode!=se.Fixed||(a=i)):(s=new ct(e.length),l.positionMode==ee.Fixed&&(a=i)),s.pathConstraintIndex=o;let h=0;for(let i=0;i<e.length;i++){let n=e[i];s.setFrame(h,n.time,this.getValue(n,t,0)*a),this.readCurve(n,s,h),h++}n.push(s),r=Math.max(r,s.frames[(s.getFrameCount()-1)*ct.ENTRIES])}else if("mix"===t){let t=new gt(e.length);t.pathConstraintIndex=o;let s=0;for(let i=0;i<e.length;i++){let n=e[i];t.setFrame(s,n.time,this.getValue(n,"rotateMix",1),this.getValue(n,"translateMix",1)),this.readCurve(n,t,s),s++}n.push(t),r=Math.max(r,t.frames[(t.getFrameCount()-1)*gt.ENTRIES])}}}if(t.deform)for(let e in t.deform){let a=t.deform[e],o=s.findSkin(e);if(null==o)throw new Error("Skin not found: "+e);for(let t in a){let e=a[t],l=s.findSlotIndex(t);if(-1==l)throw new Error("Slot not found: "+e.name);for(let t in e){let s=e[t],a=o.getAttachment(l,t);if(null==a)throw new Error("Deform attachment not found: "+s.name);let h=null!=a.bones,d=a.vertices,u=h?d.length/3*2:d.length,c=new nt(s.length);c.slotIndex=l,c.attachment=a;let p=0;for(let t=0;t<s.length;t++){let e,n=s[t],r=this.getValue(n,"vertices",null);if(null==r)e=h?N.newFloatArray(u):d;else{e=N.newFloatArray(u);let t=this.getValue(n,"offset",0);if(N.arrayCopy(r,0,e,t,r.length),1!=i)for(let s=t,n=s+r.length;s<n;s++)e[s]*=i;if(!h)for(let t=0;t<u;t++)e[t]+=d[t]}c.setFrame(p,n.time,e),this.readCurve(n,c,p),p++}n.push(c),r=Math.max(r,c.frames[c.getFrameCount()-1])}}}let a=t.drawOrder;if(null==a&&(a=t.draworder),null!=a){let t=new at(a.length),e=s.slots.length,i=0;for(let n=0;n<a.length;n++){let r=a[n],o=null,l=this.getValue(r,"offsets",null);if(null!=l){o=N.newArray(e,-1);let t=N.newArray(e-l.length,0),i=0,n=0;for(let e=0;e<l.length;e++){let r=l[e],a=s.findSlotIndex(r.slot);if(-1==a)throw new Error("Slot not found: "+r.slot);for(;i!=a;)t[n++]=i++;o[i+r.offset]=i++}for(;i<e;)t[n++]=i++;for(let s=e-1;s>=0;s--)-1==o[s]&&(o[s]=t[--n])}t.setFrame(i++,r.time,o)}n.push(t),r=Math.max(r,t.frames[t.getFrameCount()-1])}if(t.events){let e=new rt(t.events.length),i=0;for(let n=0;n<t.events.length;n++){let r=t.events[n],a=s.findEvent(r.name);if(null==a)throw new Error("Event not found: "+r.name);let o=new $t(N.toSinglePrecision(r.time),a);o.intValue=this.getValue(r,"int",a.intValue),o.floatValue=this.getValue(r,"float",a.floatValue),o.stringValue=this.getValue(r,"string",a.stringValue),e.setFrame(i++,o)}n.push(e),r=Math.max(r,e.frames[e.getFrameCount()-1])}if(isNaN(r))throw new Error("Error while parsing animation, duration is NaN");s.animations.push(new O(e,n,r))}readCurve(t,e,s){if(t.curve)if("stepped"===t.curve)e.setStepped(s);else if("[object Array]"===Object.prototype.toString.call(t.curve)){let i=t.curve;e.setCurve(s,i[0],i[1],i[2],i[3])}}getValue(t,e,s){return void 0!==t[e]?t[e]:s}static blendModeFromString(t){if("normal"==(t=t.toLowerCase()))return ge.Normal;if("additive"==t)return ge.Additive;if("multiply"==t)return ge.Multiply;if("screen"==t)return ge.Screen;throw new Error(`Unknown blend mode: ${t}`)}static positionModeFromString(t){if("fixed"==(t=t.toLowerCase()))return ee.Fixed;if("percent"==t)return ee.Percent;throw new Error(`Unknown position mode: ${t}`)}static spacingModeFromString(t){if("length"==(t=t.toLowerCase()))return se.Length;if("fixed"==t)return se.Fixed;if("percent"==t)return se.Percent;throw new Error(`Unknown position mode: ${t}`)}static rotateModeFromString(t){if("tangent"==(t=t.toLowerCase()))return ie.Tangent;if("chain"==t)return ie.Chain;if("chainscale"==t)return ie.ChainScale;throw new Error(`Unknown rotate mode: ${t}`)}static transformModeFromString(t){if("normal"==(t=t.toLowerCase()))return Dt.Normal;if("onlytranslation"==t)return Dt.OnlyTranslation;if("norotationorreflection"==t)return Dt.NoRotationOrReflection;if("noscale"==t)return Dt.NoScale;if("noscaleorreflection"==t)return Dt.NoScaleOrReflection;throw new Error(`Unknown transform mode: ${t}`)}}class Ee{constructor(t,e,s,i){E(this,"parent"),E(this,"skin"),E(this,"slotIndex"),E(this,"mesh"),this.mesh=t,this.skin=e,this.slotIndex=s,this.parent=i}}Math.fround||(Math.fround=(me=new Float32Array(1),function(t){return me[0]=t,me[0]}));class ye{constructor(t){E(this,"clientId"),E(this,"toLoad",new Array),E(this,"assets",{}),E(this,"textureLoader"),this.clientId=t}loaded(){var t=0;for(var e in this.assets)t++;return t}}const Te=class t{constructor(t){E(this,"centerX",0),E(this,"centerY",0),E(this,"radius",0),E(this,"angle",0),E(this,"worldX",0),E(this,"worldY",0),this.radius=t}begin(t){this.worldX=t.x+this.centerX,this.worldY=t.y+this.centerY}transform(e,s,i,n){let r=this.angle*P.degreesToRadians,a=e.x-this.worldX,o=e.y-this.worldY,l=Math.sqrt(a*a+o*o);if(l<this.radius){let s=t.interpolation.apply(0,r,(this.radius-l)/this.radius),i=Math.cos(s),n=Math.sin(s);e.x=i*a-n*o+this.worldX,e.y=n*a+i*o+this.worldY}}end(){}};E(Te,"interpolation",new V(2));let Ae=Te;const Ce=class t extends _t{constructor(t){super(t.resource),E(this,"texture"),this.texture=i.Texture.from(t)}static from(e){return t.textureMap.has(e)?t.textureMap.get(e):new t(e)}setFilters(e,s){const i=this.texture.source.style;i.minFilter=t.toPixiTextureFilter(e),i.magFilter=t.toPixiTextureFilter(s),this.texture.source.autoGenerateMipmaps=t.toPixiMipMap(e),this.texture.source.updateMipmaps()}setWraps(e,s){const i=this.texture.source.style;i.addressModeU=t.toPixiTextureWrap(e),i.addressModeV=t.toPixiTextureWrap(s)}dispose(){this.texture.destroy()}static toPixiMipMap(t){switch(t){case Yt.Nearest:case Yt.Linear:return!1;case Yt.MipMapNearestLinear:case Yt.MipMapNearestNearest:case Yt.MipMapLinearLinear:case Yt.MipMapLinearNearest:return!0;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureFilter(t){switch(t){case Yt.Nearest:case Yt.MipMapNearestLinear:case Yt.MipMapNearestNearest:return"nearest";case Yt.Linear:case Yt.MipMapLinearLinear:case Yt.MipMapLinearNearest:return"linear";default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case Ft.ClampToEdge:return"clamp-to-edge";case Ft.MirroredRepeat:return"mirror-repeat";case Ft.Repeat:return"repeat";default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case ge.Normal:return"normal";case ge.Additive:return"add";case ge.Multiply:return"multiply";case ge.Screen:return"screen";default:throw new Error(`Unknown blendMode: ${String(t)}`)}}};E(Ce,"textureMap",new Map);let Me=Ce;const Se={extension:i.ExtensionType.Asset,resolver:{test:t=>i.checkExtension(t,".atlas"),parse:t=>{var e,s,n;const r=t.split(".");return{resolution:parseFloat(null!=(n=null==(s=null==(e=i.Resolver.RETINA_PREFIX)?void 0:e.exec(t))?void 0:s[1])?n:"1"),format:r[r.length-2],src:t}}},loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineTextureAtlasLoader"},test:t=>i.checkExtension(t,".atlas"),load(t){return y(this,null,(function*(){const e=yield i.DOMAdapter.get().fetch(t);return yield e.text()}))},testParse(t,e){const s=i.checkExtension(e.src,".atlas"),n="string"==typeof t;return Promise.resolve(s&&n)},unload(t){t.dispose()},parse(t,e,s){return y(this,null,(function*(){var n;const r=e.data||{};let a=i.path.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");const o=new Wt(t,(t=>Me.from(e.data.imageTexture.source)));if(r.images instanceof i.TextureSource||"string"==typeof r.images){const t=r.images;r.images={},r.images[o.pages[0].name]=t}const l=[];for(const t of o.pages){if(r.resolve){const e=null==(n=r.resolve())?void 0:n.then((e=>{e&&t.setTexture(Me.from(e.source))}));l.push(e);continue}const o=t.name,u=(null==r?void 0:r.images)?r.images[o]:void 0;if(u instanceof i.TextureSource)t.setTexture(Me.from(u));else{const n=null!=u?u:i.path.normalize([...a.split(i.path.sep),o].join(i.path.sep)),c={src:i.copySearchParams(n,e.src),data:(h=b({},r.imageMetadata),d={alphaMode:t.pma?"premultiplied-alpha":"premultiply-alpha-on-upload"},p(h,m(d)))},g=s.load(c).then((e=>{t.setTexture(Me.from(e.source))}));l.push(g)}}var h,d;return yield Promise.all(l),o}))}}};i.extensions.add(Se);const ve={extension:i.ExtensionType.Asset,loader:{extension:{type:i.ExtensionType.LoadParser,priority:i.LoaderParserPriority.Normal,name:"spineSkeletonLoader"},test:t=>i.checkExtension(t,".skel"),load(t){return y(this,null,(function*(){const e=yield i.DOMAdapter.get().fetch(t);return new Uint8Array(yield e.arrayBuffer())}))},testParse(t,e){const s=i.checkExtension(e.src,".json")&&(n=t,Object.prototype.hasOwnProperty.call(n,"bones"));var n;const r=i.checkExtension(e.src,".skel")&&function(t){return t instanceof Uint8Array}(t);return Promise.resolve(s||r)}}};i.extensions.add(ve);const Re=new Float32Array(1),Pe=new Uint32Array(1);class Ie extends i.Geometry{constructor(){const t=new i.Buffer({data:Re,label:"attribute-batch-buffer",usage:i.BufferUsage.VERTEX|i.BufferUsage.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:28,offset:0},aUV:{buffer:t,format:"float32x2",stride:28,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:28,offset:16},aDarkColor:{buffer:t,format:"unorm8x4",stride:28,offset:20},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:28,offset:24}},indexBuffer:new i.Buffer({data:Pe,label:"index-batch-buffer",usage:i.BufferUsage.INDEX|i.BufferUsage.COPY_DST,shrinkToFit:!1})})}}const ke={name:"color-bit",vertex:{header:"\n @in aDarkColor: vec4<f32>;\n @out vDarkColor: vec4<f32>;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n @in vDarkColor: vec4<f32>;\n ",end:"\n\n let alpha = outColor.a * vColor.a;\n let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n\n finalColor = vec4<f32>(rgb, alpha);\n\n "}},Ve={name:"color-bit",vertex:{header:"\n in vec4 aDarkColor;\n out vec4 vDarkColor;\n ",main:"\n vDarkColor = aDarkColor;\n "},fragment:{header:"\n in vec4 vDarkColor;\n ",end:"\n\n finalColor.a = outColor.a * vColor.a;\n finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;\n "}};class De extends i.Shader{constructor(t){super({glProgram:i.compileHighShaderGlProgram({name:"dark-tint-batch",bits:[i.colorBitGl,Ve,i.generateTextureBatchBitGl(t),i.roundPixelsBitGl]}),gpuProgram:i.compileHighShaderGpuProgram({name:"dark-tint-batch",bits:[i.colorBit,ke,i.generateTextureBatchBit(t),i.roundPixelsBit]}),resources:{batchSamplers:i.getBatchSamplersUniformGroup(t)}})}}let Ne=null;const _e=class t extends i.Batcher{constructor(){super(...arguments),E(this,"geometry",new Ie),E(this,"shader",Ne||(Ne=new De(this.maxTextures))),E(this,"name",t.extension.name),E(this,"vertexSize",7)}packAttributes(t,e,s,n,r){const a=r<<16|65535&t.roundPixels,o=t.transform,l=o.a,h=o.b,d=o.c,u=o.d,c=o.tx,p=o.ty,{positions:m,uvs:g}=t,f=t.color,x=(f>>24&255)/255,w=i.Color.shared.setValue(t.darkColor).premultiply(x,!0).toPremultiplied(1,!1),b=t.attributeOffset,E=b+t.attributeSize;for(let t=b;t<E;t++){const i=2*t,r=m[i],o=m[i+1];e[n++]=l*r+d*o+c,e[n++]=u*o+h*r+p,e[n++]=g[i],e[n++]=g[i+1],s[n++]=f,s[n++]=w,s[n++]=a}}packQuadAttributes(t,e,s,i,n){const r=t.texture,a=t.transform,o=a.a,l=a.b,h=a.c,d=a.d,u=a.tx,c=a.ty,p=t.bounds,m=p.maxX,g=p.minX,f=p.maxY,x=p.minY,w=r.uvs,b=t.color,E=t.darkColor,y=n<<16|65535&t.roundPixels;e[i+0]=o*g+h*x+u,e[i+1]=d*x+l*g+c,e[i+2]=w.x0,e[i+3]=w.y0,s[i+4]=b,s[i+5]=E,s[i+6]=y,e[i+7]=o*m+h*x+u,e[i+8]=d*x+l*m+c,e[i+9]=w.x1,e[i+10]=w.y1,s[i+11]=b,s[i+12]=E,s[i+13]=y,e[i+14]=o*m+h*f+u,e[i+15]=d*f+l*m+c,e[i+16]=w.x2,e[i+17]=w.y2,s[i+18]=b,s[i+19]=E,s[i+20]=y,e[i+21]=o*g+h*f+u,e[i+22]=d*f+l*g+c,e[i+23]=w.x3,e[i+24]=w.y3,s[i+25]=b,s[i+26]=E,s[i+27]=y}};E(_e,"extension",{type:[i.ExtensionType.Batcher],name:"darkTint"});let Le=_e;i.extensions.add(Le);class Oe{constructor(){E(this,"indexOffset",0),E(this,"attributeOffset",0),E(this,"indexSize"),E(this,"attributeSize"),E(this,"batcherName","darkTint"),E(this,"topology","triangle-list"),E(this,"packAsQuad",!1),E(this,"renderable"),E(this,"positions"),E(this,"indices"),E(this,"uvs"),E(this,"roundPixels"),E(this,"data"),E(this,"blendMode"),E(this,"darkTint"),E(this,"texture"),E(this,"transform"),E(this,"_textureId"),E(this,"_attributeStart"),E(this,"_indexStart"),E(this,"_batcher"),E(this,"_batch")}get color(){const t=this.data.color,e=this.renderable.groupColor,s=this.renderable.groupAlpha;let i;const n=t.a*s*255;if(16777215!==e){const s=e>>16&255,r=e>>8&255,a=255&e,o=t.r*a,l=t.g*r;i=n<<24|t.b*s<<16|l<<8|o}else i=n<<24|255*t.b<<16|255*t.g<<8|255*t.r;return i}get darkColor(){const t=this.data.darkColor;return 255*t.b<<16|255*t.g<<8|255*t.r}get groupTransform(){return this.renderable.groupTransform}setData(t,e,s,i){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const t=e.clippedData;this.indexSize=t.indicesCount,this.attributeSize=t.vertexCount,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=i,this.blendMode=s,this.batcherName=e.darkTint?"darkTint":"default"}}const Ye={0:"normal",1:"add",2:"multiply",3:"screen"};class Fe{constructor(t){E(this,"renderer"),E(this,"gpuSpineData",{}),E(this,"_destroyRenderableBound",this.destroyRenderable.bind(this)),this.renderer=t}validateRenderable(t){if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,s=this.gpuSpineData[t.uid];for(let i=0,n=e.length;i<n;i++){const n=e[i],r=n.getAttachment();if(r instanceof Pt||r instanceof Mt){const e=t._getCachedData(n,r),i=s.slotBatches[e.id],a=e.texture;if(a!==i.texture&&!i._batcher.checkAndUpdateTexture(i,a))return!0}}}return!1}addRenderable(t,e){var s,n;const r=this._getSpineData(t),a=this.renderer.renderPipes.batch,o=t.skeleton.drawOrder,l=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments();for(let h=0,d=o.length;h<d;h++){const d=o[h],u=d.getAttachment(),c=Ye[d.data.blendMode];if(u instanceof Pt||u instanceof Mt){const i=t._getCachedData(d,u),o=(s=r.slotBatches)[n=i.id]||(s[n]=new Oe);o.setData(t,i,c,l),i.skipRender||a.addToBatch(o,e)}const p=t._slotsObject[d.data.name];if(p){const t=p.container;t.includeInBuild=!0,i.collectAllRenderables(t,e,this.renderer),t.includeInBuild=!1}}}updateRenderable(t){var e;const s=this.gpuSpineData[t.uid];t._validateAndTransformAttachments();const i=t.skeleton.drawOrder;for(let n=0,r=i.length;n<r;n++){const r=i[n],a=r.getAttachment();if(a instanceof Pt||a instanceof Mt){if(!t._getCachedData(r,a).skipRender){const i=s.slotBatches[t._getCachedData(r,a).id];null==(e=i._batcher)||e.updateElement(i)}}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}}E(Fe,"extension",{type:[i.ExtensionType.WebGLPipes,i.ExtensionType.WebGPUPipes,i.ExtensionType.CanvasPipes],name:"spine"}),i.extensions.add(Fe);const Xe=new L,Be=new ue,We=new _((()=>new i.Graphics));class Ue extends i.ViewContainer{constructor(t){var e;t instanceof ce&&(t={skeletonData:t}),super(),E(this,"batched",!0),E(this,"buildId",0),E(this,"renderPipeId","spine"),E(this,"_didSpineUpdate",!1),E(this,"beforeUpdateWorldTransforms",(()=>{})),E(this,"afterUpdateWorldTransforms",(()=>{})),E(this,"skeleton"),E(this,"state"),E(this,"skeletonBounds"),E(this,"darkTint",!1),E(this,"_debug"),E(this,"_slotsObject",Object.create(null)),E(this,"clippingSlotToPixiMasks",Object.create(null)),E(this,"spineAttachmentsDirty",!0),E(this,"spineTexturesDirty",!0),E(this,"_lastAttachments",[]),E(this,"_stateChanged",!0),E(this,"attachmentCacheData",[]),E(this,"_autoUpdate",!1),E(this,"hasNeverUpdated",!0),E(this,"currentClippingSlot");const s=t instanceof ce?t:t.skeletonData;this.skeleton=new le(s),this.skeleton.flipY=!0,this.state=new xt(new Tt(s)),this.autoUpdate=null==(e=null==t?void 0:t.autoUpdate)||e,this.darkTint=void 0===(null==t?void 0:t.darkTint)?this.skeleton.slots.some((t=>!!t.data.darkColor)):null==t?void 0:t.darkTint;const i=this.skeleton.slots;for(let t=0;t<i.length;t++)this.attachmentCacheData[t]=Object.create(null)}getSlotFromRef(t){let e;if(e="number"==typeof t?this.skeleton.slots[t]:"string"==typeof t?this.skeleton.findSlot(t):t,!e)throw new Error(`No slot found with the given slot reference: ${t}`);return e}get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t&&!this._autoUpdate?i.Ticker.shared.add(this.internalUpdate,this):i.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=t}update(t){this.internalUpdate(0,t)}internalUpdate(t,e){this._updateAndApplyState(null!=e?e:i.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,e){const s=t;if("string"==typeof t&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(s)} not found`);if(Xe.set(e.x,e.y),t.parent){const e=t.parent.worldToLocal(Xe);t.x=e.x,t.y=-e.y}else t.x=Xe.x,t.y=Xe.y}getBonePosition(t,e){const s=t;return"string"==typeof t&&(t=this.skeleton.findBone(t)),t?(e||(e={x:0,y:0}),e.x=t.worldX,e.y=t.worldY,e):(console.error(`Cant set bone position! Bone ${String(s)} not found`),e)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:e}=this;this.state.apply(e),this.beforeUpdateWorldTransforms(this),e.updateWorldTransform(),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this._boundsDirty=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder,e=this._lastAttachments;let s=0,i=!1;for(let n=0;n<t.length;n++){const r=t[n].getAttachment();r&&(r!==e[s]&&(i=!0,e[s]=r),s++)}s!==e.length&&(i=!0,e.length=s),this.spineAttachmentsDirty=i}updateAndSetPixiMask(t,e){var s,i;const n=t.attachment;if(n&&n instanceof Ct){return((s=this.clippingSlotToPixiMasks)[i=t.data.name]||(s[i]={slot:t,vertices:new Array})).maskComputed=!1,void(this.currentClippingSlot=this.clippingSlotToPixiMasks[t.data.name])}let r=this.currentClippingSlot,a=this._slotsObject[t.data.name];if(r&&a){let t=r.slot,e=t.attachment,s=r.mask;if(s||(s=We.obtain(),r.mask=s,this.addChild(s)),!r.maskComputed){r.maskComputed=!0;const i=e.worldVerticesLength,n=r.vertices;e.computeWorldVertices(t,0,i,n,0,2),s.clear().poly(n).stroke({width:0}).fill({alpha:.25})}a.container.mask=s}else(null==a?void 0:a.container.mask)&&(a.container.mask=null);if(r&&r.slot.attachment.endSlot==t.data&&(this.currentClippingSlot=void 0),e)for(const t in this.clippingSlotToPixiMasks){const e=this.clippingSlotToPixiMasks[t];e.slot.attachment instanceof Ct&&e.maskComputed||!e.mask||(this.removeChild(e.mask),We.free(e.mask),e.mask=void 0)}}transformAttachments(){var t;const e=this.skeleton.drawOrder;for(let s=0;s<e.length;s++){const n=e[s];this.updateAndSetPixiMask(n,s===e.length-1);const r=n.getAttachment();if(r)if(r instanceof Mt||r instanceof Pt){const e=this._getCachedData(n,r);r instanceof Pt?r.computeWorldVertices(n.bone,e.vertices,0,2):r.computeWorldVertices(n,0,r.worldVerticesLength,e.vertices,0,2),e.uvs.length<r.uvs.length&&(e.uvs=new Float32Array(r.uvs.length)),i.fastCopy(r.uvs.buffer,e.uvs.buffer);const s=n.bone.skeleton.color,a=n.color,o=r.color;e.color.set(s.r*a.r*o.r,s.g*a.g*o.g,s.b*a.b*o.b,s.a*a.a*o.a),n.darkColor&&e.darkColor.setFromColor(n.darkColor),e.skipRender=e.clipped=!1;const l=(null==(t=r.region)?void 0:t.texture.texture)||i.Texture.EMPTY;e.texture!==l&&(e.texture=l,this.spineTexturesDirty=!0),Be.isClipping()&&this.updateClippingData(e)}else if(r instanceof Ct){Be.clipStart(n,r);continue}Be.clipEndWithSlot(n)}Be.clipEnd()}updateClippingData(t){t.clipped=!0,Be.clipTrianglesUnpacked(t.vertices,t.indices,t.indices.length,t.uvs);const{clippedVertices:e,clippedUVs:s,clippedTriangles:i}=Be,n=e.length/2,r=i.length;t.clippedData||(t.clippedData={vertices:new Float32Array(2*n),uvs:new Float32Array(2*n),vertexCount:n,indices:new Uint16Array(r),indicesCount:r},this.spineAttachmentsDirty=!0);const a=t.clippedData,o=a.vertexCount!==n||r!==a.indicesCount;t.skipRender=0===n,o&&(this.spineAttachmentsDirty=!0,a.vertexCount<n&&(a.vertices=new Float32Array(2*n),a.uvs=new Float32Array(2*n)),a.indices.length<r&&(a.indices=new Uint16Array(r)));const{vertices:l,uvs:h,indices:d}=a;for(let t=0;t<n;t++)l[2*t]=e[2*t],l[2*t+1]=e[2*t+1],h[2*t]=s[2*t],h[2*t+1]=s[2*t+1];a.vertexCount=n;for(let t=0;t<r;t++)d[t]!==i[t]&&(this.spineAttachmentsDirty=!0,d[t]=i[t]);a.indicesCount=r}updateSlotObjects(){for(const t in this._slotsObject){const e=this._slotsObject[t];e&&this.updateSlotObject(e)}}updateSlotObject(t){const{slot:e,container:s}=t;if(s.visible=this.skeleton.drawOrder.includes(e),s.visible){const t=e.bone;s.position.set(t.worldX,t.worldY),s.scale.x=t.getWorldScaleX(),s.scale.y=t.getWorldScaleY(),s.rotation=t.getWorldRotationX()*i.DEG_TO_RAD,s.alpha=this.skeleton.color.a*e.color.a}}_getCachedData(t,e){return this.attachmentCacheData[t.data.index][e.name]||this.initCachedData(t,e)}initCachedData(t,e){var s,i;let n;return e instanceof Pt?(n=new Float32Array(8),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(e.uvs.length),color:new v(1,1,1,1),darkColor:new v(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(s=e.region)?void 0:s.texture.texture}):(n=new Float32Array(e.worldVerticesLength),this.attachmentCacheData[t.data.index][e.name]={id:`${t.data.index}-${e.name}`,vertices:n,clipped:!1,indices:e.triangles,uvs:new Float32Array(e.uvs.length),color:new v(1,1,1,1),darkColor:new v(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:null==(i=e.region)?void 0:i.texture.texture}),this.attachmentCacheData[t.data.index][e.name]}onViewUpdate(){var t;if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this),null==(t=this.debug)||t.renderDebug(this)}addSlotObject(t,e){var s;t=this.getSlotFromRef(t);for(const t in this._slotsObject)(null==(s=this._slotsObject[t])?void 0:s.container)===e&&this.removeSlotObject(this._slotsObject[t].slot);this.removeSlotObject(t),e.includeInBuild=!1,this.addChild(e);const i={container:e,slot:t};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){var e,s;let n;if(t instanceof i.Container){for(const s in this._slotsObject)if((null==(e=this._slotsObject[s])?void 0:e.container)===t){this._slotsObject[s]=null,n=t;break}}else{const e=this.getSlotFromRef(t);n=null==(s=this._slotsObject[e.data.name])?void 0:s.container,this._slotsObject[e.data.name]=null}n&&(this.removeChild(n),n.includeInBuild=!0)}getSlotObject(t){var e;return t=this.getSlotFromRef(t),null==(e=this._slotsObject[t.data.name])?void 0:e.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||(this.skeletonBounds=new he);const t=this.skeletonBounds;if(t.update(this.skeleton,!0),t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const t=this.skeleton.drawOrder,e=this._bounds;e.clear();for(let s=0;s<t.length;s++){const i=t[s],n=i.getAttachment();if(n&&(n instanceof Pt||n instanceof Mt)){const t=this._getCachedData(i,n);e.addVertexData(t.vertices,0,t.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),i.Ticker.shared.remove(this.internalUpdate,this),this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this._lastAttachments.length=0,this.attachmentCacheData=null}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,e){this.pixiWorldCoordinatesToSkeleton(t),e.parent?e.parent.worldToLocal(t):e.worldToLocal(t)}static from({skeleton:t,atlas:e,scale:s=1,darkTint:n,autoUpdate:r=!0}){const a=`${t}-${e}-${s}`;if(i.Cache.has(a))return new Ue(i.Cache.get(a));const o=i.Assets.get(t),l=i.Assets.get(e),h=new It(l),d=new be(h).readSkeletonData(o);return i.Cache.set(a,d),new Ue({skeletonData:d,darkTint:n,autoUpdate:r})}}var je=Object.freeze({__proto__:null,Animation:O,AnimationState:xt,AnimationStateAdapter2:class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},AnimationStateData:Tt,AssetManager:Gt,AtlasAttachmentLoader:It,Attachment:T,AttachmentTimeline:st,BlendMode:ge,Bone:Nt,BoneData:kt,BoundingBoxAttachment:At,ClippingAttachment:Ct,Color:v,ColorTimeline:K,CurveTimeline:q,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)}}},DeformTimeline:nt,DrawOrderTimeline:at,Event:$t,EventData:zt,EventQueue:bt,EventTimeline:rt,EventType:yt,FakeTexture:Bt,IkConstraint:Ht,IkConstraintData:Zt,IkConstraintTimeline:lt,IntSet:M,Interpolation:I,JitterEffect:class{constructor(t,e){E(this,"jitterX",0),E(this,"jitterY",0),this.jitterX=t,this.jitterY=e}begin(t){}transform(t,e,s,i){t.x+=P.randomTriangular(-this.jitterX,this.jitterY),t.y+=P.randomTriangular(-this.jitterX,this.jitterY)}end(){}},MathUtils:P,MeshAttachment:Mt,MixDirection:W,MixPose:B,PathAttachment:St,PathConstraint:re,PathConstraintData:Jt,PathConstraintMixTimeline:gt,PathConstraintPositionTimeline:ct,PathConstraintSpacingTimeline:pt,PointAttachment:vt,Pool:_,PositionMode:ee,Pow:k,PowOut:V,RegionAttachment:Pt,RotateMode:ie,RotateTimeline:$,ScaleTimeline:Z,SharedAssetManager:class{constructor(t=""){E(this,"pathPrefix"),E(this,"clientAssets",{}),E(this,"queuedAssets",{}),E(this,"rawAssets",{}),E(this,"errors",{}),this.pathPrefix=t}queueAsset(t,e,s){var i=this.clientAssets[t];return null==i&&(i=new ye(t),this.clientAssets[t]=i),null!==e&&(i.textureLoader=e),i.toLoad.push(s),this.queuedAssets[s]!==s&&(this.queuedAssets[s]=s,!0)}loadText(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=s.responseText:this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadJson(t,e){if(e=this.pathPrefix+e,!this.queueAsset(t,null,e))return;let s=new XMLHttpRequest;s.onreadystatechange=()=>{s.readyState==XMLHttpRequest.DONE&&(s.status>=200&&s.status<300?this.rawAssets[e]=JSON.parse(s.responseText):this.errors[e]=`Couldn't load text ${e}: status ${s.status}, ${s.responseText}`)},s.open("GET",e,!0),s.send()}loadTexture(t,e,s){if(s=this.pathPrefix+s,!this.queueAsset(t,e,s))return;let i=new Image;i.src=s,i.crossOrigin="anonymous",i.onload=t=>{this.rawAssets[s]=i},i.onerror=t=>{this.errors[s]=`Couldn't load image ${s}`}}get(t,e){e=this.pathPrefix+e;var s=this.clientAssets[t];return null==s||s.assets[e]}updateClientAssets(t){for(var e=0;e<t.toLoad.length;e++){var s=t.toLoad[e],i=t.assets[s];if(null==i){var n=this.rawAssets[s];if(null==n)continue;n instanceof HTMLImageElement?t.assets[s]=t.textureLoader(n):t.assets[s]=n}}}isLoadingComplete(t){var e=this.clientAssets[t];return null==e||(this.updateClientAssets(e),e.toLoad.length==e.loaded())}dispose(){}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},ShearTimeline:J,Skeleton:le,SkeletonBounds:he,SkeletonClipping:ue,SkeletonData:ce,SkeletonJson:be,Skin:fe,Slot:ae,SlotData:xe,SpacingMode:se,Spine:Ue,SpineDebugRenderer:class{constructor(){E(this,"registeredSpines",new Map),E(this,"drawMeshHull",!0),E(this,"drawMeshTriangles",!0),E(this,"drawBones",!0),E(this,"drawPaths",!0),E(this,"drawBoundingBoxes",!0),E(this,"drawClipping",!0),E(this,"drawRegionAttachments",!0),E(this,"drawEvents",!0),E(this,"lineWidth",1),E(this,"regionAttachmentsColor",30975),E(this,"meshHullColor",30975),E(this,"meshTrianglesColor",16763904),E(this,"clippingPolygonColor",16711935),E(this,"boundingBoxesRectColor",65280),E(this,"boundingBoxesPolygonColor",65280),E(this,"boundingBoxesCircleColor",65280),E(this,"pathsCurveColor",16711680),E(this,"pathsLineColor",16711935),E(this,"skeletonXYColor",16711680),E(this,"bonesColor",61132),E(this,"eventFontSize",24),E(this,"eventFontColor",0)}registerSpine(t){if(this.registeredSpines.has(t))return void console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",t);const e={parentDebugContainer:new i.Container,bones:new i.Container,skeletonXY:new i.Graphics,regionAttachmentsShape:new i.Graphics,meshTrianglesLine:new i.Graphics,meshHullLine:new i.Graphics,clippingPolygon:new i.Graphics,boundingBoxesRect:new i.Graphics,boundingBoxesCircle:new i.Graphics,boundingBoxesPolygon:new i.Graphics,pathsCurve:new i.Graphics,pathsLine:new i.Graphics,eventText:new i.Container,eventCallback:{event:(s,n)=>{if(this.drawEvents){const s=Math.abs(t.scale.x||t.scale.y||1),r=new i.Text({text:n.data.name,style:{fontSize:this.eventFontSize/s,fill:this.eventFontColor,fontFamily:"monospace"}});r.scale.x=Math.sign(t.scale.x),r.anchor.set(.5),e.eventText.addChild(r),setTimeout((()=>{r.destroyed||r.destroy()}),250)}}}};e.parentDebugContainer.addChild(e.bones),e.parentDebugContainer.addChild(e.skeletonXY),e.parentDebugContainer.addChild(e.regionAttachmentsShape),e.parentDebugContainer.addChild(e.meshTrianglesLine),e.parentDebugContainer.addChild(e.meshHullLine),e.parentDebugContainer.addChild(e.clippingPolygon),e.parentDebugContainer.addChild(e.boundingBoxesRect),e.parentDebugContainer.addChild(e.boundingBoxesCircle),e.parentDebugContainer.addChild(e.boundingBoxesPolygon),e.parentDebugContainer.addChild(e.pathsCurve),e.parentDebugContainer.addChild(e.pathsLine),e.parentDebugContainer.addChild(e.eventText),e.parentDebugContainer.zIndex=9999999,e.parentDebugContainer.accessibleChildren=!1,e.parentDebugContainer.eventMode="none",e.parentDebugContainer.interactiveChildren=!1,t.addChild(e.parentDebugContainer),t.state.addListener(e.eventCallback),this.registeredSpines.set(t,e)}renderDebug(t){this.registeredSpines.has(t)||this.registerSpine(t);const e=this.registeredSpines.get(t);if(!e)return;t.addChild(e.parentDebugContainer),e.skeletonXY.clear(),e.regionAttachmentsShape.clear(),e.meshTrianglesLine.clear(),e.meshHullLine.clear(),e.clippingPolygon.clear(),e.boundingBoxesRect.clear(),e.boundingBoxesCircle.clear(),e.boundingBoxesPolygon.clear(),e.pathsCurve.clear(),e.pathsLine.clear();for(let t=e.bones.children.length;t>0;t--)e.bones.children[t-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(t.scale.x||t.scale.y||1),i=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(t,e,i,s),this.drawPaths&&this.drawPathsFunc(t,e,i),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(t,e,i),this.drawClipping&&this.drawClippingFunc(t,e,i),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(t,e,i),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(t,e,i),this.drawEvents)for(const t of e.eventText.children)t.alpha-=.05,t.y-=2}drawBonesFunc(t,e,s,n){const r=t.skeleton,a=r.x,o=r.y,l=r.bones;e.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let t=0,r=l.length;t<r;t++){const r=l[t],h=r.data.length,d=a+r.worldX,u=o+r.worldY,c=a+h*r.a+r.worldX,p=o+h*r.b+r.worldY;if("root"===r.data.name||null===r.data.parent)continue;const m=Math.abs(d-c),g=Math.abs(u-p),f=Math.pow(m,2),x=g,w=Math.pow(g,2),b=Math.sqrt(f+w),E=Math.pow(b,2),y=Math.PI/180,T=Math.acos((E+w-f)/(2*x*b))||0;if(0===b)continue;const A=new i.Graphics;e.bones.addChild(A);const C=b/50/n;A.context.poly([0,0,0-C,b-3*C,0,b-C,0+C,b-3*C]).fill(this.bonesColor),A.x=d,A.y=u,A.pivot.y=b;let M=0;d<c&&u<p?M=180*y-T:d>c&&u<p?M=180*y+T:d>c&&u>p?M=-T:d<c&&u>p?M=T:u===p&&d<c?M=90*y:u===p&&d>c?M=-90*y:d===c&&u<p?M=180*y:d===c&&u>p&&(M=0),A.rotation=M,A.circle(0,b,1.2*C).fill({color:0,alpha:.6}).stroke({width:s+C/2.4,color:this.bonesColor})}const h=3*s;e.skeletonXY.context.moveTo(a-h,o-h).lineTo(a+h,o+h).moveTo(a+h,o-h).lineTo(a-h,o+h).stroke()}drawRegionAttachmentsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t],n=s.getAttachment();if(null===n||!(n instanceof Pt))continue;const r=n,a=new Float32Array(8);r.computeWorldVertices(s.bone,a,0,2),e.regionAttachmentsShape.poly(Array.from(a.slice(0,8)))}e.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Mt))continue;const r=n,a=new Float32Array(r.worldVerticesLength),o=r.triangles;let l=r.hullLength;if(r.computeWorldVertices(s,0,r.worldVerticesLength,a,0,2),this.drawMeshTriangles)for(let t=0,s=o.length;t<s;t+=3){const s=2*o[t],i=2*o[t+1],n=2*o[t+2];e.meshTrianglesLine.context.moveTo(a[s],a[s+1]).lineTo(a[i],a[i+1]).lineTo(a[n],a[n+1])}if(this.drawMeshHull&&l>0){l=2*(l>>1);let t=a[l-2],s=a[l-1];for(let i=0,n=l;i<n;i+=2){const n=a[i],r=a[i+1];e.meshHullLine.context.moveTo(n,r).lineTo(t,s),t=n,s=r}}}e.meshHullLine.stroke({width:s,color:this.meshHullColor}),e.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof Ct))continue;const r=n,a=r.worldVerticesLength,o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2),e.clippingPolygon.poly(Array.from(o))}e.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(t,e,s){const i=new he;i.update(t.skeleton,!0),i.minX!==1/0&&e.boundingBoxesRect.rect(i.minX,i.minY,i.getWidth(),i.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const n=i.polygons,r=(t,i,n)=>{if(n<3)throw new Error("Polygon must contain at least 3 vertices");const r=[],a=2*s;for(let s=0,i=t.length;s<i;s+=2){const i=t[s],n=t[s+1];e.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),e.boundingBoxesCircle.drawCircle(i,n,a),e.boundingBoxesCircle.fill(0),e.boundingBoxesCircle.circle(i,n,a).fill({color:this.boundingBoxesCircleColor}),r.push(i,n)}e.boundingBoxesPolygon.poly(r).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let t=0,e=n.length;t<e;t++){const e=n[t];r(e,0,e.length)}}drawPathsFunc(t,e,s){const i=t.skeleton.slots;for(let t=0,s=i.length;t<s;t++){const s=i[t];if(!s.bone.isActive)continue;const n=s.getAttachment();if(null===n||!(n instanceof St))continue;const r=n;let a=r.worldVerticesLength;const o=new Float32Array(a);r.computeWorldVertices(s,0,a,o,0,2);let l=o[2],h=o[3],d=0,u=0;if(r.closed){const t=o[0],s=o[1],i=o[a-2],n=o[a-1];d=o[a-4],u=o[a-3],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(t,s,i,n,d,u),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(t,s),e.pathsLine.moveTo(d,u),e.pathsLine.lineTo(i,n)}a-=4;for(let t=4;t<a;t+=6){const s=o[t],i=o[t+1],n=o[t+2],r=o[t+3];d=o[t+4],u=o[t+5],e.pathsCurve.moveTo(l,h),e.pathsCurve.bezierCurveTo(s,i,n,r,d,u),e.pathsLine.moveTo(l,h),e.pathsLine.lineTo(s,i),e.pathsLine.moveTo(d,u),e.pathsLine.lineTo(n,r),l=d,h=u}}e.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),e.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(t){this.registeredSpines.has(t)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",t);const e=this.registeredSpines.get(t);e&&(t.state.removeListener(e.eventCallback),e.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(t))}},SpinePipe:Fe,SpineTexture:Me,SwirlEffect:Ae,Texture:_t,TextureAtlas:Wt,TextureAtlasPage:jt,TextureAtlasRegion:qt,TextureFilter:Yt,TextureRegion:Xt,TextureWrap:Ft,TimeKeeper:class{constructor(){E(this,"maxDelta",.064),E(this,"framesPerSecond",0),E(this,"delta",0),E(this,"totalTime",0),E(this,"lastTime",Date.now()/1e3),E(this,"frameCount",0),E(this,"frameTime",0)}update(){var 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)}},TimelineType:U,TrackEntry:wt,TransformConstraint:oe,TransformConstraintData:we,TransformConstraintTimeline:dt,TransformMode:Dt,TranslateTimeline:H,Triangulator:de,TwoColorTimeline:et,Utils:N,Vector2:L,VertexAttachment:C,WindowedMean:class{constructor(t=32){E(this,"values"),E(this,"addedValues",0),E(this,"lastValue",0),E(this,"mean",0),E(this,"dirty",!0),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}}});return t.Spine=class extends o{},t.SpineSystem=class extends u{init(){super.init({pixiSpine:je})}},t.pixiSpine=je,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,PIXI);globalThis.EVA.plugin.renderer.spine36=globalThis.EVA.plugin.renderer.spine36||_EVA_IIFE_spine36;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-spine36",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.2",
|
|
4
4
|
"description": "@eva/plugin-renderer-spine36",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-spine36.esm.js",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/eva.js": "2.0.1-beta.
|
|
21
|
+
"@eva/eva.js": "2.0.1-beta.2",
|
|
22
22
|
"@eva/inspector-decorator": "^0.0.5",
|
|
23
|
-
"@eva/plugin-renderer": "2.0.1-beta.
|
|
24
|
-
"@eva/spine-base": "2.0.1-beta.
|
|
23
|
+
"@eva/plugin-renderer": "2.0.1-beta.2",
|
|
24
|
+
"@eva/spine-base": "2.0.1-beta.2",
|
|
25
25
|
"pixi.js": "^8.8.1"
|
|
26
26
|
}
|
|
27
27
|
}
|