"use strict";var spine=(()=>{var Yt=Object.defineProperty,nr=Object.getOwnPropertyDescriptor,ar=Object.getOwnPropertyNames,lr=Object.prototype.hasOwnProperty,or=(t,e)=>{for(var i in e)Yt(t,i,{get:e[i],enumerable:!0})},hr=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ar(e))!lr.call(t,r)&&r!==i&&Yt(t,r,{get:()=>e[r],enumerable:!(s=nr(e,r))||s.enumerable});return t},cr=t=>hr(Yt({},"__esModule",{value:!0}),t),Ji={};or(Ji,{AlphaTimeline:()=>Ht,Animation:()=>ht,AnimationState:()=>rs,AnimationStateAdapter:()=>gr,AnimationStateData:()=>cs,AssetCache:()=>ws,AssetManager:()=>Xi,AssetManagerBase:()=>ps,AtlasAttachmentLoader:()=>gs,Attachment:()=>Lt,AttachmentTimeline:()=>Ne,BinaryInput:()=>Ts,BlendMode:()=>Yi,Bone:()=>xi,BoneData:()=>wi,BoundingBoxAttachment:()=>fi,CURRENT:()=>hs,CameraController:()=>Qr,ClippingAttachment:()=>tt,Color:()=>V,Color2Attribute:()=>Fs,ColorAttribute:()=>xt,ConstraintData:()=>st,CurveTimeline:()=>Se,CurveTimeline1:()=>Ae,CurveTimeline2:()=>ct,DebugUtils:()=>fr,DeformTimeline:()=>Zt,Downloader:()=>bi,DrawOrderTimeline:()=>qe,Event:()=>vi,EventData:()=>yi,EventQueue:()=>as,EventTimeline:()=>dt,EventType:()=>ls,FIRST:()=>ci,FakeTexture:()=>pr,GLTexture:()=>_e,HOLD_FIRST:()=>ft,HOLD_MIX:()=>os,HOLD_SUBSEQUENT:()=>di,IkConstraint:()=>xs,IkConstraintData:()=>Ai,IkConstraintTimeline:()=>Jt,Inherit:()=>gt,InheritTimeline:()=>zt,Input:()=>nt,IntSet:()=>dr,Interpolation:()=>Ki,LoadingScreen:()=>Us,M00:()=>O,M01:()=>q,M02:()=>G,M03:()=>D,M10:()=>H,M11:()=>N,M12:()=>_,M13:()=>U,M20:()=>j,M21:()=>Z,M22:()=>W,M23:()=>z,M30:()=>Q,M31:()=>$,M32:()=>ee,M33:()=>K,ManagedWebGLRenderingContext:()=>ge,MathUtils:()=>P,Matrix4:()=>rt,Mesh:()=>Bi,MeshAttachment:()=>Ge,MixBlend:()=>is,MixDirection:()=>ss,OrthoCamera:()=>Rs,PathAttachment:()=>He,PathConstraint:()=>bs,PathConstraintData:()=>Ci,PathConstraintMixTimeline:()=>ei,PathConstraintPositionTimeline:()=>Qt,PathConstraintSpacingTimeline:()=>$t,Physics:()=>As,PhysicsConstraintDampingTimeline:()=>si,PhysicsConstraintGravityTimeline:()=>ai,PhysicsConstraintInertiaTimeline:()=>ti,PhysicsConstraintMassTimeline:()=>ri,PhysicsConstraintMixTimeline:()=>li,PhysicsConstraintResetTimeline:()=>oi,PhysicsConstraintStrengthTimeline:()=>ii,PhysicsConstraintTimeline:()=>Be,PhysicsConstraintWindTimeline:()=>ni,PointAttachment:()=>ms,PolygonBatcher:()=>Oi,Pool:()=>$e,Position2Attribute:()=>wt,Position3Attribute:()=>$r,PositionMode:()=>Si,Pow:()=>Qi,PowOut:()=>ur,RGB2Timeline:()=>jt,RGBA2Timeline:()=>_t,RGBATimeline:()=>qt,RGBTimeline:()=>Gt,RegionAttachment:()=>it,ResizeMode:()=>Ns,RotateMode:()=>ki,RotateTimeline:()=>et,SETUP:()=>ui,SUBSEQUENT:()=>ut,ScaleTimeline:()=>Vt,ScaleXTimeline:()=>Ot,ScaleYTimeline:()=>Dt,SceneRenderer:()=>Ni,SequenceTimeline:()=>hi,Shader:()=>ke,ShapeRenderer:()=>Di,ShapeType:()=>Vs,ShearTimeline:()=>Nt,ShearXTimeline:()=>Ut,ShearYTimeline:()=>Wt,Skeleton:()=>Ei,SkeletonBinary:()=>Ss,SkeletonBounds:()=>ks,SkeletonClipping:()=>Is,SkeletonData:()=>Ii,SkeletonDebugRenderer:()=>Os,SkeletonJson:()=>Ms,SkeletonRenderer:()=>Ds,Skin:()=>pt,SkinEntry:()=>Mi,Slot:()=>vs,SlotData:()=>Ri,SpacingMode:()=>Ti,SpineCanvas:()=>an,SpinePlayer:()=>ln,SpinePlayerEditor:()=>gn,StringSet:()=>Ft,TexCoordAttribute:()=>Vi,Texture:()=>mi,TextureAtlas:()=>gi,TextureAtlasPage:()=>fs,TextureAtlasRegion:()=>pi,TextureFilter:()=>mt,TextureRegion:()=>us,TextureWrap:()=>ds,TimeKeeper:()=>ot,Timeline:()=>ue,Touch:()=>Ys,TrackEntry:()=>ns,TransformConstraint:()=>ys,TransformConstraintData:()=>Fi,TransformConstraintTimeline:()=>Kt,TranslateTimeline:()=>Pt,TranslateXTimeline:()=>Xt,TranslateYTimeline:()=>Bt,Triangulator:()=>Es,Utils:()=>X,Vector2:()=>Ce,Vector3:()=>ve,VertexAttachment:()=>Ye,VertexAttribute:()=>je,VertexAttributeType:()=>Ls,WindowedMean:()=>mr});var dr=class{array=new Array;add(t){let e=this.contains(t);return this.array[t|0]=t|0,!e}contains(t){return this.array[t|0]!=null}remove(t){this.array[t|0]=void 0}clear(){this.array.length=0}},Ft=class{entries={};size=0;add(t){let e=this.entries[t];return this.entries[t]=!0,e?!1:(this.size++,!0)}addAll(t){let e=this.size;for(var i=0,s=t.length;i1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(e,i){e.r=((i&4278190080)>>>24)/255,e.g=((i&16711680)>>>16)/255,e.b=((i&65280)>>>8)/255,e.a=(i&255)/255}static rgb888ToColor(e,i){e.r=((i&16711680)>>>16)/255,e.g=((i&65280)>>>8)/255,e.b=(i&255)/255}toRgb888(){const e=i=>("0"+(i*255).toString(16)).slice(-2);return+("0x"+e(this.r)+e(this.g)+e(this.b))}static fromString(e,i=new We){return i.setFromString(e)}},P=class Me{static PI=3.1415927;static PI2=Me.PI*2;static invPI2=1/Me.PI2;static radiansToDegrees=180/Me.PI;static radDeg=Me.radiansToDegrees;static degreesToRadians=Me.PI/180;static degRad=Me.degreesToRadians;static clamp(e,i,s){return es?s:e}static cosDeg(e){return Math.cos(e*Me.degRad)}static sinDeg(e){return Math.sin(e*Me.degRad)}static atan2Deg(e,i){return Math.atan2(e,i)*Me.degRad}static signum(e){return e>0?1:e<0?-1:0}static toInt(e){return e>0?Math.floor(e):Math.ceil(e)}static cbrt(e){let i=Math.pow(Math.abs(e),.3333333333333333);return e<0?-i:i}static randomTriangular(e,i){return Me.randomTriangularWith(e,i,(e+i)*.5)}static randomTriangularWith(e,i,s){let r=Math.random(),h=i-e;return r<=(s-e)/h?e+Math.sqrt(r*h*(s-e)):i-Math.sqrt((1-r)*h*(i-s))}static isPowerOfTwo(e){return e&&(e&e-1)===0}},Ki=class{apply(t,e,i){return t+(e-t)*this.applyInternal(i)}},Qi=class extends Ki{power=2;constructor(t){super(),this.power=t}applyInternal(t){return t<=.5?Math.pow(t*2,this.power)/2:Math.pow((t-1)*2,this.power)/(this.power%2==0?-2:2)+1}},ur=class extends Qi{constructor(t){super(t)}applyInternal(t){return Math.pow(t-1,this.power)*(this.power%2==0?-1:1)+1}},X=class Qe{static SUPPORTS_TYPED_ARRAYS=typeof Float32Array<"u";static arrayCopy(e,i,s,r,h){for(let l=i,n=r;l=i?e:Qe.setArraySize(e,i,s)}static newArray(e,i){let s=new Array(e);for(let r=0;r0?this.items.pop():this.instantiator()}free(t){t.reset&&t.reset(),this.items.push(t)}freeAll(t){for(let e=0;ethis.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)}},mr=class{values;addedValues=0;lastValue=0;mean=0;dirty=!0;constructor(t=32){this.values=new Array(t)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(t){this.addedValuesthis.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let t=0;for(let e=0;e>1)*l;let n=e.bone.skeleton,a=e.deform,o=this.vertices,c=this.bones;if(!c){a.length>0&&(o=a);let f=e.bone,g=f.worldX,w=f.worldY,b=f.a,p=f.b,x=f.c,v=f.d;for(let y=i,A=h;A=this.regions.length&&(s=this.regions.length-1);let r=this.regions[s];i.region!=r&&(i.region=r,i.updateRegion())}getPath(e,i){let s=e,r=(this.start+i).toString();for(let h=this.digits-r.length;h>0;h--)s+="0";return s+=r,s}static nextID(){return Et._nextID++}},es=(t=>(t[t.hold=0]="hold",t[t.once=1]="once",t[t.loop=2]="loop",t[t.pingpong=3]="pingpong",t[t.onceReverse=4]="onceReverse",t[t.loopReverse=5]="loopReverse",t[t.pingpongReverse=6]="pingpongReverse",t))(es||{}),ts=[0,1,2,3,4,5,6],ht=class{name;timelines=[];timelineIds=new Ft;duration;constructor(t,e,i){if(!t)throw new Error("name cannot be null.");this.name=t,this.setTimelines(e),this.duration=i}setTimelines(t){if(!t)throw new Error("timelines cannot be null.");this.timelines=t,this.timelineIds.clear();for(var e=0;e0&&(e%=this.duration));let a=this.timelines;for(let o=0,c=a.length;o(t[t.setup=0]="setup",t[t.first=1]="first",t[t.replace=2]="replace",t[t.add=3]="add",t))(is||{}),ss=(t=>(t[t.mixIn=0]="mixIn",t[t.mixOut=1]="mixOut",t))(ss||{}),se={rotate:0,x:1,y:2,scaleX:3,scaleY:4,shearX:5,shearY:6,inherit:7,rgb:8,alpha:9,rgb2:10,attachment:11,deform:12,event:13,drawOrder:14,ikConstraint:15,transformConstraint:16,pathConstraintPosition:17,pathConstraintSpacing:18,pathConstraintMix:19,physicsConstraintInertia:20,physicsConstraintStrength:21,physicsConstraintDamping:22,physicsConstraintMass:23,physicsConstraintWind:24,physicsConstraintGravity:25,physicsConstraintMix:26,physicsConstraintReset:27,sequence:28},ue=class{propertyIds;frames;constructor(t,e){this.propertyIds=e,this.frames=X.newFloatArray(t*this.getFrameEntries())}getPropertyIds(){return this.propertyIds}getFrameEntries(){return 1}getFrameCount(){return this.frames.length/this.getFrameEntries()}getDuration(){return this.frames[this.frames.length-this.getFrameEntries()]}static search1(t,e){let i=t.length;for(let s=1;se)return s-1;return i-1}static search(t,e,i){let s=t.length;for(let r=i;re)return r-i;return s-i}},Se=class extends ue{curves;constructor(t,e,i){super(t,i),this.curves=X.newFloatArray(t+e*18),this.curves[t-1]=1}setLinear(t){this.curves[t]=0}setStepped(t){this.curves[t]=1}shrink(t){let e=this.getFrameCount()+t*18;if(this.curves.length>e){let i=X.newFloatArray(e);X.arrayCopy(this.curves,0,i,0,e),this.curves=i}}setBezier(t,e,i,s,r,h,l,n,a,o,c){let u=this.curves,d=this.getFrameCount()+t*18;i==0&&(u[e]=2+d);let m=(s-h*2+n)*.03,f=(r-l*2+a)*.03,g=((h-n)*3-s+o)*.006,w=((l-a)*3-r+c)*.006,b=m*2+g,p=f*2+w,x=(h-s)*.3+m+g*.16666667,v=(l-r)*.3+f+w*.16666667,y=s+x,A=r+v;for(let C=d+18;dt){let a=this.frames[e],o=this.frames[e+i];return o+(t-a)/(r[s]-a)*(r[s+1]-o)}let h=s+18;for(s+=2;s=t){let a=r[s-2],o=r[s-1];return o+(t-a)/(r[s]-a)*(r[s+1]-o)}e+=this.getFrameEntries();let l=r[h-2],n=r[h-1];return n+(t-l)/(this.frames[e]-l)*(this.frames[e+i]-n)}},Ae=class extends Se{constructor(t,e,i){super(t,e,[i])}getFrameEntries(){return 2}setFrame(t,e,i){t<<=1,this.frames[t]=e,this.frames[t+1]=i}getCurveValue(t){let e=this.frames,i=e.length-2;for(let r=2;r<=i;r+=2)if(e[r]>t){i=r-2;break}let s=this.curves[i>>1];switch(s){case 0:let r=e[i],h=e[i+1];return h+(t-r)/(e[i+2]-r)*(e[i+2+1]-h);case 1:return e[i+1]}return this.getBezierValue(t,i,1,s-2)}getRelativeValue(t,e,i,s,r){if(t>2];switch(f){case 0:let g=a[m];c=a[m+1],u=a[m+2],d=a[m+3];let w=(i-g)/(a[m+4]-g);c+=(a[m+4+1]-c)*w,u+=(a[m+4+2]-u)*w,d+=(a[m+4+3]-d)*w;break;case 1:c=a[m+1],u=a[m+2],d=a[m+3];break;default:c=this.getBezierValue(i,m,1,f-2),u=this.getBezierValue(i,m,2,f+18-2),d=this.getBezierValue(i,m,3,f+18*2-2)}if(r==1)o.r=c,o.g=u,o.b=d;else{if(h==0){let g=n.data.color;o.r=g.r,o.g=g.g,o.b=g.b}o.r+=(c-o.r)*r,o.g+=(u-o.g)*r,o.b+=(d-o.b)*r}}},Ht=class extends Ae{slotIndex=0;constructor(t,e,i){super(t,e,se.alpha+"|"+i),this.slotIndex=i}apply(t,e,i,s,r,h,l){let n=t.slots[this.slotIndex];if(!n.bone.active)return;let a=n.color;if(i>3];switch(x){case 0:let v=a[p];u=a[p+1],d=a[p+2],m=a[p+3],f=a[p+4],g=a[p+5],w=a[p+6],b=a[p+7];let y=(i-v)/(a[p+8]-v);u+=(a[p+8+1]-u)*y,d+=(a[p+8+2]-d)*y,m+=(a[p+8+3]-m)*y,f+=(a[p+8+4]-f)*y,g+=(a[p+8+5]-g)*y,w+=(a[p+8+6]-w)*y,b+=(a[p+8+7]-b)*y;break;case 1:u=a[p+1],d=a[p+2],m=a[p+3],f=a[p+4],g=a[p+5],w=a[p+6],b=a[p+7];break;default:u=this.getBezierValue(i,p,1,x-2),d=this.getBezierValue(i,p,2,x+18-2),m=this.getBezierValue(i,p,3,x+18*2-2),f=this.getBezierValue(i,p,4,x+18*3-2),g=this.getBezierValue(i,p,5,x+18*4-2),w=this.getBezierValue(i,p,6,x+18*5-2),b=this.getBezierValue(i,p,7,x+18*6-2)}if(r==1)o.set(u,d,m,f),c.r=g,c.g=w,c.b=b;else{if(h==0){o.setFromColor(n.data.color);let v=n.data.darkColor;c.r=v.r,c.g=v.g,c.b=v.b}o.add((u-o.r)*r,(d-o.g)*r,(m-o.b)*r,(f-o.a)*r),c.r+=(g-c.r)*r,c.g+=(w-c.g)*r,c.b+=(b-c.b)*r}}},jt=class extends Se{slotIndex=0;constructor(t,e,i){super(t,e,[se.rgb+"|"+i,se.rgb2+"|"+i]),this.slotIndex=i}getFrameEntries(){return 7}setFrame(t,e,i,s,r,h,l,n){t*=7,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=s,this.frames[t+3]=r,this.frames[t+4]=h,this.frames[t+5]=l,this.frames[t+6]=n}apply(t,e,i,s,r,h,l){let n=t.slots[this.slotIndex];if(!n.bone.active)return;let a=this.frames,o=n.color,c=n.darkColor;if(it){let n=this.frames[e];return i[s+1]*(t-n)/(i[s]-n)}let r=s+18;for(s+=2;s=t){let n=i[s-2],a=i[s-1];return a+(t-n)/(i[s]-n)*(i[s+1]-a)}let h=i[r-2],l=i[r-1];return l+(1-l)*(t-h)/(this.frames[e+this.getFrameEntries()]-h)}apply(t,e,i,s,r,h,l){let n=t.slots[this.slotIndex];if(!n.bone.active)return;let a=n.getAttachment();if(!a||!(a instanceof Ye)||a.timelineAttachment!=this.attachment)return;let o=n.deform;o.length==0&&(h=0);let c=this.vertices,u=c[0].length,d=this.frames;if(i=d[d.length-1]){let p=c[d.length-1];if(r==1)if(h==3){let x=a;if(x.bones)for(let v=0;vs)this.apply(e,i,Number.MAX_VALUE,r,h,l,n),i=-1;else if(i>=a[o-1])return;if(s0&&a[c-1]==u;)c--}for(;c=a[c];c++)r.push(this.events[c])}},qe=class Js extends ue{static propertyIds=[""+se.drawOrder];drawOrders;constructor(e){super(e,Js.propertyIds),this.drawOrders=new Array(e)}getFrameCount(){return this.frames.length}setFrame(e,i,s){this.frames[e]=i,this.drawOrders[e]=s}apply(e,i,s,r,h,l,n){if(n==1){l==0&&X.arrayCopy(e.slots,0,e.drawOrder,0,e.slots.length);return}if(s>2];switch(m){case 0:let f=a[d];o=a[d+1],c=a[d+2],u=a[d+3];let g=(i-f)/(a[d+4]-f);o+=(a[d+4+1]-o)*g,c+=(a[d+4+2]-c)*g,u+=(a[d+4+3]-u)*g;break;case 1:o=a[d+1],c=a[d+2],u=a[d+3];break;default:o=this.getBezierValue(i,d,1,m-2),c=this.getBezierValue(i,d,2,m+18-2),u=this.getBezierValue(i,d,3,m+18*2-2)}if(h==0){let f=n.data;n.mixRotate=f.mixRotate+(o-f.mixRotate)*r,n.mixX=f.mixX+(c-f.mixX)*r,n.mixY=f.mixY+(u-f.mixY)*r}else n.mixRotate+=(o-n.mixRotate)*r,n.mixX+=(c-n.mixX)*r,n.mixY+=(u-n.mixY)*r}},Be=class extends Ae{constraintIndex=0;constructor(t,e,i,s){super(t,e,s+"|"+i),this.constraintIndex=i}apply(t,e,i,s,r,h,l){let n;if(this.constraintIndex==-1){const a=i>=this.frames[0]?this.getCurveValue(i):0;for(const o of t.physicsConstraints)o.active&&this.global(o.data)&&this.set(o,this.getAbsoluteValue2(i,r,h,this.get(o),this.setup(o),a))}else n=t.physicsConstraints[this.constraintIndex],n.active&&this.set(n,this.getAbsoluteValue(i,r,h,this.get(n),this.setup(n)))}},ti=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintInertia)}setup(t){return t.data.inertia}get(t){return t.inertia}set(t,e){t.inertia=e}global(t){return t.inertiaGlobal}},ii=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintStrength)}setup(t){return t.data.strength}get(t){return t.strength}set(t,e){t.strength=e}global(t){return t.strengthGlobal}},si=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintDamping)}setup(t){return t.data.damping}get(t){return t.damping}set(t,e){t.damping=e}global(t){return t.dampingGlobal}},ri=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintMass)}setup(t){return 1/t.data.massInverse}get(t){return 1/t.massInverse}set(t,e){t.massInverse=1/e}global(t){return t.massGlobal}},ni=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintWind)}setup(t){return t.data.wind}get(t){return t.wind}set(t,e){t.wind=e}global(t){return t.windGlobal}},ai=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintGravity)}setup(t){return t.data.gravity}get(t){return t.gravity}set(t,e){t.gravity=e}global(t){return t.gravityGlobal}},li=class extends Be{constructor(t,e,i){super(t,e,i,se.physicsConstraintMix)}setup(t){return t.data.mix}get(t){return t.mix}set(t,e){t.mix=e}global(t){return t.mixGlobal}},oi=class Ks extends ue{static propertyIds=[se.physicsConstraintReset.toString()];constraintIndex;constructor(e,i){super(e,Ks.propertyIds),this.constraintIndex=i}getFrameCount(){return this.frames.length}setFrame(e,i){this.frames[e]=i}apply(e,i,s,r,h,l,n){let a;if(this.constraintIndex!=-1&&(a=e.physicsConstraints[this.constraintIndex],!a.active))return;const o=this.frames;if(i>s)this.apply(e,i,Number.MAX_VALUE,[],h,l,n),i=-1;else if(i>=o[o.length-1])return;if(!(s=o[ue.search1(o,i)+1]))if(a!=null)a.reset();else for(const c of e.physicsConstraints)c.active&&c.reset()}},hi=class Oe extends ue{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(e,i,s){super(e,[se.sequence+"|"+i+"|"+s.sequence.id]),this.slotIndex=i,this.attachment=s}getFrameEntries(){return Oe.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(e,i,s,r,h){let l=this.frames;e*=Oe.ENTRIES,l[e]=i,l[e+Oe.MODE]=s|r<<4,l[e+Oe.DELAY]=h}apply(e,i,s,r,h,l,n){let a=e.slots[this.slotIndex];if(!a.bone.active)return;let o=a.attachment,c=this.attachment;if(o!=c&&(!(o instanceof Ye)||o.timelineAttachment!=c))return;if(n==1){l==0&&(a.sequenceIndex=-1);return}let u=this.frames;if(s>4,b=this.attachment.sequence.regions.length,p=ts[f&15];if(p!=0)switch(w+=(s-m)/g+1e-5|0,p){case 1:w=Math.min(b-1,w);break;case 2:w%=b;break;case 3:{let x=(b<<1)-2;w=x==0?0:w%x,w>=b&&(w=x-w);break}case 4:w=Math.max(b-1-w,0);break;case 5:w=b-1-w%b;break;case 6:{let x=(b<<1)-2;w=x==0?0:(w+b-1)%x,w>=b&&(w=x-w)}}a.sequenceIndex=w}},rs=class It{static _emptyAnimation=new ht("",[],0);static emptyAnimation(){return It._emptyAnimation}data;tracks=new Array;timeScale=1;unkeyedState=0;events=new Array;listeners=new Array;queue=new as(this);propertyIDs=new Ft;animationsChanged=!1;trackEntryPool=new $e(()=>new ns);constructor(e){this.data=e}update(e){e*=this.timeScale;let i=this.tracks;for(let s=0,r=i.length;s0){if(h.delay-=l,h.delay>0)continue;l=-h.delay,h.delay=0}let n=h.next;if(n){let a=h.trackLast-n.delay;if(a>=0){for(n.delay=0,n.trackTime+=h.timeScale==0?0:(a/h.timeScale+e)*n.timeScale,h.trackTime+=l,this.setCurrent(s,n,!0);n.mixingFrom;)n.mixTime+=e,n=n.mixingFrom;continue}}else if(h.trackLast>=h.trackEnd&&!h.mixingFrom){i[s]=null,this.queue.end(h),this.clearNext(h);continue}if(h.mixingFrom&&this.updateMixingFrom(h,e)){let a=h.mixingFrom;for(h.mixingFrom=null,a&&(a.mixingTo=null);a;)this.queue.end(a),a=a.mixingFrom}h.trackTime+=l}this.queue.drain()}updateMixingFrom(e,i){let s=e.mixingFrom;if(!s)return!0;let r=this.updateMixingFrom(s,i);return s.animationLast=s.nextAnimationLast,s.trackLast=s.nextTrackLast,e.nextTrackLast!=-1&&e.mixTime>=e.mixDuration?((s.totalAlpha==0||e.mixDuration==0)&&(e.mixingFrom=s.mixingFrom,s.mixingFrom!=null&&(s.mixingFrom.mixingTo=e),e.interruptAlpha=s.interruptAlpha,this.queue.end(s)),r):(s.trackTime+=i*s.timeScale,e.mixTime+=i,!1)}apply(e){if(!e)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();let i=this.events,s=this.tracks,r=!1;for(let d=0,m=s.length;d0)continue;r=!0;let g=d==0?1:f.mixBlend,w=f.alpha;f.mixingFrom?w*=this.applyMixingFrom(f,e,g):f.trackTime>=f.trackEnd&&!f.next&&(w=0);let b=w>=f.alphaAttachmentThreshold,p=f.animationLast,x=f.getAnimationTime(),v=x,y=i;f.reverse&&(v=f.animation.duration-v,y=null);let A=f.animation.timelines,C=A.length;if(d==0&&w==1||g==3){d==0&&(b=!0);for(let S=0;S1&&(h=1),s!=1&&(s=r.mixBlend));let l=h=r.alphaAttachmentThreshold):(X.webkit602BugfixHelper(S,s),n&&y instanceof qe&&C==0&&(A=0),y.apply(i,d,f,g,S,C,A))}}return e.mixDuration>0&&this.queueEvents(r,m),this.events.length=0,r.nextAnimationLast=m,r.nextTrackLast=r.trackTime,h}applyAttachmentTimeline(e,i,s,r,h){var l=i.slots[e.slotIndex];l.bone.active&&(s=0,x=g>=0;Math.abs(w)<=90&&P.signum(w)!=P.signum(f)&&(Math.abs(g-b)>180?(m+=360*P.signum(g),x=p):b!=0?m-=360*P.signum(g):x=p),x!=p&&(m+=360*P.signum(g)),l[n]=m}l[n+1]=f,o.rotation=u+m*r}queueEvents(e,i){let s=e.animationStart,r=e.animationEnd,h=r-s,l=e.trackLast%h,n=this.events,a=0,o=n.length;for(;ar||this.queue.event(e,u)}let c=!1;if(e.loop)if(h==0)c=!0;else{const u=Math.floor(e.trackTime/h);c=u>0&&u>Math.floor(e.trackLast/h)}else c=i>=r&&e.animationLast=this.tracks.length)return;let i=this.tracks[e];if(!i)return;this.queue.end(i),this.clearNext(i);let s=i;for(;;){let r=s.mixingFrom;if(!r)break;this.queue.end(r),s.mixingFrom=null,s.mixingTo=null,s=r}this.tracks[i.trackIndex]=null,this.queue.drain()}setCurrent(e,i,s){let r=this.expandToIndex(e);this.tracks[e]=i,i.previous=null,r&&(s&&this.queue.interrupt(r),i.mixingFrom=r,r.mixingTo=i,i.mixTime=0,r.mixingFrom&&r.mixDuration>0&&(i.interruptAlpha*=Math.min(1,r.mixTime/r.mixDuration)),r.timelinesRotation.length=0),this.queue.start(i)}setAnimation(e,i,s=!1){let r=this.data.skeletonData.findAnimation(i);if(!r)throw new Error("Animation not found: "+i);return this.setAnimationWith(e,r,s)}setAnimationWith(e,i,s=!1){if(!i)throw new Error("animation cannot be null.");let r=!0,h=this.expandToIndex(e);h&&(h.nextTrackLast==-1?(this.tracks[e]=h.mixingFrom,this.queue.interrupt(h),this.queue.end(h),this.clearNext(h),h=h.mixingFrom,r=!1):this.clearNext(h));let l=this.trackEntry(e,i,s,h);return this.setCurrent(e,l,r),this.queue.drain(),l}addAnimation(e,i,s=!1,r=0){let h=this.data.skeletonData.findAnimation(i);if(!h)throw new Error("Animation not found: "+i);return this.addAnimationWith(e,h,s,r)}addAnimationWith(e,i,s=!1,r=0){if(!i)throw new Error("animation cannot be null.");let h=this.expandToIndex(e);if(h)for(;h.next;)h=h.next;let l=this.trackEntry(e,i,s,h);return h?(h.next=l,l.previous=h,r<=0&&(r=Math.max(r+h.getTrackComplete()-l.mixDuration,0))):(this.setCurrent(e,l,!0),this.queue.drain(),r<0&&(r=0)),l.delay=r,l}setEmptyAnimation(e,i=0){let s=this.setAnimationWith(e,It.emptyAnimation(),!1);return s.mixDuration=i,s.trackEnd=i,s}addEmptyAnimation(e,i=0,s=0){let r=this.addAnimationWith(e,It.emptyAnimation(),!1,s);return s<=0&&(r.delay=Math.max(r.delay+r.mixDuration-i,0)),r.mixDuration=i,r.trackEnd=i,r}setEmptyAnimations(e=0){let i=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let s=0,r=this.tracks.length;s0){h[a]=os,l[a]=u;continue e}break}h[a]=ft}}}getCurrent(e){return e>=this.tracks.length?null:this.tracks[e]}addListener(e){if(!e)throw new Error("listener cannot be null.");this.listeners.push(e)}removeListener(e){let i=this.listeners.indexOf(e);i>=0&&this.listeners.splice(i,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}},ns=class{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;holdPrevious=!1;reverse=!1;shortestRotation=!1;eventThreshold=0;mixAttachmentThreshold=0;alphaAttachmentThreshold=0;mixDrawOrderThreshold=0;animationStart=0;animationEnd=0;animationLast=0;nextAnimationLast=0;delay=0;trackTime=0;trackLast=0;nextTrackLast=0;trackEnd=0;timeScale=0;alpha=0;mixTime=0;_mixDuration=0;interruptAlpha=0;totalAlpha=0;get mixDuration(){return this._mixDuration}set mixDuration(t){this._mixDuration=t}setMixDurationWithDelay(t,e){this._mixDuration=t,e<=0&&(this.previous!=null?e=Math.max(e+this.previous.getTrackComplete()-t,0):e=0),this.delay=e}mixBlend=2;timelineMode=new Array;timelineHoldMix=new Array;timelinesRotation=new Array;reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(this.loop){let t=this.animationEnd-this.animationStart;return t==0?this.animationStart:this.trackTime%t+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)}setAnimationLast(t){this.animationLast=t,this.nextAnimationLast=t}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){let t=this.animationEnd-this.animationStart;if(t!=0){if(this.loop)return t*(1+(this.trackTime/t|0));if(this.trackTime=0}},as=class{objects=[];drainDisabled=!1;animState;constructor(t){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 i=0;i(t[t.start=0]="start",t[t.interrupt=1]="interrupt",t[t.end=2]="end",t[t.dispose=3]="dispose",t[t.complete=4]="complete",t[t.event=5]="event",t))(ls||{}),gr=class{start(t){}interrupt(t){}end(t){}dispose(t){}complete(t){}event(t,e){}},ut=0,ci=1,di=2,ft=3,os=4,ui=1,hs=2,cs=class{skeletonData;animationToMixTime={};defaultMix=0;constructor(t){if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,i){let s=this.skeletonData.findAnimation(t);if(!s)throw new Error("Animation not found: "+t);let r=this.skeletonData.findAnimation(e);if(!r)throw new Error("Animation not found: "+e);this.setMixWith(s,r,i)}setMixWith(t,e,i){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");let s=t.name+"."+e.name;this.animationToMixTime[s]=i}getMix(t,e){let i=t.name+"."+e.name,s=this.animationToMixTime[i];return s===void 0?this.defaultMix:s}},fi=class Qs extends Ye{color=new V(1,1,1,1);constructor(e){super(e)}copy(){let e=new Qs(this.name);return this.copyTo(e),e.color.setFromColor(this.color),e}},tt=class $s extends Ye{endSlot=null;color=new V(.2275,.2275,.8078,1);constructor(e){super(e)}copy(){let e=new $s(this.name);return this.copyTo(e),e.endSlot=this.endSlot,e.color.setFromColor(this.color),e}},mi=class{_image;constructor(t){this._image=t}getImage(){return this._image}},mt=(t=>(t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.MipMap=9987]="MipMap",t[t.MipMapNearestNearest=9984]="MipMapNearestNearest",t[t.MipMapLinearNearest=9985]="MipMapLinearNearest",t[t.MipMapNearestLinear=9986]="MipMapNearestLinear",t[t.MipMapLinearLinear=9987]="MipMapLinearLinear",t))(mt||{}),ds=(t=>(t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.ClampToEdge=33071]="ClampToEdge",t[t.Repeat=10497]="Repeat",t))(ds||{}),us=class{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0},pr=class extends mi{setFilters(t,e){}setWraps(t,e){}dispose(){}},gi=class{pages=new Array;regions=new Array;constructor(t){let e=new wr(t),i=new Array(4),s={};s.size=o=>{o.width=parseInt(i[1]),o.height=parseInt(i[2])},s.format=()=>{},s.filter=o=>{o.minFilter=X.enumValue(mt,i[1]),o.magFilter=X.enumValue(mt,i[2])},s.repeat=o=>{i[1].indexOf("x")!=-1&&(o.uWrap=10497),i[1].indexOf("y")!=-1&&(o.vWrap=10497)},s.pma=o=>{o.pma=i[1]=="true"};var r={};r.xy=o=>{o.x=parseInt(i[1]),o.y=parseInt(i[2])},r.size=o=>{o.width=parseInt(i[1]),o.height=parseInt(i[2])},r.bounds=o=>{o.x=parseInt(i[1]),o.y=parseInt(i[2]),o.width=parseInt(i[3]),o.height=parseInt(i[4])},r.offset=o=>{o.offsetX=parseInt(i[1]),o.offsetY=parseInt(i[2])},r.orig=o=>{o.originalWidth=parseInt(i[1]),o.originalHeight=parseInt(i[2])},r.offsets=o=>{o.offsetX=parseInt(i[1]),o.offsetY=parseInt(i[2]),o.originalWidth=parseInt(i[3]),o.originalHeight=parseInt(i[4])},r.rotate=o=>{let c=i[1];c=="true"?o.degrees=90:c!="false"&&(o.degrees=parseInt(c))},r.index=o=>{o.index=parseInt(i[1])};let h=e.readLine();for(;h&&h.trim().length==0;)h=e.readLine();for(;!(!h||h.trim().length==0||e.readEntry(i,h)==0);)h=e.readLine();let l=null,n=null,a=null;for(;h!==null;)if(h.trim().length==0)l=null,h=e.readLine();else if(l){let o=new pi(l,h);for(;;){let c=e.readEntry(i,h=e.readLine());if(c==0)break;let u=r[i[0]];if(u)u(o);else{n||(n=[]),a||(a=[]),n.push(i[0]);let d=[];for(let m=0;m0&&a&&a.length>0&&(o.names=n,o.values=a,n=null,a=null),o.u=o.x/l.width,o.v=o.y/l.height,o.degrees==90?(o.u2=(o.x+o.height)/l.width,o.v2=(o.y+o.width)/l.height):(o.u2=(o.x+o.width)/l.width,o.v2=(o.y+o.height)/l.height),this.regions.push(o)}else{for(l=new fs(h.trim());e.readEntry(i,h=e.readLine())!=0;){let o=s[i[0]];o&&o(l)}this.pages.push(l)}}findRegion(t){for(let e=0;e=this.lines.length?null:this.lines[this.index++]}readEntry(t,e){if(!e||(e=e.trim(),e.length==0))return 0;let i=e.indexOf(":");if(i==-1)return 0;t[0]=e.substr(0,i).trim();for(let s=1,r=i+1;;s++){let h=e.indexOf(",",r);if(h==-1)return t[s]=e.substr(r).trim(),s;if(t[s]=e.substr(r,h-r).trim(),r=h+1,s==4)return 4}}},fs=class{name;minFilter=9728;magFilter=9728;uWrap=33071;vWrap=33071;texture=null;width=0;height=0;pma=!1;regions=new Array;constructor(t){this.name=t}setTexture(t){this.texture=t,t.setFilters(this.minFilter,this.magFilter),t.setWraps(this.uWrap,this.vWrap);for(let e of this.regions)e.texture=t}},pi=class extends us{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(t,e){super(),this.page=t,this.name=e,t.regions.push(this)}},Ge=class Hi extends Ye{region=null;path;regionUVs=[];uvs=[];triangles=[];color=new V(1,1,1,1);width=0;height=0;hullLength=0;edges=[];parentMesh=null;sequence=null;tempColor=new V(0,0,0,0);constructor(e,i){super(e),this.path=i}updateRegion(){if(!this.region)throw new Error("Region not set.");let e=this.regionUVs;(!this.uvs||this.uvs.length!=e.length)&&(this.uvs=X.newFloatArray(e.length));let i=this.uvs,s=this.uvs.length,r=this.region.u,h=this.region.v,l=0,n=0;if(this.region instanceof pi){let a=this.region,o=a.page,c=o.width,u=o.height;switch(a.degrees){case 90:r-=(a.originalHeight-a.offsetY-a.height)/c,h-=(a.originalWidth-a.offsetX-a.width)/u,l=a.originalHeight/c,n=a.originalWidth/u;for(let d=0;d= 0.");if(!e)throw new Error("name cannot be null.");this.index=t,this.name=e,this.parent=i}},gt=(t=>(t[t.Normal=0]="Normal",t[t.OnlyTranslation=1]="OnlyTranslation",t[t.NoRotationOrReflection=2]="NoRotationOrReflection",t[t.NoScale=3]="NoScale",t[t.NoScaleOrReflection=4]="NoScaleOrReflection",t))(gt||{}),xi=class{data;skeleton;parent=null;children=new Array;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;ax=0;ay=0;arotation=0;ascaleX=0;ascaleY=0;ashearX=0;ashearY=0;a=0;b=0;c=0;d=0;worldY=0;worldX=0;inherit=0;sorted=!1;active=!1;constructor(t,e,i){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.skeleton=e,this.parent=i,this.setToSetupPose()}isActive(){return this.active}update(t){this.updateWorldTransformWith(this.ax,this.ay,this.arotation,this.ascaleX,this.ascaleY,this.ashearX,this.ashearY)}updateWorldTransform(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)}updateWorldTransformWith(t,e,i,s,r,h,l){this.ax=t,this.ay=e,this.arotation=i,this.ascaleX=s,this.ascaleY=r,this.ashearX=h,this.ashearY=l;let n=this.parent;if(!n){let d=this.skeleton;const m=d.scaleX,f=d.scaleY,g=(i+h)*P.degRad,w=(i+90+l)*P.degRad;this.a=Math.cos(g)*s*m,this.b=Math.cos(w)*r*m,this.c=Math.sin(g)*s*f,this.d=Math.sin(w)*r*f,this.worldX=t*m+d.x,this.worldY=e*f+d.y;return}let a=n.a,o=n.b,c=n.c,u=n.d;switch(this.worldX=a*t+o*e+n.worldX,this.worldY=c*t+u*e+n.worldY,this.inherit){case 0:{const d=(i+h)*P.degRad,m=(i+90+l)*P.degRad,f=Math.cos(d)*s,g=Math.cos(m)*r,w=Math.sin(d)*s,b=Math.sin(m)*r;this.a=a*f+o*w,this.b=a*g+o*b,this.c=c*f+u*w,this.d=c*g+u*b;return}case 1:{const d=(i+h)*P.degRad,m=(i+90+l)*P.degRad;this.a=Math.cos(d)*s,this.b=Math.cos(m)*r,this.c=Math.sin(d)*s,this.d=Math.sin(m)*r;break}case 2:{let d=1/this.skeleton.scaleX,m=1/this.skeleton.scaleY;a*=d,c*=m;let f=a*a+c*c,g=0;f>1e-4?(f=Math.abs(a*u*m-o*d*c)/f,o=c*f,u=a*f,g=Math.atan2(c,a)*P.radDeg):(a=0,c=0,g=90-Math.atan2(u,o)*P.radDeg);const w=(i+h-g)*P.degRad,b=(i+l-g+90)*P.degRad,p=Math.cos(w)*s,x=Math.cos(b)*r,v=Math.sin(w)*s,y=Math.sin(b)*r;this.a=a*p-o*v,this.b=a*x-o*y,this.c=c*p+u*v,this.d=c*x+u*y;break}case 3:case 4:{i*=P.degRad;const d=Math.cos(i),m=Math.sin(i);let f=(a*d+o*m)/this.skeleton.scaleX,g=(c*d+u*m)/this.skeleton.scaleY,w=Math.sqrt(f*f+g*g);w>1e-5&&(w=1/w),f*=w,g*=w,w=Math.sqrt(f*f+g*g),this.inherit==3&&a*u-o*c<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(w=-w),i=Math.PI/2+Math.atan2(g,f);const b=Math.cos(i)*w,p=Math.sin(i)*w;h*=P.degRad,l=(90+l)*P.degRad;const x=Math.cos(h)*s,v=Math.cos(l)*r,y=Math.sin(h)*s,A=Math.sin(l)*r;this.a=f*x+b*y,this.b=f*v+b*A,this.c=g*x+p*y,this.d=g*v+p*A;break}}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY}setToSetupPose(){let t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY,this.inherit=t.inherit}updateAppliedTransform(){let t=this.parent;if(!t){this.ax=this.worldX-this.skeleton.x,this.ay=this.worldY-this.skeleton.y,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,this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*P.radDeg;return}let e=t.a,i=t.b,s=t.c,r=t.d,h=1/(e*r-i*s),l=r*h,n=i*h,a=s*h,o=e*h,c=this.worldX-t.worldX,u=this.worldY-t.worldY;this.ax=c*l-u*n,this.ay=u*o-c*a;let d,m,f,g;if(this.inherit==1)d=this.a,m=this.b,f=this.c,g=this.d;else{switch(this.inherit){case 2:{let v=Math.abs(e*r-i*s)/(e*e+s*s);i=-s*this.skeleton.scaleX*v/this.skeleton.scaleY,r=e*this.skeleton.scaleY*v/this.skeleton.scaleX,h=1/(e*r-i*s),l=r*h,n=i*h;break}case 3:case 4:let w=P.cosDeg(this.rotation),b=P.sinDeg(this.rotation);e=(e*w+i*b)/this.skeleton.scaleX,s=(s*w+r*b)/this.skeleton.scaleY;let p=Math.sqrt(e*e+s*s);p>1e-5&&(p=1/p),e*=p,s*=p,p=Math.sqrt(e*e+s*s),this.inherit==3&&h<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(p=-p);let x=P.PI/2+Math.atan2(s,e);i=Math.cos(x)*p,r=Math.sin(x)*p,h=1/(e*r-i*s),l=r*h,n=i*h,a=s*h,o=e*h}d=l*this.a-n*this.c,m=l*this.b-n*this.d,f=o*this.c-a*this.a,g=o*this.d-a*this.b}if(this.ashearX=0,this.ascaleX=Math.sqrt(d*d+f*f),this.ascaleX>1e-4){let w=d*g-m*f;this.ascaleY=w/this.ascaleX,this.ashearY=-Math.atan2(d*m+f*g,w)*P.radDeg,this.arotation=Math.atan2(f,d)*P.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(m*m+g*g),this.ashearY=0,this.arotation=90-Math.atan2(g,m)*P.radDeg}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)}worldToLocal(t){let e=1/(this.a*this.d-this.b*this.c),i=t.x-this.worldX,s=t.y-this.worldY;return t.x=i*this.d*e-s*this.b*e,t.y=s*this.a*e-i*this.c*e,t}localToWorld(t){let e=t.x,i=t.y;return t.x=e*this.a+i*this.b+this.worldX,t.y=e*this.c+i*this.d+this.worldY,t}worldToParent(t){if(t==null)throw new Error("world cannot be null.");return this.parent==null?t:this.parent.worldToLocal(t)}parentToWorld(t){if(t==null)throw new Error("world cannot be null.");return this.parent==null?t:this.parent.localToWorld(t)}worldToLocalRotation(t){let e=P.sinDeg(t),i=P.cosDeg(t);return Math.atan2(this.a*e-this.c*i,this.d*i-this.b*e)*P.radDeg+this.rotation-this.shearX}localToWorldRotation(t){t-=this.rotation-this.shearX;let e=P.sinDeg(t),i=P.cosDeg(t);return Math.atan2(i*this.c+e*this.d,i*this.a+e*this.b)*P.radDeg}rotateWorld(t){t*=P.degRad;const e=Math.sin(t),i=Math.cos(t),s=this.a,r=this.b;this.a=i*s-e*this.c,this.b=i*r-e*this.d,this.c=e*s+i*this.c,this.d=e*r+i*this.d}},st=class{constructor(t,e,i){this.name=t,this.order=e,this.skinRequired=i}},ps=class{pathPrefix="";textureLoader;downloader;cache;errors={};toLoad=0;loaded=0;constructor(t,e="",i=new bi,s=new ws){this.textureLoader=t,this.pathPrefix=e,this.downloader=i,this.cache=s}start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,i){this.toLoad--,this.loaded++,this.cache.assets[e]=i,this.cache.assetsRefCount[e]=(this.cache.assetsRefCount[e]||0)+1,t&&t(e,i)}error(t,e,i){this.toLoad--,this.loaded++,this.errors[e]=i,t&&t(e,i)}loadAll(){return new Promise((e,i)=>{let s=()=>{if(this.isLoadingComplete()){this.hasErrors()?i(this.errors):e(this);return}requestAnimationFrame(s)};requestAnimationFrame(s)})}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},i=()=>{}){t=this.start(t),!this.reuseAssets(t,e,i)&&(this.cache.assetsLoaded[t]=new Promise((s,r)=>{this.downloader.downloadBinary(t,h=>{this.success(e,t,h),s(h)},(h,l)=>{const n=`Couldn't load binary ${t}: status ${h}, ${l}`;this.error(i,t,n),r(n)})}))}loadText(t,e=()=>{},i=()=>{}){t=this.start(t),this.downloader.downloadText(t,s=>{this.success(e,t,s)},(s,r)=>{this.error(i,t,`Couldn't load text ${t}: status ${s}, ${r}`)})}loadJson(t,e=()=>{},i=()=>{}){t=this.start(t),!this.reuseAssets(t,e,i)&&(this.cache.assetsLoaded[t]=new Promise((s,r)=>{this.downloader.downloadJson(t,h=>{this.success(e,t,h),s(h)},(h,l)=>{const n=`Couldn't load JSON ${t}: status ${h}, ${l}`;this.error(i,t,n),r(n)})}))}reuseAssets(t,e=()=>{},i=()=>{}){const s=this.cache.assetsLoaded[t],r=s!==void 0;return r&&(this.cache.assetsLoaded[t]=s.then(h=>(h=h instanceof Image||h instanceof ImageBitmap?this.textureLoader(h):h,this.success(e,t,h),h)).catch(h=>this.error(i,t,h))),r}loadTexture(t,e=()=>{},i=()=>{}){t=this.start(t),!this.reuseAssets(t,e,i)&&(this.cache.assetsLoaded[t]=new Promise((s,r)=>{if(!!!(typeof window<"u"&&typeof navigator<"u"&&window.document))fetch(t,{mode:"cors"}).then(n=>{if(n.ok)return n.blob();const a=`Couldn't load image: ${t}`;this.error(i,t,`Couldn't load image: ${t}`),r(a)}).then(n=>n?createImageBitmap(n,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(n=>{if(n){const a=this.textureLoader(n);this.success(e,t,a),s(a)}});else{let n=new Image;n.crossOrigin="anonymous",n.onload=()=>{const a=this.textureLoader(n);this.success(e,t,a),s(a)},n.onerror=()=>{const a=`Couldn't load image: ${t}`;this.error(i,t,a),r(a)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),n.src=t}}))}loadTextureAtlas(t,e=()=>{},i=()=>{},s){let r=t.lastIndexOf("/"),h=r>=0?t.substring(0,r+1):"";t=this.start(t),!this.reuseAssets(t,e,i)&&(this.cache.assetsLoaded[t]=new Promise((l,n)=>{this.downloader.downloadText(t,a=>{try{let o=new gi(a),c=o.pages.length,u=!1;for(let d of o.pages)this.loadTexture(s?s[d.name]:h+d.name,(m,f)=>{u||(d.setTexture(f),--c==0&&(this.success(e,t,o),l(o)))},(m,f)=>{if(!u){const g=`Couldn't load texture ${t} page image: ${m}`;this.error(i,t,g),n(g)}u=!0})}catch(o){const c=`Couldn't parse texture atlas ${t}: ${o.message}`;this.error(i,t,c),n(c)}},(a,o)=>{const c=`Couldn't load texture atlas ${t}: status ${a}, ${o}`;this.error(i,t,c),n(c)})}))}loadTextureAtlasButNoTextures(t,e=()=>{},i=()=>{},s){t=this.start(t),!this.reuseAssets(t,e,i)&&(this.cache.assetsLoaded[t]=new Promise((r,h)=>{this.downloader.downloadText(t,l=>{try{const n=new gi(l);this.success(e,t,n),r(n)}catch(n){const a=`Couldn't parse texture atlas ${t}: ${n.message}`;this.error(i,t,a),h(a)}},(l,n)=>{const a=`Couldn't load texture atlas ${t}: status ${l}, ${n}`;this.error(i,t,a),h(a)})}))}async loadBinaryAsync(t){return new Promise((e,i)=>{this.loadBinary(t,(s,r)=>e(r),(s,r)=>i(r))})}async loadJsonAsync(t){return new Promise((e,i)=>{this.loadJson(t,(s,r)=>e(r),(s,r)=>i(r))})}async loadTextureAsync(t){return new Promise((e,i)=>{this.loadTexture(t,(s,r)=>e(r),(s,r)=>i(r))})}async loadTextureAtlasAsync(t){return new Promise((e,i)=>{this.loadTextureAtlas(t,(s,r)=>e(r),(s,r)=>i(r))})}async loadTextureAtlasButNoTexturesAsync(t){return new Promise((e,i)=>{this.loadTextureAtlasButNoTextures(t,(s,r)=>e(r),(s,r)=>i(r))})}setCache(t){this.cache=t}get(t){return this.cache.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;let e=this.cache.assets[t];if(e)return e;let i=this.errors[t];throw Error("Asset not found: "+t+(i?` `+i:""))}remove(t){t=this.pathPrefix+t;let e=this.cache.assets[t];return e.dispose&&e.dispose(),delete this.cache.assets[t],delete this.cache.assetsRefCount[t],delete this.cache.assetsLoaded[t],e}removeAll(){for(let t in this.cache.assets){let e=this.cache.assets[t];e.dispose&&e.dispose()}this.cache.assets={},this.cache.assetsLoaded={},this.cache.assetsRefCount={}}isLoadingComplete(){return this.toLoad==0}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}disposeAsset(t){--this.cache.assetsRefCount[t]===0&&this.remove(t)}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}},ws=class Mt{assets={};assetsRefCount={};assetsLoaded={};static AVAILABLE_CACHES=new Map;static getCache(e){const i=Mt.AVAILABLE_CACHES.get(e);if(i)return i;const s=new Mt;return Mt.AVAILABLE_CACHES.set(e,s),s}async addAsset(e,i){this.assetsLoaded[e]=Promise.resolve(i),this.assets[e]=await i}},bi=class{callbacks={};rawDataUris={};dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return e!=-1?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){for(var e=window.atob(t),i=e.length,s=new Uint8Array(i),r=0;r{this.finish(t,r.status,r.responseText)};r.onload=h,r.onerror=h,r.send()}downloadJson(t,e,i){this.downloadText(t,s=>{e(JSON.parse(s))},i)}downloadBinary(t,e,i){if(this.start(t,e,i))return;const s=this.rawDataUris[t];if(s&&!s.includes(".")){try{this.finish(t,200,this.dataUriToUint8Array(s))}catch(l){this.finish(t,400,JSON.stringify(l))}return}let r=new XMLHttpRequest;r.open("GET",s||t,!0),r.responseType="arraybuffer";let h=()=>{this.finish(t,r.status,r.response)};r.onload=()=>{r.status==200||r.status==0?this.finish(t,200,new Uint8Array(r.response)):h()},r.onerror=h,r.send()}start(t,e,i){let s=this.callbacks[t];try{if(s)return!0;this.callbacks[t]=s=[]}finally{s.push(e,i)}}finish(t,e,i){let s=this.callbacks[t];delete this.callbacks[t];let r=e==200||e==0?[i]:[e,i];for(let h=r.length-1,l=s.length;h180?d-=360:d<-180&&(d+=360);let g=t.ascaleX,w=t.ascaleY;if(s||r){switch(t.inherit){case 3:case 4:m=e-t.worldX,f=i-t.worldY}const b=t.data.length*g;if(b>1e-4){const p=m*m+f*f;if(s&&pb*b){const x=(Math.sqrt(p)/b-1)*l+1;g*=x,h&&(w*=x)}}}t.updateWorldTransformWith(t.ax,t.ay,t.arotation+d*l,g,w,t.ashearX,t.ashearY)}apply2(t,e,i,s,r,h,l,n,a){if(t.inherit!=0||e.inherit!=0)return;let o=t.ax,c=t.ay,u=t.ascaleX,d=t.ascaleY,m=u,f=d,g=e.ascaleX,w=0,b=0,p=0;u<0?(u=-u,w=180,p=-1):(w=0,p=1),d<0&&(d=-d,p=-p),g<0?(g=-g,b=180):b=0;let x=e.ax,v=0,y=0,A=0,C=t.a,S=t.b,k=t.c,R=t.d,Y=Math.abs(u-d)<=1e-4;!Y||h?(v=0,y=C*x+t.worldX,A=k*x+t.worldY):(v=e.ay,y=C*x+S*v+t.worldX,A=k*x+R*v+t.worldY);let F=t.parent;if(!F)throw new Error("IK parent must itself have a parent.");C=F.a,S=F.b,k=F.c,R=F.d;let L=C*R-S*k,I=y-F.worldX,M=A-F.worldY;L=Math.abs(L)<=1e-4?0:1/L;let B=(I*R-M*S)*L-o,ie=(M*C-I*k)*L-c,te=Math.sqrt(B*B+ie*ie),re=e.data.length*g,ce,oe;if(te<1e-4){this.apply1(t,i,s,!1,h,!1,a),e.updateWorldTransformWith(x,v,0,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY);return}I=i-F.worldX,M=s-F.worldY;let fe=(I*R-M*S)*L-o,J=(M*C-I*k)*L-c,ne=fe*fe+J*J;if(n!=0){n*=u*(g+1)*.5;let me=Math.sqrt(ne),we=me-te-re*u+n;if(we>0){let xe=Math.min(1,we/(n*2))-1;xe=(we-n*(1-xe*xe))/me,fe-=xe*fe,J-=xe*J,ne=fe*fe+J*J}}e:if(Y){re*=u;let me=(ne-te*te-re*re)/(2*te*re);me<-1?(me=-1,oe=Math.PI*r):me>1?(me=1,oe=0,h&&(C=(Math.sqrt(ne)/(te+re)-1)*a+1,m*=C,l&&(f*=C))):oe=Math.acos(me)*r,C=te+re*me,S=re*Math.sin(oe),ce=Math.atan2(J*C-fe*S,fe*C+J*S)}else{C=u*re,S=d*re;let me=C*C,we=S*S,xe=Math.atan2(J,fe);k=we*te*te+me*ne-me*we;let Ie=-2*we*te,Je=we-me;if(R=Ie*Ie-4*Je*k,R>=0){let Ke=Math.sqrt(R);Ie<0&&(Ke=-Ke),Ke=-(Ie+Ke)*.5;let lt=Ke/Je,_s=k/Ke,kt=Math.abs(lt)=0){M=Math.sqrt(lt)*r,ce=xe-Math.atan2(M,kt),oe=Math.atan2(M/d,(kt-te)/u);break e}}let at=P.PI,St=te-C,qi=St*St,qs=0,Gs=0,Tt=te+C,Gi=Tt*Tt,Hs=0;k=-C*te/(me-we),k>=-1&&k<=1&&(k=Math.acos(k),I=C*Math.cos(k)+te,M=S*Math.sin(k),R=I*I+M*M,RGi&&(Gs=k,Gi=R,Tt=I,Hs=M)),ne<=(qi+Gi)*.5?(ce=xe-Math.atan2(qs*r,St),oe=at*r):(ce=xe-Math.atan2(Hs*r,Tt),oe=Gs*r)}let he=Math.atan2(v,x)*p,be=t.arotation;ce=(ce-he)*P.radDeg+w-be,ce>180?ce-=360:ce<-180&&(ce+=360),t.updateWorldTransformWith(o,c,be+ce*a,m,f,0,0),be=e.arotation,oe=((oe+he)*P.radDeg-e.ashearX)*p+b-be,oe>180?oe-=360:oe<-180&&(oe+=360),e.updateWorldTransformWith(x,v,be+oe*a,e.ascaleX,e.ascaleY,e.ashearX,e.ashearY)}},Ai=class extends st{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}bendDirection=0;compress=!1;stretch=!1;uniform=!1;mix=0;softness=0;constructor(t){super(t,0,!1)}},Ci=class extends st{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("SlotData not set.")}positionMode=0;spacingMode=1;rotateMode=1;offsetRotation=0;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;constructor(t){super(t,0,!1)}},Si=(t=>(t[t.Fixed=0]="Fixed",t[t.Percent=1]="Percent",t))(Si||{}),Ti=(t=>(t[t.Length=0]="Length",t[t.Fixed=1]="Fixed",t[t.Percent=2]="Percent",t[t.Proportional=3]="Proportional",t))(Ti||{}),ki=(t=>(t[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale",t))(ki||{}),bs=class De{static NONE=-1;static BEFORE=-2;static AFTER=-3;static epsilon=1e-5;data;bones;target;position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;spaces=new Array;positions=new Array;world=new Array;curves=new Array;lengths=new Array;segments=new Array;active=!1;constructor(e,i){if(!e)throw new Error("data cannot be null.");if(!i)throw new Error("skeleton cannot be null.");this.data=e,this.bones=new Array;for(let r=0,h=e.bones.length;r0){v=u/v*f;for(let A=1;A0?P.degRad:-P.degRad}for(let v=0,y=3;v0){let Y=A.a,F=A.b,L=A.c,I=A.d,M=0,B=0,ie=0;if(n?M=g[y-1]:d[v+1]==0?M=g[y+2]:M=Math.atan2(R,k),M-=Math.atan2(L,Y),x){B=Math.cos(M),ie=Math.sin(M);let te=A.data.length;w+=(te*(B*Y-ie*L)-k)*s,b+=(te*(ie*Y+B*L)-R)*s}else M+=p;M>P.PI?M-=P.PI2:M<-P.PI&&(M+=P.PI2),M*=s,B=Math.cos(M),ie=Math.sin(M),A.a=B*Y-ie*L,A.b=B*F-ie*I,A.c=ie*Y+B*L,A.d=ie*F+B*I}A.updateAppliedTransform()}}computeWorldPositions(e,i,s){let r=this.target,h=this.position,l=this.spaces,n=X.setArraySize(this.positions,i*3+2),a=this.world,o=e.closed,c=e.worldVerticesLength,u=c/6,d=De.NONE;if(!e.constantSpeed){let te=e.lengths;u-=o?1:2;let re=te[u];this.data.positionMode==1&&(h*=re);let ce;switch(this.data.spacingMode){case 2:ce=re;break;case 3:ce=re/i;break;default:ce=1}a=X.setArraySize(this.world,8);for(let oe=0,fe=0,J=0;oere){d!=De.AFTER&&(d=De.AFTER,e.computeWorldVertices(r,c-6,4,a,0,2)),this.addAfterPosition(he-re,a,0,n,fe);continue}for(;;J++){let be=te[J];if(!(he>be)){if(J==0)he/=be;else{let me=te[J-1];he=(he-me)/(be-me)}break}}J!=d&&(d=J,o&&J==u?(e.computeWorldVertices(r,c-4,4,a,0,2),e.computeWorldVertices(r,0,4,a,4,2)):e.computeWorldVertices(r,J*6+2,8,a,0,2)),this.addCurvePosition(he,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],n,fe,s||oe>0&&ne==0)}return n}o?(c+=2,a=X.setArraySize(this.world,c),e.computeWorldVertices(r,2,c-4,a,0,2),e.computeWorldVertices(r,0,2,a,c-4,2),a[c-2]=a[0],a[c-1]=a[1]):(u--,c-=4,a=X.setArraySize(this.world,c),e.computeWorldVertices(r,2,c,a,0,2));let m=X.setArraySize(this.curves,u),f=0,g=a[0],w=a[1],b=0,p=0,x=0,v=0,y=0,A=0,C=0,S=0,k=0,R=0,Y=0,F=0,L=0,I=0;for(let te=0,re=2;tef){this.addAfterPosition(J-f,a,c-4,n,re);continue}for(;;ce++){let ne=m[ce];if(!(J>ne)){if(ce==0)J/=ne;else{let he=m[ce-1];J=(J-he)/(ne-he)}break}}if(ce!=d){d=ce;let ne=ce*6;for(g=a[ne],w=a[ne+1],b=a[ne+2],p=a[ne+3],x=a[ne+4],v=a[ne+5],y=a[ne+6],A=a[ne+7],C=(g-b*2+x)*.03,S=(w-p*2+v)*.03,k=((b-x)*3-g+y)*.006,R=((p-v)*3-w+A)*.006,Y=C*2+k,F=S*2+R,L=(b-g)*.3+C+k*.16666667,I=(p-w)*.3+S+R*.16666667,ie=Math.sqrt(L*L+I*I),B[0]=ie,ne=1;ne<8;ne++)L+=Y,I+=F,Y+=k,F+=R,ie+=Math.sqrt(L*L+I*I),B[ne]=ie;L+=Y,I+=F,ie+=Math.sqrt(L*L+I*I),B[8]=ie,L+=Y+k,I+=F+R,ie+=Math.sqrt(L*L+I*I),B[9]=ie,oe=0}for(J*=ie;;oe++){let ne=B[oe];if(!(J>ne)){if(oe==0)J/=ne;else{let he=B[oe-1];J=oe+(J-he)/(ne-he)}break}}this.addCurvePosition(J*.1,g,w,b,p,x,v,y,A,n,re,s||te>0&&fe==0)}return n}addBeforePosition(e,i,s,r,h){let l=i[s],n=i[s+1],a=i[s+2]-l,o=i[s+3]-n,c=Math.atan2(o,a);r[h]=l+e*Math.cos(c),r[h+1]=n+e*Math.sin(c),r[h+2]=c}addAfterPosition(e,i,s,r,h){let l=i[s+2],n=i[s+3],a=l-i[s],o=n-i[s+1],c=Math.atan2(o,a);r[h]=l+e*Math.cos(c),r[h+1]=n+e*Math.sin(c),r[h+2]=c}addCurvePosition(e,i,s,r,h,l,n,a,o,c,u,d){if(e==0||isNaN(e)){c[u]=i,c[u+1]=s,c[u+2]=Math.atan2(h-s,r-i);return}let m=e*e,f=m*e,g=1-e,w=g*g,b=w*g,p=g*e,x=p*3,v=g*x,y=x*e,A=i*b+r*v+l*y+a*f,C=s*b+h*v+n*y+o*f;c[u]=A,c[u+1]=C,d&&(e<.001?c[u+2]=Math.atan2(h-s,r-i):c[u+2]=Math.atan2(C-(s*w+h*p*2+n*m),A-(i*w+r*p*2+l*m)))}},xr=class{data;_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("Bone not set.")}inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xVelocity=0;yOffset=0;yVelocity=0;rotateOffset=0;rotateVelocity=0;scaleOffset=0;scaleVelocity=0;active=!1;skeleton;remaining=0;lastTime=0;constructor(t,e){this.data=t,this.skeleton=e,this.bone=e.bones[t.bone.index],this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}reset(){this.remaining=0,this.lastTime=this.skeleton.time,this._reset=!0,this.xOffset=0,this.xVelocity=0,this.yOffset=0,this.yVelocity=0,this.rotateOffset=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleVelocity=0}setToSetupPose(){const t=this.data;this.inertia=t.inertia,this.strength=t.strength,this.damping=t.damping,this.massInverse=t.massInverse,this.wind=t.wind,this.gravity=t.gravity,this.mix=t.mix}isActive(){return this.active}update(t){const e=this.mix;if(e==0)return;const i=this.data.x>0,s=this.data.y>0,r=this.data.rotate>0||this.data.shearX>0,h=this.data.scaleX>0,l=this.bone,n=l.data.length;switch(t){case 0:return;case 1:this.reset();case 2:const a=this.skeleton,o=Math.max(this.skeleton.time-this.lastTime,0);this.remaining+=o,this.lastTime=a.time;const c=l.worldX,u=l.worldY;if(this._reset)this._reset=!1,this.ux=c,this.uy=u;else{let d=this.remaining,m=this.inertia,f=this.data.step,g=this.skeleton.data.referenceScale,w=-1,b=this.data.limit*o,p=b*Math.abs(a.scaleY);if(b*=Math.abs(a.scaleX),i||s){if(i){const x=(this.ux-c)*m;this.xOffset+=x>b?b:x<-b?-b:x,this.ux=c}if(s){const x=(this.uy-u)*m;this.yOffset+=x>p?p:x<-p?-p:x,this.uy=u}if(d>=f){w=Math.pow(this.damping,60*f);const x=this.massInverse*f,v=this.strength,y=this.wind*g*a.scaleX,A=this.gravity*g*a.scaleY;do i&&(this.xVelocity+=(y-this.xOffset*v)*x,this.xOffset+=this.xVelocity*f,this.xVelocity*=w),s&&(this.yVelocity-=(A+this.yOffset*v)*x,this.yOffset+=this.yVelocity*f,this.yVelocity*=w),d-=f;while(d>=f)}i&&(l.worldX+=this.xOffset*e*this.data.x),s&&(l.worldY+=this.yOffset*e*this.data.y)}if(r||h){let x=Math.atan2(l.c,l.a),v=0,y=0,A=0,C=this.cx-l.worldX,S=this.cy-l.worldY;if(C>b?C=b:C<-b&&(C=-b),S>p?S=p:S<-p&&(S=-p),r){A=(this.data.rotate+this.data.shearX)*e;let k=Math.atan2(S+this.ty,C+this.tx)-x-this.rotateOffset*A;this.rotateOffset+=(k-Math.ceil(k*P.invPI2-.5)*P.PI2)*m,k=this.rotateOffset*A+x,v=Math.cos(k),y=Math.sin(k),h&&(k=n*l.getWorldScaleX(),k>0&&(this.scaleOffset+=(C*v+S*y)*m/k))}else{v=Math.cos(x),y=Math.sin(x);const k=n*l.getWorldScaleX();k>0&&(this.scaleOffset+=(C*v+S*y)*m/k)}if(d=this.remaining,d>=f){w==-1&&(w=Math.pow(this.damping,60*f));const k=this.massInverse*f,R=this.strength,Y=this.wind,F=Ei.yDown?-this.gravity:this.gravity,L=n/g;for(;;)if(d-=f,h&&(this.scaleVelocity+=(Y*v-F*y-this.scaleOffset*R)*k,this.scaleOffset+=this.scaleVelocity*f,this.scaleVelocity*=w),r){if(this.rotateVelocity-=((Y*y+F*v)*L+this.rotateOffset*R)*k,this.rotateOffset+=this.rotateVelocity*f,this.rotateVelocity*=w,d0){let d=0;this.data.rotate>0&&(d=a*this.data.rotate,o=Math.sin(d),c=Math.cos(d),u=l.b,l.b=c*u-o*l.d,l.d=o*u+c*l.d),d+=a*this.data.shearX,o=Math.sin(d),c=Math.cos(d),u=l.a,l.a=c*u-o*l.c,l.c=o*u+c*l.c}else a*=this.data.rotate,o=Math.sin(a),c=Math.cos(a),u=l.a,l.a=c*u-o*l.c,l.c=o*u+c*l.c,u=l.b,l.b=c*u-o*l.d,l.d=o*u+c*l.d}if(h){const a=1+this.scaleOffset*e*this.data.scaleX;l.a*=a,l.c*=a}t!=3&&(this.tx=n*l.a,this.ty=n*l.c),l.updateAppliedTransform()}translate(t,e){this.ux-=t,this.uy-=e,this.cx-=t,this.cy-=e}rotate(t,e,i){const s=i*P.degRad,r=Math.cos(s),h=Math.sin(s),l=this.cx-t,n=this.cy-e;this.translate(l*r-n*h-l,l*h+n*r-n)}},vs=class{data;bone;color;darkColor=null;attachment=null;attachmentState=0;sequenceIndex=-1;deform=new Array;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("bone cannot be null.");this.data=t,this.bone=e,this.color=new V,this.darkColor=t.darkColor?new V:null,this.setToSetupPose()}getSkeleton(){return this.bone.skeleton}getAttachment(){return this.attachment}setAttachment(t){this.attachment!=t&&((!(t instanceof Ye)||!(this.attachment instanceof Ye)||t.timelineAttachment!=this.attachment.timelineAttachment)&&(this.deform.length=0),this.attachment=t,this.sequenceIndex=-1)}setToSetupPose(){this.color.setFromColor(this.data.color),this.darkColor&&this.darkColor.setFromColor(this.data.darkColor),this.data.attachmentName?(this.attachment=null,this.setAttachment(this.bone.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.attachment=null}},ys=class{data;bones;target;mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;temp=new Ce;active=!1;constructor(t,e){if(!t)throw new Error("data cannot be null.");if(!e)throw new Error("skeleton cannot be null.");this.data=t,this.bones=new Array;for(let s=0;s0?P.degRad:-P.degRad,m=this.data.offsetRotation*d,f=this.data.offsetShearY*d,g=this.bones;for(let w=0,b=g.length;wP.PI?C-=P.PI2:C<-P.PI&&(C+=P.PI2),C*=t;let S=Math.cos(C),k=Math.sin(C);p.a=S*x-k*y,p.b=S*v-k*A,p.c=k*x+S*y,p.d=k*v+S*A}if(l){let x=this.temp;n.localToWorld(x.set(this.data.offsetX,this.data.offsetY)),p.worldX+=(x.x-p.worldX)*e,p.worldY+=(x.y-p.worldY)*i}if(s!=0){let x=Math.sqrt(p.a*p.a+p.c*p.c);x!=0&&(x=(x+(Math.sqrt(a*a+c*c)-x+this.data.offsetScaleX)*s)/x),p.a*=x,p.c*=x}if(r!=0){let x=Math.sqrt(p.b*p.b+p.d*p.d);x!=0&&(x=(x+(Math.sqrt(o*o+u*u)-x+this.data.offsetScaleY)*r)/x),p.b*=x,p.d*=x}if(h>0){let x=p.b,v=p.d,y=Math.atan2(v,x),A=Math.atan2(u,o)-Math.atan2(c,a)-(y-Math.atan2(p.c,p.a));A>P.PI?A-=P.PI2:A<-P.PI&&(A+=P.PI2),A=y+(A+f)*h;let C=Math.sqrt(x*x+v*v);p.b=Math.cos(A)*C,p.d=Math.sin(A)*C}p.updateAppliedTransform()}}applyRelativeWorld(){let t=this.mixRotate,e=this.mixX,i=this.mixY,s=this.mixScaleX,r=this.mixScaleY,h=this.mixShearY,l=e!=0||i!=0,n=this.target,a=n.a,o=n.b,c=n.c,u=n.d,d=a*u-o*c>0?P.degRad:-P.degRad,m=this.data.offsetRotation*d,f=this.data.offsetShearY*d,g=this.bones;for(let w=0,b=g.length;wP.PI?C-=P.PI2:C<-P.PI&&(C+=P.PI2),C*=t;let S=Math.cos(C),k=Math.sin(C);p.a=S*x-k*y,p.b=S*v-k*A,p.c=k*x+S*y,p.d=k*v+S*A}if(l){let x=this.temp;n.localToWorld(x.set(this.data.offsetX,this.data.offsetY)),p.worldX+=x.x*e,p.worldY+=x.y*i}if(s!=0){let x=(Math.sqrt(a*a+c*c)-1+this.data.offsetScaleX)*s+1;p.a*=x,p.c*=x}if(r!=0){let x=(Math.sqrt(o*o+u*u)-1+this.data.offsetScaleY)*r+1;p.b*=x,p.d*=x}if(h>0){let x=Math.atan2(u,o)-Math.atan2(c,a);x>P.PI?x-=P.PI2:x<-P.PI&&(x+=P.PI2);let v=p.b,y=p.d;x=Math.atan2(y,v)+(x-P.PI/2+f)*h;let A=Math.sqrt(v*v+y*y);p.b=Math.cos(x)*A,p.d=Math.sin(x)*A}p.updateAppliedTransform()}}applyAbsoluteLocal(){let t=this.mixRotate,e=this.mixX,i=this.mixY,s=this.mixScaleX,r=this.mixScaleY,h=this.mixShearY,l=this.target,n=this.bones;for(let a=0,o=n.length;ai.data.name==e)??null}findTransformConstraint(e){if(!e)throw new Error("constraintName cannot be null.");return this.transformConstraints.find(i=>i.data.name==e)??null}findPathConstraint(e){if(!e)throw new Error("constraintName cannot be null.");return this.pathConstraints.find(i=>i.data.name==e)??null}findPhysicsConstraint(e){if(e==null)throw new Error("constraintName cannot be null.");return this.physicsConstraints.find(i=>i.data.name==e)??null}getBoundsRect(e){let i=new Ce,s=new Ce;return this.getBounds(i,s,void 0,e),{x:i.x,y:i.y,width:s.x,height:s.y}}getBounds(e,i,s=new Array(2),r=null){if(!e)throw new Error("offset cannot be null.");if(!i)throw new Error("size cannot be null.");let h=this.drawOrder,l=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let c=0,u=h.length;c(t[t.none=0]="none",t[t.reset=1]="reset",t[t.update=2]="update",t[t.pose=3]="pose",t))(As||{}),Cs=class extends st{_bone=null;set bone(t){this._bone=t}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;constructor(t){super(t,0,!1)}},Ii=class{name=null;bones=new Array;slots=new Array;skins=new Array;defaultSkin=null;events=new Array;animations=new Array;ikConstraints=new Array;transformConstraints=new Array;pathConstraints=new Array;physicsConstraints=new Array;x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=0;imagesPath=null;audioPath=null;findBone(t){if(!t)throw new Error("boneName cannot be null.");let e=this.bones;for(let i=0,s=e.length;i=s.length&&(s.length=t+1),s[t]||(s[t]={}),s[t][e]=i}addSkin(t){for(let s=0;s= 0.");if(!e)throw new Error("name cannot be null.");if(!i)throw new Error("boneData cannot be null.");this.index=t,this.name=e,this.boneData=i}},Yi=(t=>(t[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen",t))(Yi||{}),Fi=class extends st{bones=new Array;_target=null;set target(t){this._target=t}get target(){if(this._target)return this._target;throw new Error("BoneData not set.")}mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;offsetRotation=0;offsetX=0;offsetY=0;offsetScaleX=0;offsetScaleY=0;offsetShearY=0;relative=!1;local=!1;constructor(t){super(t,0,!1)}},Ss=class{scale=1;attachmentLoader;linkedMeshes=new Array;constructor(t){this.attachmentLoader=t}readSkeletonData(t){let e=this.scale,i=new Ii;i.name="";let s=new Ts(t),r=s.readInt32(),h=s.readInt32();i.hash=h==0&&r==0?null:h.toString(16)+r.toString(16),i.version=s.readString(),i.x=s.readFloat(),i.y=s.readFloat(),i.width=s.readFloat(),i.height=s.readFloat(),i.referenceScale=s.readFloat()*e;let l=s.readBoolean();l&&(i.fps=s.readFloat(),i.imagesPath=s.readString(),i.audioPath=s.readString());let n=0;n=s.readInt(!0);for(let o=0;o>1&3,d.rotateMode=m>>3&3,(m&128)!=0&&(d.offsetRotation=s.readFloat()),d.position=s.readFloat(),d.positionMode==0&&(d.position*=e),d.spacing=s.readFloat(),(d.spacingMode==0||d.spacingMode==1)&&(d.spacing*=e),d.mixRotate=s.readFloat(),d.mixX=s.readFloat(),d.mixY=s.readFloat(),i.pathConstraints.push(d)}n=s.readInt(!0);for(let o=0,c;o>4,t.readFloat())}s.push(y);break}}}}}let h=t.readInt(!0);if(h>0){let a=new qe(h),o=i.slots.length;for(let c=0;c=0;b--)m[b]=-1;let f=X.newArray(o-d,0),g=0,w=0;for(let b=0;b=0;b--)m[b]==-1&&(m[b]=f[--w]);a.setFrame(c,u,m)}s.push(a)}let l=t.readInt(!0);if(l>0){let a=new dt(l);for(let o=0;o>>1^-(i&1)}readStringRef(){let t=this.readInt(!0);return t==0?null:this.strings[t-1]}readString(){let t=this.readInt(!0);switch(t){case 0:return null;case 1:return""}t--;let e="",i=0;for(let s=0;s>4){case 12:case 13:e+=String.fromCharCode((r&31)<<6|this.readByte()&63),s+=2;break;case 14:e+=String.fromCharCode((r&15)<<12|(this.readByte()&63)<<6|this.readByte()&63),s+=3;break;default:e+=String.fromCharCode(r),s++}}return e}readFloat(){let t=this.buffer.getFloat32(this.index);return this.index+=4,t}readBoolean(){return this.readByte()!=0}},br=class{parent;skinIndex;slotIndex;mesh;inheritTimeline;constructor(t,e,i,s,r){this.mesh=t,this.skinIndex=e,this.slotIndex=i,this.parent=s,this.inheritTimeline=r}},vr=class{constructor(t=null,e=null,i=0){this.bones=t,this.vertices=e,this.length=i}};function pe(t,e,i){let s=t.readFloat(),r=t.readFloat()*i;for(let h=0,l=0,n=e.getFrameCount()-1;e.setFrame(h,s,r),h!=n;h++){let a=t.readFloat(),o=t.readFloat()*i;switch(t.readByte()){case Fe:e.setStepped(h);break;case Le:ae(t,e,l++,h,0,s,a,r,o,i)}s=a,r=o}return e}function Li(t,e,i){let s=t.readFloat(),r=t.readFloat()*i,h=t.readFloat()*i;for(let l=0,n=0,a=e.getFrameCount()-1;e.setFrame(l,s,r,h),l!=a;l++){let o=t.readFloat(),c=t.readFloat()*i,u=t.readFloat()*i;switch(t.readByte()){case Fe:e.setStepped(l);break;case Le:ae(t,e,n++,l,0,s,o,r,c,i),ae(t,e,n++,l,1,s,o,h,u,i)}s=o,r=c,h=u}return e}function ae(t,e,i,s,r,h,l,n,a,o){e.setBezier(i,s,r,h,n,t.readFloat(),t.readFloat()*o,t.readFloat(),t.readFloat()*o,l,a)}var yr=0,Ar=1,Cr=2,Sr=3,Tr=4,kr=5,Er=6,Ir=7,Mr=8,Rr=9,Yr=10,Fr=0,Lr=1,Pr=2,Xr=3,Br=4,Vr=5,Or=0,Dr=1,Nr=0,Ur=1,Wr=2,zr=0,qr=1,Gr=2,Hr=4,_r=5,jr=6,Zr=7,Jr=8,Fe=1,Le=2,ks=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=new Array;polygons=new Array;polygonPool=new $e(()=>X.newFloatArray(16));update(t,e){if(!t)throw new Error("skeleton cannot be null.");let i=this.boundingBoxes,s=this.polygons,r=this.polygonPool,h=t.slots,l=h.length;i.length=0,r.freeAll(s),s.length=0;for(let n=0;n=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,i,s){let r=this.minX,h=this.minY,l=this.maxX,n=this.maxY;if(t<=r&&i<=r||e<=h&&s<=h||t>=l&&i>=l||e>=n&&s>=n)return!1;let a=(s-e)/(i-t),o=a*(r-t)+e;if(o>h&&oh&&or&&cr&&ct.minX&&this.minYt.minY}containsPoint(t,e){let i=this.polygons;for(let s=0,r=i.length;s=i||o=i){let c=s[n];c+(i-a)/(o-a)*(s[h]-c)=c&&x<=m||x>=m&&x<=c)&&(x>=e&&x<=s||x>=s&&x<=e)){let v=(o*b-a*g)/p;if((v>=u&&v<=f||v>=f&&v<=u)&&(v>=i&&v<=r||v>=r&&v<=i))return!0}c=m,u=f}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");let e=this.boundingBoxes.indexOf(t);return e==-1?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},Es=class ye{convexPolygons=new Array;convexPolygonsIndices=new Array;indicesArray=new Array;isConcaveArray=new Array;triangles=new Array;polygonPool=new $e(()=>new Array);polygonIndicesPool=new $e(()=>new Array);triangulate(e){let i=e,s=e.length>>1,r=this.indicesArray;r.length=0;for(let n=0;n3;){let n=s-1,a=0,o=1;for(;;){e:if(!h[a]){let d=r[n]<<1,m=r[a]<<1,f=r[o]<<1,g=i[d],w=i[d+1],b=i[m],p=i[m+1],x=i[f],v=i[f+1];for(let y=(o+1)%s;y!=n;y=(y+1)%s){if(!h[y])continue;let A=r[y]<<1,C=i[A],S=i[A+1];if(ye.positiveArea(x,v,g,w,C,S)&&ye.positiveArea(g,w,b,p,C,S)&&ye.positiveArea(b,p,x,v,C,S))break e}break}if(o==0){do{if(!h[a])break;a--}while(a>0);break}n=a,a=o,o=(o+1)%s}l.push(r[(s+a-1)%s]),l.push(r[a]),l.push(r[(a+1)%s]),r.splice(a,1),h.splice(a,1),s--;let c=(s+a-1)%s,u=a==s?0:a;h[c]=ye.isConcave(c,s,i,r),h[u]=ye.isConcave(u,s,i,r)}return s==3&&(l.push(r[2]),l.push(r[0]),l.push(r[1])),l}decompose(e,i){let s=e,r=this.convexPolygons;this.polygonPool.freeAll(r),r.length=0;let h=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(h),h.length=0;let l=this.polygonIndicesPool.obtain();l.length=0;let n=this.polygonPool.obtain();n.length=0;let a=-1,o=0;for(let c=0,u=i.length;c0?(r.push(n),h.push(l)):(this.polygonPool.free(n),this.polygonIndicesPool.free(l)),n=this.polygonPool.obtain(),n.length=0,n.push(g),n.push(w),n.push(b),n.push(p),n.push(x),n.push(v),l=this.polygonIndicesPool.obtain(),l.length=0,l.push(d),l.push(m),l.push(f),o=ye.winding(g,w,b,p,x,v),a=d)}n.length>0&&(r.push(n),h.push(l));for(let c=0,u=r.length;c=0;c--)n=r[c],n.length==0&&(r.splice(c,1),this.polygonPool.free(n),l=h[c],h.splice(c,1),this.polygonIndicesPool.free(l));return r}static isConcave(e,i,s,r){let h=r[(i+e-1)%i]<<1,l=r[e]<<1,n=r[(e+1)%i]<<1;return!this.positiveArea(s[h],s[h+1],s[l],s[l+1],s[n],s[n+1])}static positiveArea(e,i,s,r,h,l){return e*(l-r)+s*(i-l)+h*(r-i)>=0}static winding(e,i,s,r,h,l){let n=s-e,a=r-i;return h*a-l*n+n*i-e*a>=0?1:-1}},Is=class ji{triangulator=new Es;clippingPolygon=new Array;clipOutput=new Array;clippedVertices=new Array;clippedUVs=new Array;clippedTriangles=new Array;scratch=new Array;clipAttachment=null;clippingPolygons=null;clipStart(e,i){if(this.clipAttachment)return 0;this.clipAttachment=i;let s=i.worldVerticesLength,r=X.setArraySize(this.clippingPolygon,s);i.computeWorldVertices(e,0,s,r,0,2);let h=this.clippingPolygon;ji.makeClockwise(h);let l=this.clippingPolygons=this.triangulator.decompose(h,this.triangulator.triangulate(h));for(let n=0,a=l.length;n>1,A=this.clipOutput,C=X.setArraySize(h,x+y*2);for(let k=0;k>1,fe=this.clipOutput,J=X.setArraySize(o,I+oe*m);for(let he=0;he>1,re=this.clipOutput,ce=X.setArraySize(l,Y+te*2),oe=X.setArraySize(n,Y+te*2);for(let J=0;J=2?(u=a,a=this.scratch):u=this.scratch,u.length=0,u.push(e),u.push(i),u.push(s),u.push(r),u.push(h),u.push(l),u.push(e),u.push(i),a.length=0;let d=n.length-4,m=n;for(let f=0;;f+=2){let g=m[f],w=m[f+1],b=g-m[f+2],p=w-m[f+3],x=a.length,v=u;for(let A=0,C=u.length-2;Ab*(w-Y),L=p*(g-S)-b*(w-k);if(L>0){if(F){a.push(R),a.push(Y);continue}let I=R-S,M=Y-k,B=L/(I*p-M*b);if(B>=0&&B<=1)a.push(S+I*B),a.push(k+M*B);else{a.push(R),a.push(Y);continue}}else if(F){let I=R-S,M=Y-k,B=L/(I*p-M*b);if(B>=0&&B<=1)a.push(S+I*B),a.push(k+M*B),a.push(R),a.push(Y);else{a.push(R),a.push(Y);continue}}c=!0}if(x==a.length)return o.length=0,!0;if(a.push(a[0]),a.push(a[1]),f==d)break;let y=a;a=u,a.length=0,u=y}if(o!=a){o.length=0;for(let f=0,g=a.length-2;f>1;o0){let o=i.findPhysicsConstraint(l);if(!o)throw new Error("Physics constraint not found: "+l);a=i.physicsConstraints.indexOf(o)}for(let o in n){let c=n[o],u=c[0];if(!u)continue;let d=c.length;if(o=="reset"){const f=new oi(d,a);for(let g=0;u!=null;u=c[g+1],g++)f.setFrame(g,E(u,"time",0));r.push(f);continue}let m;if(o=="inertia")m=new ti(d,d,a);else if(o=="strength")m=new ii(d,d,a);else if(o=="damping")m=new si(d,d,a);else if(o=="mass")m=new ri(d,d,a);else if(o=="wind")m=new ni(d,d,a);else if(o=="gravity")m=new ai(d,d,a);else if(o=="mix")m=new li(d,d,a);else continue;r.push(Te(c,m,0,1))}}if(t.attachments)for(let l in t.attachments){let n=t.attachments[l],a=i.findSkin(l);if(!a)throw new Error("Skin not found: "+l);for(let o in n){let c=n[o],u=i.findSlot(o);if(!u)throw new Error("Slot not found: "+o);let d=u.index;for(let m in c){let f=c[m],g=a.getAttachment(d,m);for(let w in f){let b=f[w],p=b[0];if(p){if(w=="deform"){let x=g.bones,v=g.vertices,y=x?v.length/3*2:v.length,A=new Zt(b.length,b.length,d,g),C=E(p,"time",0);for(let S=0,k=0;;S++){let R,Y=E(p,"vertices",null);if(!Y)R=x?X.newFloatArray(y):v;else{R=X.newFloatArray(y);let M=E(p,"offset",0);if(X.arrayCopy(Y,0,R,M,Y.length),s!=1)for(let B=M,ie=B+Y.length;B=0;w--)u[w]==-1&&(u[w]=m[--g])}l.setFrame(a,E(c,"time",0),u)}r.push(l)}if(t.events){let l=new dt(t.events.length),n=0;for(let a=0;a"u"&&(Math.fround=function(t){return function(e){return t[0]=e,t[0]}}(new Float32Array(1)));var ge=class{canvas;gl;restorables=[];constructor(t,e={alpha:!0}){if(t instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext)this.gl=t,this.canvas=this.gl.canvas;else{const i=t;this.gl=i.getContext("webgl2",e)||i.getContext("webgl",e),this.canvas=i,i.addEventListener("webglcontextlost",this.contextLostHandler),i.addEventListener("webglcontextrestored",this.contextRestoredHandler)}}contextLostHandler=t=>{t&&t.preventDefault()};contextRestoredHandler=()=>{for(let t=0,e=this.restorables.length;t-1&&this.restorables.splice(e,1)}},_e=class Rt extends mi{context;texture=null;boundUnit=0;useMipMaps=!1;static DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL=!1;constructor(e,i,s=!1){super(i),this.context=e instanceof ge?e:new ge(e),this.useMipMaps=s,this.restore(),this.context.addRestorable(this)}setFilters(e,i){let s=this.context.gl;this.bind(),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,Rt.validateMagFilter(i)),this.useMipMaps=Rt.usesMipMaps(e),this.useMipMaps&&s.generateMipmap(s.TEXTURE_2D)}static validateMagFilter(e){switch(e){case 9987:case 9985:case 9986:case 9984:return 9729;default:return e}}static usesMipMaps(e){switch(e){case 9987:case 9985:case 9986:case 9984:return!0;default:return!1}}setWraps(e,i){let s=this.context.gl;this.bind(),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i)}update(e){let i=this.context.gl;this.texture||(this.texture=this.context.gl.createTexture()),this.bind(),Rt.DISABLE_UNPACK_PREMULTIPLIED_ALPHA_WEBGL&&i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,this._image),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,e?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e&&i.generateMipmap(i.TEXTURE_2D)}restore(){this.texture=null,this.update(this.useMipMaps)}bind(e=0){let i=this.context.gl;this.boundUnit=e,i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,this.texture)}unbind(){let e=this.context.gl;e.activeTexture(e.TEXTURE0+this.boundUnit),e.bindTexture(e.TEXTURE_2D,null)}dispose(){this.context.removeRestorable(this),this.context.gl.deleteTexture(this.texture)}},Xi=class extends ps{constructor(t,e="",i=new bi){super(s=>new _e(t,s),e,i)}},ve=class{x=0;y=0;z=0;constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}setFrom(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}set(t,e,i){return this.x=t,this.y=e,this.z=i,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}scale(t){return this.x*=t,this.y*=t,this.z*=t,this}normalize(){let t=this.length();return t==0?this:(t=1/t,this.x*=t,this.y*=t,this.z*=t,this)}cross(t){return this.set(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)}multiply(t){let e=t.values;return this.set(this.x*e[O]+this.y*e[q]+this.z*e[G]+e[D],this.x*e[H]+this.y*e[N]+this.z*e[_]+e[U],this.x*e[j]+this.y*e[Z]+this.z*e[W]+e[z])}project(t){let e=t.values,i=1/(this.x*e[Q]+this.y*e[$]+this.z*e[ee]+e[K]);return this.set((this.x*e[O]+this.y*e[q]+this.z*e[G]+e[D])*i,(this.x*e[H]+this.y*e[N]+this.z*e[_]+e[U])*i,(this.x*e[j]+this.y*e[Z]+this.z*e[W]+e[z])*i)}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}distance(t){let e=t.x-this.x,i=t.y-this.y,s=t.z-this.z;return Math.sqrt(e*e+i*i+s*s)}},O=0,q=4,G=8,D=12,H=1,N=5,_=9,U=13,j=2,Z=6,W=10,z=14,Q=3,$=7,ee=11,K=15,rt=class Re{temp=new Float32Array(16);values=new Float32Array(16);static xAxis=new ve;static yAxis=new ve;static zAxis=new ve;static tmpMatrix=new Re;constructor(){let e=this.values;e[O]=1,e[N]=1,e[W]=1,e[K]=1}set(e){return this.values.set(e),this}transpose(){let e=this.temp,i=this.values;return e[O]=i[O],e[q]=i[H],e[G]=i[j],e[D]=i[Q],e[H]=i[q],e[N]=i[N],e[_]=i[Z],e[U]=i[$],e[j]=i[G],e[Z]=i[_],e[W]=i[W],e[z]=i[ee],e[Q]=i[D],e[$]=i[U],e[ee]=i[z],e[K]=i[K],this.set(e)}identity(){let e=this.values;return e[O]=1,e[q]=0,e[G]=0,e[D]=0,e[H]=0,e[N]=1,e[_]=0,e[U]=0,e[j]=0,e[Z]=0,e[W]=1,e[z]=0,e[Q]=0,e[$]=0,e[ee]=0,e[K]=1,this}invert(){let e=this.values,i=this.temp,s=e[Q]*e[Z]*e[_]*e[D]-e[j]*e[$]*e[_]*e[D]-e[Q]*e[N]*e[W]*e[D]+e[H]*e[$]*e[W]*e[D]+e[j]*e[N]*e[ee]*e[D]-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i[N]*r,e[_]=i[_]*r,e[U]=i[U]*r,e[j]=i[j]*r,e[Z]=i[Z]*r,e[W]=i[W]*r,e[z]=i[z]*r,e[Q]=i[Q]*r,e[$]=i[$]*r,e[ee]=i[ee]*r,e[K]=i[K]*r,this}determinant(){let e=this.values;return e[Q]*e[Z]*e[_]*e[D]-e[j]*e[$]*e[_]*e[D]-e[Q]*e[N]*e[W]*e[D]+e[H]*e[$]*e[W]*e[D]+e[j]*e[N]*e[ee]*e[D]-e[H]*e[Z]*e[ee]*e[D]-e[Q]*e[Z]*e[G]*e[U]+e[j]*e[$]*e[G]*e[U]+e[Q]*e[q]*e[W]*e[U]-e[O]*e[$]*e[W]*e[U]-e[j]*e[q]*e[ee]*e[U]+e[O]*e[Z]*e[ee]*e[U]+e[Q]*e[N]*e[G]*e[z]-e[H]*e[$]*e[G]*e[z]-e[Q]*e[q]*e[_]*e[z]+e[O]*e[$]*e[_]*e[z]+e[H]*e[q]*e[ee]*e[z]-e[O]*e[N]*e[ee]*e[z]-e[j]*e[N]*e[G]*e[K]+e[H]*e[Z]*e[G]*e[K]+e[j]*e[q]*e[_]*e[K]-e[O]*e[Z]*e[_]*e[K]-e[H]*e[q]*e[W]*e[K]+e[O]*e[N]*e[W]*e[K]}translate(e,i,s){let r=this.values;return r[D]+=e,r[U]+=i,r[z]+=s,this}copy(){return new Re().set(this.values)}projection(e,i,s,r){this.identity();let h=1/Math.tan(s*(Math.PI/180)/2),l=(i+e)/(e-i),n=2*i*e/(e-i),a=this.values;return a[O]=h/r,a[H]=0,a[j]=0,a[Q]=0,a[q]=0,a[N]=h,a[Z]=0,a[$]=0,a[G]=0,a[_]=0,a[W]=l,a[ee]=-1,a[D]=0,a[U]=0,a[z]=n,a[K]=0,this}ortho2d(e,i,s,r){return this.ortho(e,e+s,i,i+r,0,1)}ortho(e,i,s,r,h,l){this.identity();let n=2/(i-e),a=2/(r-s),o=-2/(l-h),c=-(i+e)/(i-e),u=-(r+s)/(r-s),d=-(l+h)/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[O]*s[G]+r[q]*s[_]+r[G]*s[W]+r[D]*s[ee],i[D]=r[O]*s[D]+r[q]*s[U]+r[G]*s[z]+r[D]*s[K],i[H]=r[H]*s[O]+r[N]*s[H]+r[_]*s[j]+r[U]*s[Q],i[N]=r[H]*s[q]+r[N]*s[N]+r[_]*s[Z]+r[U]*s[$],i[_]=r[H]*s[G]+r[N]*s[_]+r[_]*s[W]+r[U]*s[ee],i[U]=r[H]*s[D]+r[N]*s[U]+r[_]*s[z]+r[U]*s[K],i[j]=r[j]*s[O]+r[Z]*s[H]+r[W]*s[j]+r[z]*s[Q],i[Z]=r[j]*s[q]+r[Z]*s[N]+r[W]*s[Z]+r[z]*s[$],i[W]=r[j]*s[G]+r[Z]*s[_]+r[W]*s[W]+r[z]*s[ee],i[z]=r[j]*s[D]+r[Z]*s[U]+r[W]*s[z]+r[z]*s[K],i[Q]=r[Q]*s[O]+r[$]*s[H]+r[ee]*s[j]+r[K]*s[Q],i[$]=r[Q]*s[q]+r[$]*s[N]+r[ee]*s[Z]+r[K]*s[$],i[ee]=r[Q]*s[G]+r[$]*s[_]+r[ee]*s[W]+r[K]*s[ee],i[K]=r[Q]*s[D]+r[$]*s[U]+r[ee]*s[z]+r[K]*s[K],this.set(this.temp)}lookAt(e,i,s){let r=Re.xAxis,h=Re.yAxis,l=Re.zAxis;l.setFrom(i).normalize(),r.setFrom(i).normalize(),r.cross(s).normalize(),h.setFrom(r).cross(l).normalize(),this.identity();let n=this.values;return n[O]=r.x,n[q]=r.y,n[G]=r.z,n[H]=h.x,n[N]=h.y,n[_]=h.z,n[j]=-l.x,n[Z]=-l.y,n[W]=-l.z,Re.tmpMatrix.identity(),Re.tmpMatrix.values[D]=-e.x,Re.tmpMatrix.values[U]=-e.y,Re.tmpMatrix.values[z]=-e.z,this.multiply(Re.tmpMatrix),this}},Rs=class{position=new ve(0,0,0);direction=new ve(0,0,-1);up=new ve(0,1,0);near=0;far=100;zoom=1;viewportWidth=0;viewportHeight=0;projectionView=new rt;inverseProjectionView=new rt;projection=new rt;view=new rt;constructor(t,e){this.viewportWidth=t,this.viewportHeight=e,this.update()}update(){let t=this.projection,e=this.view,i=this.projectionView,s=this.inverseProjectionView,r=this.zoom,h=this.viewportWidth,l=this.viewportHeight;t.ortho(r*(-h/2),r*(h/2),r*(-l/2),r*(l/2),this.near,this.far),e.lookAt(this.position,this.direction,this.up),i.set(t.values),i.multiply(e),s.set(i.values).invert()}screenToWorld(t,e,i){let s=t.x,r=i-t.y-1;return t.x=2*s/e-1,t.y=2*r/i-1,t.z=2*t.z-1,t.project(this.inverseProjectionView),t}worldToScreen(t,e,i){return t.project(this.projectionView),t.x=e*(t.x+1)/2,t.y=i*(t.y+1)/2,t.z=(t.z+1)/2,t}setViewport(t,e){this.viewportWidth=t,this.viewportHeight=e}},nt=class{element;mouseX=0;mouseY=0;buttonDown=!1;touch0=null;touch1=null;initialPinchDistance=0;listeners=new Array;autoPreventDefault;isTouch=!1;callbacks;constructor(t,e=!0){this.element=t,this.autoPreventDefault=e,this.callbacks=this.setupCallbacks(t)}setupCallbacks(t){const e=a=>{if(a instanceof MouseEvent&&!this.isTouch){let o=t.getBoundingClientRect();this.mouseX=a.clientX-o.left,this.mouseY=a.clientY-o.top,this.buttonDown=!0,this.listeners.map(c=>{c.down&&c.down(this.mouseX,this.mouseY,a)})}},i=a=>{if(a instanceof MouseEvent&&!this.isTouch){let o=t.getBoundingClientRect();this.mouseX=a.clientX-o.left,this.mouseY=a.clientY-o.top,this.listeners.map(c=>{this.buttonDown?c.dragged&&c.dragged(this.mouseX,this.mouseY,a):c.moved&&c.moved(this.mouseX,this.mouseY,a)})}},s=a=>{if(a instanceof MouseEvent&&!this.isTouch){let o=t.getBoundingClientRect();this.mouseX=a.clientX-o.left,this.mouseY=a.clientY-o.top,this.buttonDown=!1,this.listeners.map(c=>{c.up&&c.up(this.mouseX,this.mouseY,a)})}},r=a=>{this.autoPreventDefault&&a.preventDefault();let o=a.deltaY;a.deltaMode==WheelEvent.DOM_DELTA_LINE&&(o*=8),a.deltaMode==WheelEvent.DOM_DELTA_PAGE&&(o*=24),this.listeners.map(c=>{c.wheel&&c.wheel(a.deltaY,a)})},h=a=>{if(this.isTouch=!0,!this.touch0||!this.touch1){var o=a.changedTouches;let c=o.item(0);if(!c)return;let u=t.getBoundingClientRect(),d=c.clientX-u.left,m=c.clientY-u.top,f=new Ys(c.identifier,d,m);if(this.mouseX=d,this.mouseY=m,this.buttonDown=!0,!this.touch0)this.touch0=f,this.listeners.map(g=>{g.down&&g.down(f.x,f.y,a)});else if(!this.touch1){this.touch1=f;let g=this.touch1.x-this.touch0.x,w=this.touch1.x-this.touch0.x;this.initialPinchDistance=Math.sqrt(g*g+w*w),this.listeners.map(b=>{b.zoom&&b.zoom(this.initialPinchDistance,this.initialPinchDistance,a)})}}this.autoPreventDefault&&a.preventDefault()},l=a=>{if(this.isTouch=!0,this.touch0){var o=a.changedTouches;let d=t.getBoundingClientRect();for(var c=0;c{g.dragged&&g.dragged(m,f,a)})),this.touch1&&this.touch1.identifier===u.identifier&&(this.touch1.x=this.mouseX=m,this.touch1.y=this.mouseY=f)}if(this.touch0&&this.touch1){let m=this.touch1.x-this.touch0.x,f=this.touch1.x-this.touch0.x,g=Math.sqrt(m*m+f*f);this.listeners.map(w=>{w.zoom&&w.zoom(this.initialPinchDistance,g,a)})}}this.autoPreventDefault&&a.preventDefault()},n=a=>{if(this.isTouch=!0,this.touch0){var o=a.changedTouches;let d=t.getBoundingClientRect();for(var c=0;c{g.up&&g.up(m,f,a)}),this.touch1)this.touch0=this.touch1,this.touch1=null,this.mouseX=this.touch0.x,this.mouseX=this.touch0.x,this.buttonDown=!0,this.listeners.map(g=>{g.down&&g.down(this.touch0.x,this.touch0.y,a)});else{this.buttonDown=!1;break}this.touch1&&this.touch1.identifier&&(this.touch1=null)}}this.autoPreventDefault&&a.preventDefault()};return t.addEventListener("mousedown",e,!0),t.addEventListener("mousemove",i,!0),t.addEventListener("mouseup",s,!0),t.addEventListener("wheel",r,!0),t.addEventListener("touchstart",h,{passive:!1,capture:!1}),t.addEventListener("touchmove",l,{passive:!1,capture:!1}),t.addEventListener("touchend",n,{passive:!1,capture:!1}),t.addEventListener("touchcancel",n),{mouseDown:e,mouseMove:i,mouseUp:s,mouseWheel:r,touchStart:h,touchMove:l,touchEnd:n}}dispose(){const t=this.element;t.removeEventListener("mousedown",this.callbacks.mouseDown,!0),t.removeEventListener("mousemove",this.callbacks.mouseMove,!0),t.removeEventListener("mouseup",this.callbacks.mouseUp,!0),t.removeEventListener("wheel",this.callbacks.mouseWheel,!0),t.removeEventListener("touchstart",this.callbacks.touchStart,{capture:!1}),t.removeEventListener("touchmove",this.callbacks.touchMove,{capture:!1}),t.removeEventListener("touchend",this.callbacks.touchEnd,{capture:!1}),t.removeEventListener("touchcancel",this.callbacks.touchEnd),this.listeners.length=0}addListener(t){this.listeners.push(t)}removeListener(t){let e=this.listeners.indexOf(t);e>-1&&this.listeners.splice(e,1)}},Ys=class{constructor(t,e,i){this.identifier=t,this.x=e,this.y=i}},Qr=class{constructor(t,e){this.canvas=t,this.camera=e;let i=0,s=0,r=0,h=0,l=0,n=0,a=0,o=0;new nt(t).addListener({down:(c,u)=>{i=e.position.x,s=e.position.y,h=n=c,l=a=u,o=e.zoom},dragged:(c,u)=>{let d=c-h,m=u-l,f=e.screenToWorld(new ve(0,0),t.clientWidth,t.clientHeight),g=e.screenToWorld(new ve(d,m),t.clientWidth,t.clientHeight).sub(f);e.position.set(i-g.x,s-g.y,0),e.update(),n=c,a=u},wheel:c=>{let u=c/200*e.zoom,d=e.zoom+u;if(d>0){let m=0,f=0;if(c<0)m=n,f=a;else{let b=new ve(t.clientWidth/2+15,t.clientHeight/2),p=n-b.x,x=t.clientHeight-1-a-b.y;m=b.x-p,f=t.clientHeight-1-b.y+x}let g=e.screenToWorld(new ve(m,f),t.clientWidth,t.clientHeight);e.zoom=d,e.update();let w=e.screenToWorld(new ve(m,f),t.clientWidth,t.clientHeight);e.position.add(g.sub(w)),e.update()}},zoom:(c,u)=>{let d=c/u;e.zoom=o*d},up:(c,u)=>{n=c,a=u},moved:(c,u)=>{n=c,a=u}})}},ke=class de{constructor(e,i,s){this.vertexShader=i,this.fragmentShader=s,this.vsSource=i,this.fsSource=s,this.context=e instanceof ge?e:new ge(e),this.context.addRestorable(this),this.compile()}static MVP_MATRIX="u_projTrans";static POSITION="a_position";static COLOR="a_color";static COLOR2="a_color2";static TEXCOORDS="a_texCoords";static SAMPLER="u_texture";context;vs=null;vsSource;fs=null;fsSource;program=null;tmp2x2=new Float32Array(2*2);tmp3x3=new Float32Array(3*3);tmp4x4=new Float32Array(4*4);getProgram(){return this.program}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}getVertexShaderSource(){return this.vsSource}getFragmentSource(){return this.fsSource}compile(){let e=this.context.gl;try{if(this.vs=this.compileShader(e.VERTEX_SHADER,this.vertexShader),!this.vs)throw new Error("Couldn't compile vertex shader.");if(this.fs=this.compileShader(e.FRAGMENT_SHADER,this.fragmentShader),!this.fs)throw new Error("Couldn#t compile fragment shader.");this.program=this.compileProgram(this.vs,this.fs)}catch(i){throw this.dispose(),i}}compileShader(e,i){let s=this.context.gl,r=s.createShader(e);if(!r)throw new Error("Couldn't create shader.");if(s.shaderSource(r,i),s.compileShader(r),!s.getShaderParameter(r,s.COMPILE_STATUS)){let h="Couldn't compile shader: "+s.getShaderInfoLog(r);if(s.deleteShader(r),!s.isContextLost())throw new Error(h)}return r}compileProgram(e,i){let s=this.context.gl,r=s.createProgram();if(!r)throw new Error("Couldn't compile program.");if(s.attachShader(r,e),s.attachShader(r,i),s.linkProgram(r),!s.getProgramParameter(r,s.LINK_STATUS)){let h="Couldn't compile shader program: "+s.getProgramInfoLog(r);if(s.deleteProgram(r),!s.isContextLost())throw new Error(h)}return r}restore(){this.compile()}bind(){this.context.gl.useProgram(this.program)}unbind(){this.context.gl.useProgram(null)}setUniformi(e,i){this.context.gl.uniform1i(this.getUniformLocation(e),i)}setUniformf(e,i){this.context.gl.uniform1f(this.getUniformLocation(e),i)}setUniform2f(e,i,s){this.context.gl.uniform2f(this.getUniformLocation(e),i,s)}setUniform3f(e,i,s,r){this.context.gl.uniform3f(this.getUniformLocation(e),i,s,r)}setUniform4f(e,i,s,r,h){this.context.gl.uniform4f(this.getUniformLocation(e),i,s,r,h)}setUniform2x2f(e,i){let s=this.context.gl;this.tmp2x2.set(i),s.uniformMatrix2fv(this.getUniformLocation(e),!1,this.tmp2x2)}setUniform3x3f(e,i){let s=this.context.gl;this.tmp3x3.set(i),s.uniformMatrix3fv(this.getUniformLocation(e),!1,this.tmp3x3)}setUniform4x4f(e,i){let s=this.context.gl;this.tmp4x4.set(i),s.uniformMatrix4fv(this.getUniformLocation(e),!1,this.tmp4x4)}getUniformLocation(e){let i=this.context.gl;if(!this.program)throw new Error("Shader not compiled.");let s=i.getUniformLocation(this.program,e);if(!s&&!i.isContextLost())throw new Error(`Couldn't find location for uniform ${e}`);return s}getAttributeLocation(e){let i=this.context.gl;if(!this.program)throw new Error("Shader not compiled.");let s=i.getAttribLocation(this.program,e);if(s==-1&&!i.isContextLost())throw new Error(`Couldn't find location for attribute ${e}`);return s}dispose(){this.context.removeRestorable(this);let e=this.context.gl;this.vs&&(e.deleteShader(this.vs),this.vs=null),this.fs&&(e.deleteShader(this.fs),this.fs=null),this.program&&(e.deleteProgram(this.program),this.program=null)}static newColoredTextured(e){let i=` attribute vec4 ${de.POSITION}; attribute vec4 ${de.COLOR}; attribute vec2 ${de.TEXCOORDS}; uniform mat4 ${de.MVP_MATRIX}; varying vec4 v_color; varying vec2 v_texCoords; void main () { v_color = ${de.COLOR}; v_texCoords = ${de.TEXCOORDS}; gl_Position = ${de.MVP_MATRIX} * ${de.POSITION}; } `,s=` #ifdef GL_ES #define LOWP lowp precision mediump float; #else #define LOWP #endif varying LOWP vec4 v_color; varying vec2 v_texCoords; uniform sampler2D u_texture; void main () { gl_FragColor = v_color * texture2D(u_texture, v_texCoords); } `;return new de(e,i,s)}static newTwoColoredTextured(e){let i=` attribute vec4 ${de.POSITION}; attribute vec4 ${de.COLOR}; attribute vec4 ${de.COLOR2}; attribute vec2 ${de.TEXCOORDS}; uniform mat4 ${de.MVP_MATRIX}; varying vec4 v_light; varying vec4 v_dark; varying vec2 v_texCoords; void main () { v_light = ${de.COLOR}; v_dark = ${de.COLOR2}; v_texCoords = ${de.TEXCOORDS}; gl_Position = ${de.MVP_MATRIX} * ${de.POSITION}; } `,s=` #ifdef GL_ES #define LOWP lowp precision mediump float; #else #define LOWP #endif varying LOWP vec4 v_light; varying LOWP vec4 v_dark; varying vec2 v_texCoords; uniform sampler2D u_texture; void main () { vec4 texColor = texture2D(u_texture, v_texCoords); gl_FragColor.a = texColor.a * v_light.a; gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb; } `;return new de(e,i,s)}static newColored(e){let i=` attribute vec4 ${de.POSITION}; attribute vec4 ${de.COLOR}; uniform mat4 ${de.MVP_MATRIX}; varying vec4 v_color; void main () { v_color = ${de.COLOR}; gl_Position = ${de.MVP_MATRIX} * ${de.POSITION}; } `,s=` #ifdef GL_ES #define LOWP lowp precision mediump float; #else #define LOWP #endif varying LOWP vec4 v_color; void main () { gl_FragColor = v_color; } `;return new de(e,i,s)}},Bi=class{constructor(t,e,i,s){this.attributes=e,this.context=t instanceof ge?t:new ge(t),this.elementsPerVertex=0;for(let r=0;rthis.vertices.length)throw Error("Mesh can't store more than "+this.maxVertices()+" vertices");this.vertices.set(t,0),this.verticesLength=t.length}setIndices(t){if(this.dirtyIndices=!0,t.length>this.indices.length)throw Error("Mesh can't store more than "+this.maxIndices()+" indices");this.indices.set(t,0),this.indicesLength=t.length}draw(t,e){this.drawWithOffset(t,e,0,this.indicesLength>0?this.indicesLength:this.verticesLength/this.elementsPerVertex)}drawWithOffset(t,e,i,s){let r=this.context.gl;(this.dirtyVertices||this.dirtyIndices)&&this.update(),this.bind(t),this.indicesLength>0?r.drawElements(e,s,r.UNSIGNED_SHORT,i*2):r.drawArrays(e,i,s),this.unbind(t)}bind(t){let e=this.context.gl;e.bindBuffer(e.ARRAY_BUFFER,this.verticesBuffer);let i=0;for(let s=0;s0&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indicesBuffer)}unbind(t){let e=this.context.gl;for(let i=0;i0&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null)}update(){let t=this.context.gl;this.dirtyVertices&&(this.verticesBuffer||(this.verticesBuffer=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,this.verticesBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices.subarray(0,this.verticesLength),t.DYNAMIC_DRAW),this.dirtyVertices=!1),this.dirtyIndices&&(this.indicesBuffer||(this.indicesBuffer=t.createBuffer()),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indicesBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices.subarray(0,this.indicesLength),t.DYNAMIC_DRAW),this.dirtyIndices=!1)}restore(){this.verticesBuffer=null,this.indicesBuffer=null,this.update()}dispose(){this.context.removeRestorable(this);let t=this.context.gl;t.deleteBuffer(this.verticesBuffer),t.deleteBuffer(this.indicesBuffer)}},je=class{constructor(t,e,i){this.name=t,this.type=e,this.numElements=i}},wt=class extends je{constructor(){super(ke.POSITION,0,2)}},$r=class extends je{constructor(){super(ke.POSITION,0,3)}},Vi=class extends je{constructor(t=0){super(ke.TEXCOORDS+(t==0?"":t),0,2)}},xt=class extends je{constructor(){super(ke.COLOR,0,4)}},Fs=class extends je{constructor(){super(ke.COLOR2,0,4)}},Ls=(t=>(t[t.Float=0]="Float",t))(Ls||{}),Pe=1,en=769,Ps=770,Xs=771,Bs=774,Oi=class ze{static disableCulling=!1;context;drawCalls=0;static globalDrawCalls=0;isDrawing=!1;mesh;shader=null;lastTexture=null;verticesLength=0;indicesLength=0;srcColorBlend;srcAlphaBlend;dstBlend;cullWasEnabled=!1;constructor(e,i=!0,s=10920){if(s>10920)throw new Error("Can't have more than 10920 triangles per batch: "+s);this.context=e instanceof ge?e:new ge(e);let r=i?[new wt,new xt,new Vi,new Fs]:[new wt,new xt,new Vi];this.mesh=new Bi(e,r,s,s*3);let h=this.context.gl;this.srcColorBlend=h.SRC_ALPHA,this.srcAlphaBlend=h.ONE,this.dstBlend=h.ONE_MINUS_SRC_ALPHA}begin(e){if(this.isDrawing)throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()");this.drawCalls=0,this.shader=e,this.lastTexture=null,this.isDrawing=!0;let i=this.context.gl;i.enable(i.BLEND),i.blendFuncSeparate(this.srcColorBlend,this.dstBlend,this.srcAlphaBlend,this.dstBlend),ze.disableCulling&&(this.cullWasEnabled=i.isEnabled(i.CULL_FACE),this.cullWasEnabled&&i.disable(i.CULL_FACE))}static blendModesGL=[{srcRgb:Ps,srcRgbPma:Pe,dstRgb:Xs,srcAlpha:Pe},{srcRgb:Ps,srcRgbPma:Pe,dstRgb:Pe,srcAlpha:Pe},{srcRgb:Bs,srcRgbPma:Bs,dstRgb:Xs,srcAlpha:Pe},{srcRgb:Pe,srcRgbPma:Pe,dstRgb:en,srcAlpha:Pe}];setBlendMode(e,i){const s=ze.blendModesGL[e],r=i?s.srcRgbPma:s.srcRgb,h=s.srcAlpha,l=s.dstRgb;if(this.srcColorBlend==r&&this.srcAlphaBlend==h&&this.dstBlend==l)return;this.srcColorBlend=r,this.srcAlphaBlend=h,this.dstBlend=l,this.isDrawing&&this.flush(),this.context.gl.blendFuncSeparate(r,l,h,l)}draw(e,i,s){e!=this.lastTexture?(this.flush(),this.lastTexture=e):(this.verticesLength+i.length>this.mesh.getVertices().length||this.indicesLength+s.length>this.mesh.getIndices().length)&&this.flush();let r=this.mesh.numVertices();this.mesh.getVertices().set(i,this.verticesLength),this.verticesLength+=i.length,this.mesh.setVerticesLength(this.verticesLength);let h=this.mesh.getIndices();for(let l=this.indicesLength,n=0;n0||this.indicesLength>0)&&this.flush(),this.shader=null,this.lastTexture=null,this.isDrawing=!1;let e=this.context.gl;e.disable(e.BLEND),ze.disableCulling&&this.cullWasEnabled&&e.enable(e.CULL_FACE)}getDrawCalls(){return this.drawCalls}static getAndResetGlobalDrawCalls(){let e=ze.globalDrawCalls;return ze.globalDrawCalls=0,e}dispose(){this.mesh.dispose()}},Di=class{context;isDrawing=!1;mesh;shapeType=4;color=new V(1,1,1,1);shader=null;vertexIndex=0;tmp=new Ce;srcColorBlend;srcAlphaBlend;dstBlend;constructor(t,e=10920){if(e>10920)throw new Error("Can't have more than 10920 triangles per batch: "+e);this.context=t instanceof ge?t:new ge(t),this.mesh=new Bi(t,[new wt,new xt],e,0);let i=this.context.gl;this.srcColorBlend=i.SRC_ALPHA,this.srcAlphaBlend=i.ONE,this.dstBlend=i.ONE_MINUS_SRC_ALPHA}begin(t){if(this.isDrawing)throw new Error("ShapeRenderer.begin() has already been called");this.shader=t,this.vertexIndex=0,this.isDrawing=!0;let e=this.context.gl;e.enable(e.BLEND),e.blendFuncSeparate(this.srcColorBlend,this.dstBlend,this.srcAlphaBlend,this.dstBlend)}setBlendMode(t,e,i){this.srcColorBlend=t,this.srcAlphaBlend=e,this.dstBlend=i,this.isDrawing&&(this.flush(),this.context.gl.blendFuncSeparate(t,i,e,i))}setColor(t){this.color.setFromColor(t)}setColorWith(t,e,i,s){this.color.set(t,e,i,s)}point(t,e,i){this.check(0,1),i||(i=this.color),this.vertex(t,e,i)}line(t,e,i,s,r){this.check(1,2);let h=this.mesh.getVertices(),l=this.vertexIndex;r||(r=this.color),this.vertex(t,e,r),this.vertex(i,s,r)}triangle(t,e,i,s,r,h,l,n,a,o){this.check(t?4:1,3);let c=this.mesh.getVertices(),u=this.vertexIndex;n||(n=this.color),a||(a=this.color),o||(o=this.color),t?(this.vertex(e,i,n),this.vertex(s,r,a),this.vertex(h,l,o)):(this.vertex(e,i,n),this.vertex(s,r,a),this.vertex(s,r,n),this.vertex(h,l,a),this.vertex(h,l,n),this.vertex(e,i,a))}quad(t,e,i,s,r,h,l,n,a,o,c,u,d){this.check(t?4:1,3);let m=this.mesh.getVertices(),f=this.vertexIndex;o||(o=this.color),c||(c=this.color),u||(u=this.color),d||(d=this.color),t?(this.vertex(e,i,o),this.vertex(s,r,c),this.vertex(h,l,u),this.vertex(h,l,u),this.vertex(n,a,d),this.vertex(e,i,o)):(this.vertex(e,i,o),this.vertex(s,r,c),this.vertex(s,r,c),this.vertex(h,l,u),this.vertex(h,l,u),this.vertex(n,a,d),this.vertex(n,a,d),this.vertex(e,i,o))}rect(t,e,i,s,r,h){this.quad(t,e,i,e+s,i,e+s,i+r,e,i+r,h,h,h,h)}rectLine(t,e,i,s,r,h,l){this.check(t?4:1,8),l||(l=this.color);let n=this.tmp.set(r-i,e-s);n.normalize(),h*=.5;let a=n.x*h,o=n.y*h;t?(this.vertex(e+a,i+o,l),this.vertex(e-a,i-o,l),this.vertex(s+a,r+o,l),this.vertex(s-a,r-o,l),this.vertex(s+a,r+o,l),this.vertex(e-a,i-o,l)):(this.vertex(e+a,i+o,l),this.vertex(e-a,i-o,l),this.vertex(s+a,r+o,l),this.vertex(s-a,r-o,l),this.vertex(s+a,r+o,l),this.vertex(e+a,i+o,l),this.vertex(s-a,r-o,l),this.vertex(e-a,i-o,l))}x(t,e,i){this.line(t-i,e-i,t+i,e+i),this.line(t-i,e+i,t+i,e-i)}polygon(t,e,i,s){if(i<3)throw new Error("Polygon must contain at least 3 vertices");this.check(1,i*2),s||(s=this.color);let r=this.mesh.getVertices(),h=this.vertexIndex;e<<=1,i<<=1;let l=t[e],n=t[e+1],a=e+i;for(let o=e,c=e+i-2;o=a?(m=l,f=n):(m=t[o+2],f=t[o+3]),this.vertex(u,d,s),this.vertex(m,f,s)}}circle(t,e,i,s,r,h=0){if(h==0&&(h=Math.max(1,6*P.cbrt(s)|0)),h<=0)throw new Error("segments must be > 0.");r||(r=this.color);let l=2*P.PI/h,n=Math.cos(l),a=Math.sin(l),o=s,c=0;if(t){this.check(4,h*3+3),h--;for(let d=0;d0;)this.vertex(y,A,o),y+=C,A+=S,C+=k,S+=R,k+=Y,R+=F,this.vertex(y,A,o);this.vertex(y,A,o),this.vertex(l,n,o)}vertex(t,e,i){let s=this.vertexIndex,r=this.mesh.getVertices();r[s++]=t,r[s++]=e,r[s++]=i.r,r[s++]=i.g,r[s++]=i.b,r[s++]=i.a,this.vertexIndex=s}end(){if(!this.isDrawing)throw new Error("ShapeRenderer.begin() has not been called");this.flush();let t=this.context.gl;t.disable(t.BLEND),this.isDrawing=!1}flush(){if(this.vertexIndex!=0){if(!this.shader)throw new Error("No shader set.");this.mesh.setVerticesLength(this.vertexIndex),this.mesh.draw(this.shader,this.shapeType),this.vertexIndex=0}}check(t,e){if(!this.isDrawing)throw new Error("ShapeRenderer.begin() has not been called");if(this.shapeType==t)if(this.mesh.maxVertices()-this.mesh.numVertices()(t[t.Point=0]="Point",t[t.Line=1]="Line",t[t.Filled=4]="Filled",t))(Vs||{}),Os=class Zi{boneLineColor=new V(1,0,0,1);boneOriginColor=new V(0,1,0,1);attachmentLineColor=new V(0,0,1,.5);triangleLineColor=new V(1,.64,0,.5);pathColor=new V().setFromString("FF7F00");clipColor=new V(.8,0,0,2);aabbColor=new V(0,1,0,.5);drawBones=!0;drawRegionAttachments=!0;drawBoundingBoxes=!0;drawMeshHull=!0;drawMeshTriangles=!0;drawPaths=!0;drawSkeletonXY=!1;drawClipping=!0;premultipliedAlpha=!1;scale=1;boneWidth=2;context;bounds=new ks;temp=new Array;vertices=X.newFloatArray(2*1024);static LIGHT_GRAY=new V(192/255,192/255,192/255,1);static GREEN=new V(0,1,0,1);constructor(e){this.context=e instanceof ge?e:new ge(e)}draw(e,i,s){let r=i.x,h=i.y,l=this.context.gl,n=this.premultipliedAlpha?l.ONE:l.SRC_ALPHA;e.setBlendMode(n,l.ONE,l.ONE_MINUS_SRC_ALPHA);let a=i.bones;if(this.drawBones){e.setColor(this.boneLineColor);for(let o=0,c=a.length;o-1||!u.parent)continue;let d=u.data.length*u.a+u.worldX,m=u.data.length*u.c+u.worldY;e.rectLine(!0,u.worldX,u.worldY,d,m,this.boneWidth*this.scale)}this.drawSkeletonXY&&e.x(r,h,4*this.scale)}if(this.drawRegionAttachments){e.setColor(this.attachmentLineColor);let o=i.slots;for(let c=0,u=o.length;c0){e.setColor(this.attachmentLineColor),b=(b>>1)*2;let p=g[b-2],x=g[b-1];for(let v=0,y=b;v-1||e.circle(!0,u.worldX,u.worldY,3*this.scale,this.boneOriginColor,8)}}if(this.drawClipping){let o=i.slots;e.setColor(this.clipColor);for(let c=0,u=o.length;c=0&&s==y.data.index&&(b=!0),!b){l.clipEndWithSlot(y);continue}r>=0&&r==y.data.index&&(b=!1);let A=y.getAttachment(),C;if(A instanceof it){let S=A;c.vertices=this.vertices,c.numVertices=4,c.numFloats=v<<2,S.computeWorldVertices(y,c.vertices,0,v),d=sr.QUAD_TRIANGLES,u=S.uvs,C=S.region.texture,f=S.color}else if(A instanceof Ge){let S=A;c.vertices=this.vertices,c.numVertices=S.worldVerticesLength>>1,c.numFloats=c.numVertices*v,c.numFloats>c.vertices.length&&(c.vertices=this.vertices=X.newFloatArray(c.numFloats)),S.computeWorldVertices(y,0,S.worldVerticesLength,c.vertices,0,v),d=S.triangles,C=S.region.texture,u=S.uvs,f=S.color}else if(A instanceof tt){let S=A;l.clipStart(y,S);continue}else{l.clipEndWithSlot(y);continue}if(C){let S=y.color,k=this.tempColor;k.r=g.r*S.r*f.r,k.g=g.g*S.g*f.g,k.b=g.b*S.b*f.b,k.a=g.a*S.a*f.a,n&&(k.r*=k.a,k.g*=k.a,k.b*=k.a);let R=this.tempColor2;y.darkColor?(n?(R.r=y.darkColor.r*k.a,R.g=y.darkColor.g*k.a,R.b=y.darkColor.b*k.a):R.setFromColor(y.darkColor),R.a=n?1:0):R.set(0,0,0,1);let Y=y.data.blendMode;if(Y!=o&&(o=Y,e.setBlendMode(o,n)),l.isClipping()){l.clipTriangles(c.vertices,d,d.length,u,k,R,a);let F=new Float32Array(l.clippedVertices),L=l.clippedTriangles;h&&h(F,F.length,w),e.draw(C,F,L)}else{let F=c.vertices;if(a)for(let I=2,M=0,B=c.numFloats;I(t[t.Stretch=0]="Stretch",t[t.Expand=1]="Expand",t[t.Fit=2]="Fit",t))(Ns||{}),Ze,Ue,Ui=0,sn=1,Wi=1,yt=165,At=108,Ee=163,Us=class{renderer;logo=null;spinner=null;angle=0;fadeOut=0;fadeIn=0;timeKeeper=new ot;backgroundColor=new V(.135,.135,.135,1);tempColor=new V;constructor(t){if(this.renderer=t,this.timeKeeper.maxDelta=9,!Ue){let e=navigator.userAgent.indexOf("Safari")>-1,i=()=>Ui++;Ue=new Image,Ue.src=nn,e||(Ue.crossOrigin="anonymous"),Ue.onload=i,Ze=new Image,Ze.src=rn,e||(Ze.crossOrigin="anonymous"),Ze.onload=i}}dispose(){this.logo?.dispose(),this.spinner?.dispose()}draw(t=!1){if(Ui<2||t&&this.fadeOut>Wi)return;this.timeKeeper.update();let e=Math.abs(Math.sin(this.timeKeeper.totalTime+.25));this.angle-=this.timeKeeper.delta*200*(1+1.5*Math.pow(e,5));let i=this.tempColor,s=this.renderer,r=s.canvas,h=s.context.gl;if(s.resize(1),s.camera.position.set(r.width/2,r.height/2,0),s.batcher.setBlendMode(0,!0),t){if(this.fadeOut+=this.timeKeeper.delta*(this.timeKeeper.totalTime<1?2:1),this.fadeOut>Wi)return;i.setFromColor(this.backgroundColor),e=1-this.fadeOut/Wi,e=1-(e-1)*(e-1),i.a*=e,i.a>0&&(s.camera.zoom=1,s.begin(),s.quad(!0,0,0,r.width,0,r.width,r.height,0,r.height,i,i,i,i),s.end())}else this.fadeIn+=this.timeKeeper.delta,this.backgroundColor.a>0&&(h.clearColor(this.backgroundColor.r,this.backgroundColor.g,this.backgroundColor.b,this.backgroundColor.a),h.clear(h.COLOR_BUFFER_BIT)),e=1;e*=Math.min(this.fadeIn/sn,1),i.set(e,e,e,e),this.logo||(this.logo=new _e(s.context,Ue),this.spinner=new _e(s.context,Ze)),s.camera.zoom=Math.max(1,Ee/r.height),s.begin(),s.drawTexture(this.logo,(r.width-yt)/2,(r.height-At)/2,yt,At,i),this.spinner&&s.drawTextureRotated(this.spinner,(r.width-Ee)/2,(r.height-Ee)/2,Ee,Ee,Ee/2,Ee/2,this.angle,i),s.end()}drawInCoordinates(t,e){if(Ui<2)return;this.timeKeeper.update();let i=this.renderer;i.batcher.setBlendMode(0,!0),this.logo||(this.logo=new _e(i.context,Ue),this.spinner=new _e(i.context,Ze));const s=t-yt/2,r=e-At/2;i.drawTexture(this.logo,s,r,yt,At),this.angle-=this.timeKeeper.delta*500,this.spinner&&i.drawTextureRotated(this.spinner,s,r-25,Ee,Ee,Ee/2,Ee/2,this.angle)}},rn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKMAAACjCAYAAADmbK6AAAALKElEQVR42u2de2iW5R/GPzuqcwfnnKfNmafl5tTNHWzqNi3DEMQykcAoJSsySkspjSIk0iD/07Kf4R+FnVBDUTshZGpWUEJaaiWFgZlUFmXmIe3HNXthyebeZ77P9H13ffBG8Y8H7ut7vff93N/7fu4vGGPiFZiez/Qtw9lytJajfzfw9z/j+efPOv7cV8W+lUNY2a8T/ayTCRsWFLJA5rtUO1LLkV5p9LJeJizQiHeqnlOtmVFtdTGrrZkJCxYXsTgaI6r9MY4/UpNItW4mFDaXsTlaM6qVZlBq3UwofFrJp0HMWJ9DvXUzobCznJ1BzFjWlTLrZkJh/TDWBzFjTgo51s2EgnKI0Rrx+FiOWzNzVaym91Syx5qZsGBWb2ZFa0ZN6dbMhAWTcpkUrRmXD2K5NTNhgVbH0Zpxbl/mWjMTFvRIo0e0ZpzcncnWzISKtvmiMWNRJ4qslwmVXRXsas2Ix8ZwzFqZsGFREYtaM+Oaa1ljrUzYkJ9G/ok6TlzKjJWZVFor0y7c1Zu7WjLiqiGsskamXdHopyT4vALmzS9k/t19uHtKHlOSIMn6xAtARjIZ1sFcUS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llTS5OLlCIlIN1mS9mx/cZ5eLDALpCTI2RAhkTZQqYoTgpoCPECbaBHQ2ETL3PUl98ECAXYijG0OyYAmQoTG7W5ODkAF1CnVgm2JQx4okPA+gCMTbGskBGgRmaOblAh5GTORIrfKFx4VH4EIAxIXIxlg2SBbMvECY3e7oApbDaIgQu5/2HmeEKEINYiwSRi7EQkLFgumZOCuggctKGI4ULZN/vMeSLj0AYMytWEqMLzFg4fYDaoKaC6wvOFR4FkIPQFaILxrJAOsHsc/zlfYDWXE8qF22s8Pz5KHxcgEVALBtjJXBSSEOwFhk1Zgy4hitCT4hVw+gFs8/zwxqIBbUgyK7fcyA0PD9XX4iVxhiC0xdof6STWCsoBmKF7+cVCWFXQYyBMxRpf+STX1b0x45AhN0OMSrOGEirhrY/dfQAdjvS7oy+WCF6r1RIFxXWvlTRg1YVqFWBmxZbD99ig9pt0YPQw9rD1nstVri9V+/Ve3XrS/wfim4P5fIFxLoAAAAASUVORK5CYII=",an=class{constructor(t,e){this.config=e,e.pathPrefix||(e.pathPrefix=""),e.app||(e.app={loadAssets:()=>{},initialize:()=>{},update:()=>{},render:()=>{},error:()=>{},dispose:()=>{}}),e.webglConfig||(e.webglConfig={alpha:!0}),this.htmlCanvas=t,this.context=new ge(t,e.webglConfig),this.renderer=new Ni(t,this.context),this.gl=this.context.gl,this.assetManager=new Xi(this.context,e.pathPrefix),this.input=new nt(t),e.app.loadAssets&&e.app.loadAssets(this);let i=()=>{this.disposed||(requestAnimationFrame(i),this.time.update(),e.app.update&&e.app.update(this,this.time.delta),e.app.render&&e.app.render(this))},s=()=>{if(!this.disposed){if(this.assetManager.isLoadingComplete()){this.assetManager.hasErrors()?e.app.error&&e.app.error(this,this.assetManager.getErrors()):(e.app.initialize&&e.app.initialize(this),i());return}requestAnimationFrame(s)}};requestAnimationFrame(s)}context;time=new ot;htmlCanvas;gl;renderer;assetManager;input;disposed=!1;clear(t,e,i,s){this.gl.clearColor(t,e,i,s),this.gl.clear(this.gl.COLOR_BUFFER_BIT)}dispose(){this.config.app.dispose&&this.config.app.dispose(this),this.disposed=!0}},ln=class{constructor(t,e){this.config=e;let i=typeof t=="string"?document.getElementById(t):t;if(i==null)throw new Error("SpinePlayer parent not found: "+t);this.parent=i,e.showControls===void 0&&(e.showControls=!0);let s=e.showControls?`
`:"";this.parent.appendChild(this.dom=Ve(`
${s}
`));try{this.validateConfig(e)}catch(r){this.showError(r.message,r)}this.initialize(),this.addEventListener(window,"resize",()=>this.drawFrame(!1)),requestAnimationFrame(()=>this.drawFrame())}parent;dom;canvas=null;context=null;sceneRenderer=null;loadingScreen=null;assetManager=null;bg=new V;bgFullscreen=new V;playerControls=null;timelineSlider=null;playButton=null;skinButton=null;animationButton=null;playTime=0;selectedBones=[];cancelId=0;popup=null;error=!1;skeleton=null;animationState=null;paused=!0;speed=1;time=new ot;stopRequestAnimationFrame=!1;disposed=!1;viewport={};currentViewport={};previousViewport={};viewportTransitionStart=0;eventListeners=[];input;dispose(){this.sceneRenderer?.dispose(),this.loadingScreen?.dispose(),this.assetManager?.dispose(),this.context?.dispose();for(var t=0;t{this.pause();let w=this.animationState.getCurrent(0).animation.duration*f;this.animationState.update(w-this.playTime),this.animationState.apply(this.skeleton),this.skeleton.update(w-this.playTime),this.skeleton.updateWorldTransform(2),this.playTime=w},this.playButton.onclick=()=>this.paused?this.play():this.pause(),h.onclick=()=>this.showSpeedDialog(h),this.animationButton.onclick=()=>this.showAnimationsDialog(this.animationButton),this.skinButton.onclick=()=>this.showSkinsDialog(this.skinButton),l.onclick=()=>this.showSettingsDialog(l);let o=this.canvas.clientWidth,c=this.canvas.clientHeight,u=this.canvas.style.width,d=this.canvas.style.height,m=!1;n.onclick=()=>{let f=()=>{m=!m,m||(this.canvas.style.width=o+"px",this.canvas.style.height=c+"px",this.drawFrame(!1),requestAnimationFrame(()=>{this.canvas.style.width=u,this.canvas.style.height=d}))},g=e;g.onfullscreenchange=f,g.onwebkitfullscreenchange=f;let w=document;w.fullscreenElement||w.webkitFullscreenElement||w.mozFullScreenElement||w.msFullscreenElement?w.exitFullscreen?w.exitFullscreen():w.mozCancelFullScreen?w.mozCancelFullScreen():w.webkitExitFullscreen?w.webkitExitFullscreen():w.msExitFullscreen&&w.msExitFullscreen():(o=this.canvas.clientWidth,c=this.canvas.clientHeight,u=this.canvas.style.width,d=this.canvas.style.height,g.requestFullscreen?g.requestFullscreen():g.webkitRequestFullScreen?g.webkitRequestFullScreen():g.mozRequestFullScreen?g.mozRequestFullScreen():g.msRequestFullscreen&&g.msRequestFullscreen())},a.onclick=()=>window.open("http://esotericsoftware.com")}return e}loadSkeleton(){if(this.error)return;this.assetManager.hasErrors()&&this.showError(`Error: Assets could not be loaded. `+zi(this.assetManager.getErrors()));let t=this.config,e=this.assetManager.require(t.atlas),i=this.context.gl,s=i.getExtension("EXT_texture_filter_anisotropic"),r=i.getParameter(i.VERSION).indexOf("WebGL 1.0")!=-1;for(let c of e.pages){let u=c.minFilter;var h=t.mipmaps,l=P.isPowerOfTwo(c.width)&&P.isPowerOfTwo(c.height);r&&!l&&(h=!1),h&&(s?(i.texParameterf(i.TEXTURE_2D,s.TEXTURE_MAX_ANISOTROPY_EXT,8),u=9987):u=9729,c.texture.setFilters(u,9728)),u!=9728&&u!=9729&&c.texture.update(!0)}let n;try{let c,u,d=new gs(e);if(t.skeleton.endsWith(".json")){if(u=this.assetManager.remove(t.skeleton),!u)throw new Error("Empty JSON data.");if(t.jsonField&&(u=u[t.jsonField],!u))throw new Error("JSON field does not exist: "+t.jsonField);c=new Ms(d)}else u=this.assetManager.remove(t.skeleton),c=new Ss(d);c.scale=t.scale,n=c.readSkeletonData(u)}catch(c){this.showError(`Error: Could not load skeleton data. ${c.message}`,c);return}this.skeleton=new Ei(n);let a=new cs(n);a.defaultMix=t.defaultMix,this.animationState=new rs(a),t.controlBones.forEach(c=>{n.findBone(c)||this.showError(`Error: Control bone does not exist in skeleton: ${c}`)}),!t.skin&&n.skins.length&&(t.skin=n.skins[0].name),t.skins&&t.skin.length&&t.skins.forEach(c=>{this.skeleton.data.findSkin(c)||this.showError(`Error: Skin in config list does not exist in skeleton: ${c}`)}),t.skin&&(this.skeleton.data.findSkin(t.skin)||this.showError(`Error: Skin does not exist in skeleton: ${t.skin}`),this.skeleton.setSkinByName(t.skin),this.skeleton.setSlotsToSetupPose()),Object.getOwnPropertyNames(t.viewport.animations).forEach(c=>{n.findAnimation(c)||this.showError(`Error: Animation for which a viewport was specified does not exist in skeleton: ${c}`)}),t.animations&&t.animations.length&&(t.animations.forEach(c=>{this.skeleton.data.findAnimation(c)||this.showError(`Error: Animation in config list does not exist in skeleton: ${c}`)}),t.animation||(t.animation=t.animations[0])),t.animation&&!n.findAnimation(t.animation)&&this.showError(`Error: Animation does not exist in skeleton: ${t.animation}`),this.setupInput(),t.showControls&&((n.skins.length==1||t.skins&&t.skins.length==1)&&this.skinButton.classList.add("spine-player-hidden"),(n.animations.length==1||t.animations&&t.animations.length==1)&&this.animationButton.classList.add("spine-player-hidden")),t.success&&t.success(this);let o=this.animationState.getCurrent(0);o?(this.currentViewport.x===void 0&&this.setViewport(o.animation),t.animation||(t.animation=o.animation?.name),this.play()):t.animation?(o=this.setAnimation(t.animation),this.play()):(o=this.animationState.setEmptyAnimation(0),o.trackEnd=1e8,this.skeleton.updateWorldTransform(2),this.setViewport(o.animation),this.pause())}setupInput(){let t=this.config,e=t.controlBones;if(!e.length&&!t.showControls)return;let i=this.selectedBones=new Array(e.length),s=this.canvas,r=null,h=new Ce,l=new ve,n=new ve,a=new Ce,o=this.skeleton,c=this.sceneRenderer;if(t.interactive){let u=function(d,m){n.set(d,s.clientHeight-m,0),h.x=h.y=0;let f=24,g=0,w=null;for(let b=0;b{r=u(d,m)},up:()=>{r?r=null:t.showControls&&(this.paused?this.play():this.pause())},dragged:(d,m)=>{r&&(d=P.clamp(d+h.x,0,s.clientWidth),m=P.clamp(m-h.y,0,s.clientHeight),c.camera.screenToWorld(l.set(d,m,0),s.clientWidth,s.clientHeight),r.parent?(r.parent.worldToLocal(a.set(l.x-o.x,l.y-o.y)),r.x=a.x,r.y=a.y):(r.x=l.x-o.x,r.y=l.y-o.y))},moved:(d,m)=>u(d,m)})}if(t.showControls){this.addEventListener(document,"mousemove",g=>{g instanceof MouseEvent&&f(g.clientX,g.clientY)}),this.addEventListener(document,"touchmove",g=>{if(g instanceof TouchEvent){let w=g.changedTouches;if(w.length){let b=w[0];f(b.clientX,b.clientY)}}});let u=(g,w,b)=>{let p=g-b.left,x=w-b.top;return p>=0&&p<=b.width&&x>=0&&x<=b.height},d=!0,m=!1,f=(g,w)=>{let b=Xe(this.dom,"spine-player-popup");d=u(g,w,this.playerControls.getBoundingClientRect()),m=u(g,w,s.getBoundingClientRect()),clearTimeout(this.cancelId),!b&&!d&&!m&&!this.paused?this.playerControls.classList.add("spine-player-controls-hidden"):this.playerControls.classList.remove("spine-player-controls-hidden"),!d&&!b&&!this.paused&&(this.cancelId=setTimeout(()=>{this.paused||this.playerControls.classList.add("spine-player-controls-hidden")},1e3))}}}play(){this.paused=!1;let t=this.config;t.showControls&&(this.cancelId=setTimeout(()=>{this.paused||this.playerControls.classList.add("spine-player-controls-hidden")},1e3),this.playButton.classList.remove("spine-player-button-icon-play"),this.playButton.classList.add("spine-player-button-icon-pause"),t.animation||(t.animations&&t.animations.length?t.animation=t.animations[0]:this.skeleton.data.animations.length&&(t.animation=this.skeleton.data.animations[0].name),t.animation&&this.setAnimation(t.animation)))}pause(){this.paused=!0,this.config.showControls&&(this.playerControls.classList.remove("spine-player-controls-hidden"),clearTimeout(this.cancelId),this.playButton.classList.remove("spine-player-button-icon-pause"),this.playButton.classList.add("spine-player-button-icon-play"))}setAnimation(t,e=!0){return t=this.setViewport(t),this.animationState.setAnimationWith(0,t,e)}addAnimation(t,e=!0,i=0){return t=this.setViewport(t),this.animationState.addAnimationWith(0,t,e,i)}setViewport(t){if(typeof t=="string"){let r=this.skeleton.data.findAnimation(t);if(!r)throw new Error("Animation not found: "+t);t=r}this.previousViewport=this.currentViewport;let e=this.config.viewport,i=this.currentViewport={padLeft:e.padLeft!==void 0?e.padLeft:"10%",padRight:e.padRight!==void 0?e.padRight:"10%",padTop:e.padTop!==void 0?e.padTop:"10%",padBottom:e.padBottom!==void 0?e.padBottom:"10%"};e.x!==void 0&&e.y!==void 0&&e.width&&e.height?(i.x=e.x,i.y=e.y,i.width=e.width,i.height=e.height):this.calculateAnimationViewport(t,i);let s=this.config.viewport.animations[t.name];return s&&(s.x!==void 0&&s.y!==void 0&&s.width&&s.height&&(i.x=s.x,i.y=s.y,i.width=s.width,i.height=s.height),s.padLeft!==void 0&&(i.padLeft=s.padLeft),s.padRight!==void 0&&(i.padRight=s.padRight),s.padTop!==void 0&&(i.padTop=s.padTop),s.padBottom!==void 0&&(i.padBottom=s.padBottom)),i.padLeft=this.percentageToWorldUnit(i.width,i.padLeft),i.padRight=this.percentageToWorldUnit(i.width,i.padRight),i.padBottom=this.percentageToWorldUnit(i.height,i.padBottom),i.padTop=this.percentageToWorldUnit(i.height,i.padTop),this.viewportTransitionStart=performance.now(),t}percentageToWorldUnit(t,e){return typeof e=="string"?t*parseFloat(e.substr(0,e.length-1))/100:e}calculateAnimationViewport(t,e){this.skeleton.setToSetupPose();let i=100,s=t.duration?t.duration/i:0,r=0,h=1e8,l=-1e8,n=1e8,a=-1e8,o=new Ce,c=new Ce;const u=new Array(2);for(let d=0;dthis.drawFrame());let e=document,s=e.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement?this.bgFullscreen:this.bg;this.time.update();let r=this.time.delta,h=!this.assetManager.isLoadingComplete();!this.skeleton&&!h&&this.loadSkeleton();let l=this.skeleton,n=this.config;if(l){let a=this.sceneRenderer;a.resize(1);let o=this.paused?0:r*this.speed;if(n.frame&&n.frame(this,o),!this.paused&&(l.update(o),this.animationState.update(o),this.animationState.apply(l),n.updateWorldTransform?n.updateWorldTransform(this,o):l.updateWorldTransform(2),n.showControls)){this.playTime+=o;let f=this.animationState.getCurrent(0);if(f){let g=f.animation.duration;for(;this.playTime>=g&&g!=0;)this.playTime-=g;this.playTime=Math.max(0,Math.min(this.playTime,g)),this.timelineSlider.setValue(this.playTime/g)}}let c=this.viewport;if(c.x=this.currentViewport.x-this.currentViewport.padLeft,c.y=this.currentViewport.y-this.currentViewport.padBottom,c.width=this.currentViewport.width+this.currentViewport.padLeft+this.currentViewport.padRight,c.height=this.currentViewport.height+this.currentViewport.padBottom+this.currentViewport.padTop,this.previousViewport){let f=(performance.now()-this.viewportTransitionStart)/1e3/n.viewport.transitionTime;if(f<1){let g=this.previousViewport.x-this.previousViewport.padLeft,w=this.previousViewport.y-this.previousViewport.padBottom,b=this.previousViewport.width+this.previousViewport.padLeft+this.previousViewport.padRight,p=this.previousViewport.height+this.previousViewport.padBottom+this.previousViewport.padTop;c.x=g+(c.x-g)*f,c.y=w+(c.y-w)*f,c.width=b+(c.width-b)*f,c.height=p+(c.height-p)*f}}a.camera.zoom=this.canvas.height/this.canvas.width>c.height/c.width?c.width/this.canvas.width:c.height/this.canvas.height,a.camera.position.x=c.x+c.width/2,a.camera.position.y=c.y+c.height/2;let u=this.context.gl;u.clearColor(s.r,s.g,s.b,s.a),u.clear(u.COLOR_BUFFER_BIT),n.update&&n.update(this,o),a.begin();let d=n.backgroundImage;if(d){let f=this.assetManager.require(d.url);d.x!==void 0&&d.y!==void 0&&d.width&&d.height?a.drawTexture(f,d.x,d.y,d.width,d.height):a.drawTexture(f,c.x,c.y,c.width,c.height)}a.drawSkeleton(l,n.premultipliedAlpha),Number(a.skeletonDebugRenderer.drawBones=n.debug.bones??!1)+Number(a.skeletonDebugRenderer.drawBoundingBoxes=n.debug.bounds??!1)+Number(a.skeletonDebugRenderer.drawClipping=n.debug.clipping??!1)+Number(a.skeletonDebugRenderer.drawMeshHull=n.debug.hulls??!1)+Number(a.skeletonDebugRenderer.drawPaths=n.debug.paths??!1)+Number(a.skeletonDebugRenderer.drawRegionAttachments=n.debug.regions??!1)+Number(a.skeletonDebugRenderer.drawMeshTriangles=n.debug.meshes??!1)>0&&a.drawSkeletonDebug(l,n.premultipliedAlpha);let m=n.controlBones;if(m.length){let f=this.selectedBones;u.lineWidth(2);for(let g=0;gthis.drawFrame())}stopRendering(){this.stopRequestAnimationFrame=!0}hidePopup(t){return this.popup!=null&&this.popup.hide(t)}showSpeedDialog(t){let e="speed";if(this.hidePopup(e))return;let i=new Ct(e,t,this,this.playerControls,`
Speed

0.1x
1x
2x
`),s=new Ws(2,.1,!0);Xe(i.dom,"spine-player-speed-slider").appendChild(s.create()),s.setValue(this.speed/2),s.change=r=>this.speed=r*2,i.show()}showAnimationsDialog(t){let e="animations";if(this.hidePopup(e)||!this.skeleton||!this.skeleton.data.animations.length)return;let i=new Ct(e,t,this,this.playerControls,'
Animations

    '),s=Xe(i.dom,"spine-player-list");this.skeleton.data.animations.forEach(r=>{if(this.config.animations&&this.config.animations.indexOf(r.name)<0)return;let h=Ve('
  • ');r.name==this.config.animation&&h.classList.add("selected"),Xe(h,"selectable-text").innerText=r.name,s.appendChild(h),h.onclick=()=>{zs(s.children,"selected"),h.classList.add("selected"),this.config.animation=r.name,this.playTime=0,this.setAnimation(r.name),this.play()}}),i.show()}showSkinsDialog(t){let e="skins";if(this.hidePopup(e)||!this.skeleton||!this.skeleton.data.animations.length)return;let i=new Ct(e,t,this,this.playerControls,'
    Skins

      '),s=Xe(i.dom,"spine-player-list");this.skeleton.data.skins.forEach(r=>{if(this.config.skins&&this.config.skins.indexOf(r.name)<0)return;let h=Ve('
    • ');r.name==this.config.skin&&h.classList.add("selected"),Xe(h,"selectable-text").innerText=r.name,s.appendChild(h),h.onclick=()=>{zs(s.children,"selected"),h.classList.add("selected"),this.config.skin=r.name,this.skeleton.setSkinByName(this.config.skin),this.skeleton.setSlotsToSetupPose()}}),i.show()}showSettingsDialog(t){let e="settings";if(this.hidePopup(e)||!this.skeleton||!this.skeleton.data.animations.length)return;let i=new Ct(e,t,this,this.playerControls,'
      Debug

        '),s=Xe(i.dom,"spine-player-list"),r=(h,l)=>{let n=Ve('
      • '),a=new on(h);n.appendChild(a.create());let o=this.config.debug;a.setEnabled(o[l]),a.change=c=>o[l]=c,s.appendChild(n)};r("Bones","bones"),r("Regions","regions"),r("Meshes","meshes"),r("Bounds","bounds"),r("Paths","paths"),r("Clipping","clipping"),r("Points","points"),r("Hulls","hulls"),i.show()}showError(t,e){if(this.error){if(e)throw e}else{throw this.error=!0,this.dom.appendChild(Ve('
        '+t.replace(` `,"

        ")+"
        ")),this.config.error&&this.config.error(this,t),e||new Error(t);console.log(e)}}},Ct=class{constructor(t,e,i,s,r){this.id=t,this.button=e,this.player=i,this.dom=Ve('
        '),this.dom.innerHTML=r,s.appendChild(this.dom),this.className="spine-player-button-icon-"+t+"-selected"}dom;className;windowClickListener;dispose(){}hide(t){return this.dom.remove(),this.button.classList.remove(this.className),this.id==t?(this.player.popup=null,!0):!1}show(){this.player.popup=this,this.button.classList.add(this.className),this.dom.classList.remove("spine-player-hidden");let t=!1,e=()=>{t||requestAnimationFrame(e);let r=this.player.dom,h=Math.abs(r.getBoundingClientRect().bottom-r.getBoundingClientRect().bottom),l=Math.abs(r.getBoundingClientRect().right-r.getBoundingClientRect().right);this.dom.style.maxHeight=r.clientHeight-h-l+"px"};requestAnimationFrame(e);let i=!0,s=r=>{if(i||this.player.popup!=this){i=!1;return}this.dom.contains(r.target)||(this.dom.remove(),window.removeEventListener("click",s),this.button.classList.remove(this.className),this.player.popup=null,t=!0)};this.player.addEventListener(window,"click",s)}},on=class{constructor(t){this.text=t}switch=null;enabled=!1;change=()=>{};create(){return this.switch=Ve(`
        ${this.text}
        `),this.switch.addEventListener("click",()=>{this.setEnabled(!this.enabled),this.change&&this.change(this.enabled)}),this.switch}setEnabled(t){t?this.switch?.classList.add("active"):this.switch?.classList.remove("active"),this.enabled=t}isEnabled(){return this.enabled}},Ws=class{constructor(t=0,e=.1,i=!1){this.snaps=t,this.snapPercentage=e,this.big=i}slider=null;value=null;knob=null;change=()=>{};create(){this.slider=Ve(`
        `),this.value=Xe(this.slider,"spine-player-slider-value"),this.setValue(0);let t=!1;return new nt(this.slider).addListener({down:(e,i)=>{t=!0,this.value?.classList.add("hovering")},up:(e,i)=>{t=!1,this.change&&this.change(this.setValue(e/this.slider.clientWidth)),this.value?.classList.remove("hovering")},moved:(e,i)=>{t&&this.change&&this.change(this.setValue(e/this.slider.clientWidth))},dragged:(e,i)=>{this.change&&this.change(this.setValue(e/this.slider.clientWidth))}}),this.slider}setValue(t){if(t=Math.max(0,Math.min(1,t)),this.snaps){let e=1/this.snaps,i=t%e;ie-e*this.snapPercentage&&(t=t-i+e),t=Math.max(0,Math.min(1,t))}return this.value.style.width=""+t*100+"%",t}};function Xe(t,e){return t.getElementsByClassName(e)[0]}function Ve(t){let e=document.createElement("div");return e.innerHTML=t,e.children[0]}function zs(t,e){for(let i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}var hn=new V(.478,0,0,.25),cn=new V(1,1,1,1),dn=new V(.478,0,0,.5),un=new V(1,0,0,.8);function fn(t){return new Promise((e,i)=>{const s=document.createElement("script");s.src=t,s.onload=()=>e(),s.onerror=()=>i(new Error(`Script load error for ${t}`)),document.head.appendChild(s)})}function mn(t){return new Promise((e,i)=>{const s=document.createElement("link");s.href=t,s.rel="stylesheet",s.onload=()=>e(),s.onerror=()=>i(new Error(`CSS load error for ${t}`)),document.head.appendChild(s)})}var gn=class rr{constructor(e){this.parent=e,this.load()}static DEFAULT_CODE=`