UNPKG

@esotericsoftware/spine-pixi-v8

Version:
28 lines 227 kB
"use strict";var spine=(()=>{var es=Object.defineProperty,ii=Object.getOwnPropertyDescriptor,ri=Object.getOwnPropertyNames,oi=Object.prototype.hasOwnProperty,Rt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,s)=>(typeof require<"u"?require:t)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),ai=(e,t)=>{for(var s in t)es(e,s,{get:t[s],enumerable:!0})},li=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ri(t))!oi.call(e,i)&&i!==s&&es(e,i,{get:()=>t[i],enumerable:!(n=ii(t,i))||n.enumerable});return e},ci=e=>li(es({},"__esModule",{value:!0}),e),dn={};if(ai(dn,{AABBRectangleBoundsProvider:()=>Cr,AlphaTimeline:()=>ws,Animation:()=>Ie,AnimationState:()=>Os,AnimationStateAdapter:()=>xi,AnimationStateData:()=>vn,AssetCache:()=>Tn,AssetManagerBase:()=>bi,AtlasAttachmentLoader:()=>An,Attachment:()=>rs,AttachmentTimeline:()=>ee,BinaryInput:()=>En,BlendMode:()=>It,Bone:()=>Ee,BoneData:()=>qs,BonePose:()=>Re,BoneTimeline1:()=>Nt,BoneTimeline2:()=>ke,BoundingBoxAttachment:()=>Us,ClippingAttachment:()=>Bt,Color:()=>$,Constraint:()=>ne,ConstraintData:()=>ie,ConstraintTimeline1:()=>se,CurveTimeline:()=>Dt,CurveTimeline1:()=>fe,DebugUtils:()=>fi,DeformTimeline:()=>Ts,Downloader:()=>Sn,DrawOrder:()=>Pn,DrawOrderFolderTimeline:()=>pe,DrawOrderTimeline:()=>Wt,Event:()=>Be,EventData:()=>Ws,EventQueue:()=>wn,EventTimeline:()=>Me,EventType:()=>ft,FIRST:()=>ge,FakeTexture:()=>pi,FromProperty:()=>Gt,FromRotate:()=>Ue,FromScaleX:()=>ze,FromScaleY:()=>We,FromShearY:()=>Ge,FromX:()=>qe,FromY:()=>$e,HOLD:()=>xe,HOLD_FIRST:()=>yn,IkConstraint:()=>In,IkConstraintData:()=>we,IkConstraintPose:()=>Xe,IkConstraintTimeline:()=>Cs,Inherit:()=>et,InheritTimeline:()=>gs,IntSet:()=>hi,Interpolation:()=>he,MathUtils:()=>X,MeshAttachment:()=>pt,PathAttachment:()=>be,PathConstraint:()=>kn,PathConstraintData:()=>ye,PathConstraintMixTimeline:()=>ks,PathConstraintPose:()=>Le,PathConstraintPositionTimeline:()=>Ps,PathConstraintSpacingTimeline:()=>Is,Physics:()=>vt,PhysicsConstraint:()=>Gs,PhysicsConstraintDampingTimeline:()=>Ys,PhysicsConstraintData:()=>ve,PhysicsConstraintGravityTimeline:()=>Bs,PhysicsConstraintInertiaTimeline:()=>Ms,PhysicsConstraintMassTimeline:()=>Rs,PhysicsConstraintMixTimeline:()=>Xs,PhysicsConstraintPose:()=>Ve,PhysicsConstraintResetTimeline:()=>Ls,PhysicsConstraintStrengthTimeline:()=>Fs,PhysicsConstraintTimeline:()=>Et,PhysicsConstraintWindTimeline:()=>Es,PointAttachment:()=>Cn,Pool:()=>te,Posed:()=>$s,PosedActive:()=>zs,PosedData:()=>Ye,PositionMode:()=>Tt,Pow:()=>fn,PowOut:()=>di,Property:()=>W,RETAIN:()=>Ns,RGB2Timeline:()=>vs,RGBA2Timeline:()=>ys,RGBATimeline:()=>xs,RGBTimeline:()=>bs,RegionAttachment:()=>H,RotateMode:()=>Ut,RotateTimeline:()=>ue,SETUP:()=>Ds,SUBSEQUENT:()=>Fe,ScaleTimeline:()=>hs,ScaleXTimeline:()=>ds,ScaleYMode:()=>ct,ScaleYTimeline:()=>fs,Sequence:()=>de,SequenceMode:()=>ot,SequenceModeValues:()=>os,SequenceTimeline:()=>Ss,SetupPoseBoundsProvider:()=>Ar,ShearTimeline:()=>us,ShearXTimeline:()=>ms,ShearYTimeline:()=>ps,Skeleton:()=>re,SkeletonBinary:()=>Rn,SkeletonBounds:()=>sn,SkeletonClipping:()=>Se,SkeletonData:()=>De,SkeletonJson:()=>Vn,SkeletonRendererCore:()=>or,Skin:()=>Te,SkinEntry:()=>Hs,SkinsAndAnimationBoundsProvider:()=>Pr,Slider:()=>Fn,SliderData:()=>qt,SliderMixTimeline:()=>_s,SliderPose:()=>Oe,SliderTimeline:()=>Vs,Slot:()=>Mn,SlotCurveTimeline:()=>me,SlotData:()=>js,SlotPose:()=>_e,SpacingMode:()=>nt,Spine:()=>Ir,SpineDebugRenderer:()=>kr,SpinePipe:()=>Dn,SpineTexture:()=>rn,StringSet:()=>ss,Texture:()=>ns,TextureAtlas:()=>Pe,TextureAtlasPage:()=>mn,TextureAtlasRegion:()=>is,TextureFilter:()=>it,TextureRegion:()=>un,TextureWrap:()=>Pt,TimeKeeper:()=>ui,Timeline:()=>tt,ToProperty:()=>Ht,ToRotate:()=>Js,ToScaleX:()=>Zs,ToScaleY:()=>tn,ToShearY:()=>en,ToX:()=>Ks,ToY:()=>Qs,TrackEntry:()=>bn,TransformConstraint:()=>Yn,TransformConstraintData:()=>K,TransformConstraintPose:()=>Ne,TransformConstraintTimeline:()=>As,TranslateTimeline:()=>as,TranslateXTimeline:()=>ls,TranslateYTimeline:()=>cs,Triangulator:()=>Ln,Utils:()=>L,Vector2:()=>Ae,VertexAttachment:()=>Ot,WindowedMean:()=>mi,isBoneTimeline:()=>gn,isConstraintTimeline:()=>xn,isSlotTimeline:()=>pn}),typeof window<"u"&&window.PIXI){const e=window.require;window.require=t=>{if(e)return e(t);if(t.startsWith("@pixi/")||t.startsWith("pixi.js"))return window.PIXI}}var hi=class{array=[];add(e){const t=this.contains(e);return this.array[e|0]=e|0,!t}contains(e){return this.array[e|0]!==void 0}remove(e){this.array[e|0]=void 0}clear(){this.array.length=0}},ss=class{entries={};size=0;add(e){const t=this.entries[e];return this.entries[e]=!0,t?!1:(this.size++,!0)}addAll(e){const t=this.size;for(let s=0,n=e.length;s<n;s++)this.add(e[s]);return t!==this.size}contains(e){return this.entries[e]}clear(){this.entries={},this.size=0}},$=class Kt{r;g;b;a;static WHITE=new Kt(1,1,1,1);static RED=new Kt(1,0,0,1);static GREEN=new Kt(0,1,0,1);static BLUE=new Kt(0,0,1,1);static MAGENTA=new Kt(1,0,1,1);constructor(t=0,s=0,n=0,i=0){this.r=t,this.g=s,this.b=n,this.a=i}set(t,s,n,i){return this.r=t,this.g=s,this.b=n,this.a=i,this.clamp()}setFromColor(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}setFromString(t){return t=t.charAt(0)==="#"?t.substr(1):t,this.r=parseInt(t.substr(0,2),16)/255,this.g=parseInt(t.substr(2,2),16)/255,this.b=parseInt(t.substr(4,2),16)/255,this.a=t.length!==8?1:parseInt(t.substr(6,2),16)/255,this}add(t,s,n,i){return this.r+=t,this.g+=s,this.b+=n,this.a+=i,this.clamp()}clamp(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this}static rgba8888ToColor(t,s){t.r=((s&4278190080)>>>24)/255,t.g=((s&16711680)>>>16)/255,t.b=((s&65280)>>>8)/255,t.a=(s&255)/255}static rgb888ToColor(t,s){t.r=((s&16711680)>>>16)/255,t.g=((s&65280)>>>8)/255,t.b=(s&255)/255}toRgb888(){const t=s=>`0${(s*255).toString(16)}`.slice(-2);return+`0x${t(this.r)}${t(this.g)}${t(this.b)}`}static fromString(t,s=new Kt){return s.setFromString(t)}},X=class wt{static epsilon=1e-5;static epsilon2=wt.epsilon*wt.epsilon;static PI=3.1415927;static PI2=wt.PI*2;static invPI2=1/wt.PI2;static radiansToDegrees=180/wt.PI;static radDeg=wt.radiansToDegrees;static degreesToRadians=wt.PI/180;static degRad=wt.degreesToRadians;static clamp(t,s,n){return t<s?s:t>n?n:t}static cosDeg(t){return Math.cos(t*wt.degRad)}static sinDeg(t){return Math.sin(t*wt.degRad)}static atan2Deg(t,s){return Math.atan2(t,s)*wt.radDeg}static signum(t){return t>0?1:t<0?-1:0}static toInt(t){return t>0?Math.floor(t):Math.ceil(t)}static cbrt(t){const s=Math.pow(Math.abs(t),.3333333333333333);return t<0?-s:s}static randomTriangular(t,s){return wt.randomTriangularWith(t,s,(t+s)*.5)}static randomTriangularWith(t,s,n){const i=Math.random(),r=s-t;return i<=(n-t)/r?t+Math.sqrt(i*r*(n-t)):s-Math.sqrt((1-i)*r*(s-n))}static isPowerOfTwo(t){return t&&(t&t-1)===0}},he=class le{static linear=new class extends le{applyInternal(t){return t}};static smooth=new class extends le{applyInternal(t){return t*t*(3-2*t)}};static slowFast=new class extends le{applyInternal(t){return t*t}};static fastSlow=new class extends le{applyInternal(t){return(t-1)*(t-1)*-1+1}};static circle=new class extends le{applyInternal(t){return t<=.5?(t*=2,(1-Math.sqrt(1-t*t))/2):(t--,t*=2,(Math.sqrt(1-t*t)+1)/2)}};apply(t,s,n){return s===void 0||n===void 0?this.applyInternal(t):t+(s-t)*this.applyInternal(n)}},fn=class extends he{power=2;constructor(e){super(),this.power=e}applyInternal(e){return e<=.5?Math.pow(e*2,this.power)/2:Math.pow((e-1)*2,this.power)/(this.power%2===0?-2:2)+1}},di=class extends fn{constructor(e){super(e)}applyInternal(e){return Math.pow(e-1,this.power)*(this.power%2===0?-1:1)+1}},L=class ce{static SUPPORTS_TYPED_ARRAYS=typeof Float32Array<"u";static arrayCopy(t,s,n,i,r){for(let c=s,l=i;c<s+r;c++,l++)n[l]=t[c]}static arrayFill(t,s,n,i){for(let r=s;r<n;r++)t[r]=i}static setArraySize(t,s,n=0){const i=t.length;if(i===s)return t;if(t.length=s,i<s)for(let r=i;r<s;r++)t[r]=n;return t}static ensureArrayCapacity(t,s,n=0){return t.length>=s?t:ce.setArraySize(t,s,n)}static newArray(t,s){const n=[];for(let i=0;i<t;i++)n[i]=s;return n}static newFloatArray(t){if(ce.SUPPORTS_TYPED_ARRAYS)return new Float32Array(t);{const s=[];for(let n=0;n<s.length;n++)s[n]=0;return s}}static newShortArray(t){if(ce.SUPPORTS_TYPED_ARRAYS)return new Int16Array(t);{const s=[];for(let n=0;n<s.length;n++)s[n]=0;return s}}static toFloatArray(t){return ce.SUPPORTS_TYPED_ARRAYS?new Float32Array(t):t}static toSinglePrecision(t){return ce.SUPPORTS_TYPED_ARRAYS?Math.fround(t):t}static webkit602BugfixHelper(t){}static contains(t,s,n=!0){for(let i=0;i<t.length;i++)if(t[i]===s)return!0;return!1}static enumValue(t,s){return t[s[0].toUpperCase()+s.slice(1)]}},fi=class{static logBones(e){for(let t=0;t<e.bones.length;t++){const s=e.bones[t].appliedPose;console.log(`${s.bone.data.name}, ${s.a}, ${s.b}, ${s.c}, ${s.d}, ${s.worldX}, ${s.worldY}`)}}},te=class{items=[];instantiator;constructor(e){this.instantiator=e}obtain(){return this.items.length>0?this.items.pop():this.instantiator()}free(e){e.reset?.(),this.items.push(e)}freeAll(e){for(let t=0;t<e.length;t++)this.free(e[t])}clear(){this.items.length=0}},Ae=class{x;y;constructor(e=0,t=0){this.x=e,this.y=t}set(e,t){return this.x=e,this.y=t,this}length(){const e=this.x,t=this.y;return Math.sqrt(e*e+t*t)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}},ui=class{maxDelta=.064;framesPerSecond=0;delta=0;totalTime=0;lastTime=Date.now()/1e3;frameCount=0;frameTime=0;update(){const e=Date.now()/1e3;this.delta=e-this.lastTime,this.frameTime+=this.delta,this.totalTime+=this.delta,this.delta>this.maxDelta&&(this.delta=this.maxDelta),this.lastTime=e,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)}},mi=class{values;addedValues=0;lastValue=0;mean=0;dirty=!0;constructor(e=32){this.values=new Array(e)}hasEnoughData(){return this.addedValues>=this.values.length}addValue(e){this.addedValues<this.values.length&&this.addedValues++,this.values[this.lastValue++]=e,this.lastValue>this.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let e=0;for(let t=0;t<this.values.length;t++)e+=this.values[t];this.mean=e/this.values.length,this.dirty=!1}return this.mean}return 0}},ns=class{_image;constructor(e){this._image=e}getImage(){return this._image}},it;(function(e){e[e.Nearest=9728]="Nearest",e[e.Linear=9729]="Linear",e[e.MipMap=9987]="MipMap",e[e.MipMapNearestNearest=9984]="MipMapNearestNearest",e[e.MipMapLinearNearest=9985]="MipMapLinearNearest",e[e.MipMapNearestLinear=9986]="MipMapNearestLinear",e[e.MipMapLinearLinear=9987]="MipMapLinearLinear"})(it||(it={}));var Pt;(function(e){e[e.MirroredRepeat=33648]="MirroredRepeat",e[e.ClampToEdge=33071]="ClampToEdge",e[e.Repeat=10497]="Repeat"})(Pt||(Pt={}));var un=class{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0},pi=class extends ns{setFilters(e,t){}setWraps(e,t){}dispose(){}},Pe=class{pages=[];regions=[];constructor(e){const t=new gi(e),s=new Array(4),n={};n.size=o=>{o.width=parseInt(s[1]),o.height=parseInt(s[2])},n.format=()=>{},n.filter=o=>{o.minFilter=L.enumValue(it,s[1]),o.magFilter=L.enumValue(it,s[2])},n.repeat=o=>{s[1].indexOf("x")!==-1&&(o.uWrap=Pt.Repeat),s[1].indexOf("y")!==-1&&(o.vWrap=Pt.Repeat)},n.pma=o=>{o.pma=s[1]==="true"};var i={};i.xy=o=>{o.x=parseInt(s[1]),o.y=parseInt(s[2])},i.size=o=>{o.width=parseInt(s[1]),o.height=parseInt(s[2])},i.bounds=o=>{o.x=parseInt(s[1]),o.y=parseInt(s[2]),o.width=parseInt(s[3]),o.height=parseInt(s[4])},i.offset=o=>{o.offsetX=parseInt(s[1]),o.offsetY=parseInt(s[2])},i.orig=o=>{o.originalWidth=parseInt(s[1]),o.originalHeight=parseInt(s[2])},i.offsets=o=>{o.offsetX=parseInt(s[1]),o.offsetY=parseInt(s[2]),o.originalWidth=parseInt(s[3]),o.originalHeight=parseInt(s[4])},i.rotate=o=>{const h=s[1];h==="true"?o.degrees=90:h!=="false"&&(o.degrees=parseInt(h))},i.index=o=>{o.index=parseInt(s[1])};let r=t.readLine();for(;r&&r.trim().length===0;)r=t.readLine();for(;!(!r||r.trim().length===0||t.readEntry(s,r)===0);)r=t.readLine();let c=null,l=null,a=null;for(;r!==null;)if(r.trim().length===0)c=null,r=t.readLine();else if(c){const o=new is(c,r);for(;;){const h=t.readEntry(s,r=t.readLine());if(h===0)break;const d=i[s[0]];if(d)d(o);else{l||(l=[]),a||(a=[]),l.push(s[0]);const f=[];for(let u=0;u<h;u++)f.push(parseInt(s[u+1]));a.push(f)}}o.originalWidth===0&&o.originalHeight===0&&(o.originalWidth=o.width,o.originalHeight=o.height),l&&l.length>0&&a&&a.length>0&&(o.names=l,o.values=a,l=null,a=null),o.u=o.x/c.width,o.v=o.y/c.height,o.degrees===90?(o.u2=(o.x+o.height)/c.width,o.v2=(o.y+o.width)/c.height):(o.u2=(o.x+o.width)/c.width,o.v2=(o.y+o.height)/c.height),this.regions.push(o)}else{for(c=new mn(r.trim());t.readEntry(s,r=t.readLine())!==0;){const o=n[s[0]];o&&o(c)}this.pages.push(c)}}findRegion(e){for(let t=0;t<this.regions.length;t++)if(this.regions[t].name===e)return this.regions[t];return null}setTextures(e,t=""){for(const s of this.pages)s.setTexture(e.get(t+s.name))}dispose(){for(let e=0;e<this.pages.length;e++)this.pages[e].texture?.dispose()}},gi=class{lines;index=0;constructor(e){this.lines=e.split(/\r\n|\r|\n/)}readLine(){return this.index>=this.lines.length?null:this.lines[this.index++]}readEntry(e,t){if(!t||(t=t.trim(),t.length===0))return 0;const s=t.indexOf(":");if(s===-1)return 0;e[0]=t.substr(0,s).trim();for(let n=1,i=s+1;;n++){const r=t.indexOf(",",i);if(r===-1)return e[n]=t.substr(i).trim(),n;if(e[n]=t.substr(i,r-i).trim(),i=r+1,n===4)return 4}}},mn=class{name;minFilter=it.Nearest;magFilter=it.Nearest;uWrap=Pt.ClampToEdge;vWrap=Pt.ClampToEdge;texture=null;width=0;height=0;pma=!1;regions=[];constructor(e){this.name=e}setTexture(e){this.texture=e,e.setFilters(this.minFilter,this.magFilter),e.setWraps(this.uWrap,this.vWrap);for(const t of this.regions)t.texture=e}},is=class extends un{page;name;x=0;y=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0;index=0;degrees=0;names=null;values=null;constructor(e,t){super(),this.page=e,this.name=t,e.regions.push(this)}},rs=class Un{static empty=[];name;timelineAttachment;timelineSlots=Un.empty;constructor(t){if(!t)throw new Error("name cannot be null.");this.name=t,this.timelineAttachment=this}isTimelineActive(t,s,n){let i=t[s];if(i.bone.isActive()){const r=(n?i.getAppliedPose():i.getPose()).getAttachment();if(r!=null&&r.timelineAttachment===this)return!0}for(let r=0,c=this.timelineSlots.length;r<c;r++){if(i=t[this.timelineSlots[r]],!i.bone.isActive())continue;const l=(n?i.getAppliedPose():i.getPose()).getAttachment();if(l!=null&&l.timelineAttachment===this)return!0}return!1}},Ot=class qn extends rs{static nextID=0;id=qn.nextID++;bones=null;vertices=[];worldVerticesLength=0;constructor(t){super(t)}computeWorldVertices(t,s,n,i,r,c,l){i=c+(i>>1)*l;const a=s.appliedPose.deform;let o=this.vertices;const h=this.bones;if(!h){a.length>0&&(o=a);const m=s.bone.appliedPose,g=m.worldX,p=m.worldY,x=m.a,b=m.b,w=m.c,T=m.d;for(let y=n,v=c;v<i;y+=2,v+=l){const S=o[y],C=o[y+1];r[v]=S*x+C*b+g,r[v+1]=S*w+C*T+p}return}let d=0,f=0;for(let m=0;m<n;m+=2){const g=h[d];d+=g+1,f+=g}const u=t.bones;if(a.length===0)for(let m=c,g=f*3;m<i;m+=l){let p=0,x=0,b=h[d++];for(b+=d;d<b;d++,g+=3){const w=u[h[d]].appliedPose,T=o[g],y=o[g+1],v=o[g+2];p+=(T*w.a+y*w.b+w.worldX)*v,x+=(T*w.c+y*w.d+w.worldY)*v}r[m]=p,r[m+1]=x}else{const m=a;for(let g=c,p=f*3,x=f<<1;g<i;g+=l){let b=0,w=0,T=h[d++];for(T+=d;d<T;d++,p+=3,x+=2){const y=u[h[d]].appliedPose,v=o[p]+m[x],S=o[p+1]+m[x+1],C=o[p+2];b+=(v*y.a+S*y.b+y.worldX)*C,w+=(v*y.c+S*y.d+y.worldY)*C}r[g]=b,r[g+1]=w}}}copyTo(t){this.bones?(t.bones=[],L.arrayCopy(this.bones,0,t.bones,0,this.bones.length)):t.bones=null,this.vertices&&(t.vertices=L.newFloatArray(this.vertices.length),L.arrayCopy(this.vertices,0,t.vertices,0,this.vertices.length)),t.worldVerticesLength=this.worldVerticesLength,t.timelineAttachment=this.timelineAttachment,t.timelineSlots=this.timelineSlots}},pt=class on extends Ot{sequence;regionUVs=[];triangles=[];hullLength=0;path;color=new $(1,1,1,1);sourceMesh=null;edges=[];width=0;height=0;tempColor=new $(0,0,0,0);constructor(t,s){super(t),this.sequence=s}copy(){if(this.sourceMesh)return this.newLinkedMesh();const t=new on(this.name,this.sequence.copy());return t.path=this.path,t.color.setFromColor(this.color),this.copyTo(t),t.regionUVs=[],L.arrayCopy(this.regionUVs,0,t.regionUVs,0,this.regionUVs.length),t.triangles=[],L.arrayCopy(this.triangles,0,t.triangles,0,this.triangles.length),t.hullLength=this.hullLength,this.edges&&(t.edges=[],L.arrayCopy(this.edges,0,t.edges,0,this.edges.length)),t.width=this.width,t.height=this.height,t}updateSequence(){this.sequence.update(this)}getSourceMesh(){return this.sourceMesh}setSourceMesh(t){this.sourceMesh=t,t&&(this.bones=t.bones,this.vertices=t.vertices,this.worldVerticesLength=t.worldVerticesLength,this.regionUVs=t.regionUVs,this.triangles=t.triangles,this.hullLength=t.hullLength,this.worldVerticesLength=t.worldVerticesLength,this.edges=t.edges,this.width=t.width,this.height=t.height)}newLinkedMesh(){const t=new on(this.name,this.sequence.copy());return t.timelineAttachment=this.timelineAttachment,t.path=this.path,t.color.setFromColor(this.color),t.setSourceMesh(this.sourceMesh?this.sourceMesh:this),t.updateSequence(),t}static computeUVs(t,s,n){if(!t)throw new Error("Region not set.");const i=n.length;let r=t.u,c=t.v,l=0,a=0;if(t instanceof is){const o=t.page,h=o.width,d=o.height;switch(t.degrees){case 90:r-=(t.originalHeight-t.offsetY-t.height)/h,c-=(t.originalWidth-t.offsetX-t.width)/d,l=t.originalHeight/h,a=t.originalWidth/d;for(let f=0;f<i;f+=2)n[f]=r+s[f+1]*l,n[f+1]=c+(1-s[f])*a;return;case 180:r-=(t.originalWidth-t.offsetX-t.width)/h,c-=t.offsetY/d,l=t.originalWidth/h,a=t.originalHeight/d;for(let f=0;f<i;f+=2)n[f]=r+(1-s[f])*l,n[f+1]=c+(1-s[f+1])*a;return;case 270:r-=t.offsetY/h,c-=t.offsetX/d,l=t.originalHeight/h,a=t.originalWidth/d;for(let f=0;f<i;f+=2)n[f]=r+(1-s[f+1])*l,n[f+1]=c+s[f]*a;return;default:r-=t.offsetX/h,c-=(t.originalHeight-t.offsetY-t.height)/d,l=t.originalWidth/h,a=t.originalHeight/d}}else t?(l=t.u2-r,a=t.v2-c):(r=c=0,l=a=1);for(let o=0;o<i;o+=2)n[o]=r+s[o]*l,n[o+1]=c+s[o+1]*a}},H=class $n extends rs{sequence;x=0;y=0;scaleX=1;scaleY=1;rotation=0;width=0;height=0;path;color=new $(1,1,1,1);tempColor=new $(1,1,1,1);constructor(t,s){super(t),this.sequence=s}copy(){const t=new $n(this.name,this.sequence.copy());return t.path=this.path,t.x=this.x,t.y=this.y,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.rotation=this.rotation,t.width=this.width,t.height=this.height,t.color.setFromColor(this.color),t}computeWorldVertices(t,s,n,i,r){const c=t.bone.appliedPose,l=c.worldX,a=c.worldY,o=c.a,h=c.b,d=c.c,f=c.d;let u=s[0],m=s[1];n[i]=u*o+m*h+l,n[i+1]=u*d+m*f+a,i+=r,u=s[2],m=s[3],n[i]=u*o+m*h+l,n[i+1]=u*d+m*f+a,i+=r,u=s[4],m=s[5],n[i]=u*o+m*h+l,n[i+1]=u*d+m*f+a,i+=r,u=s[6],m=s[7],n[i]=u*o+m*h+l,n[i+1]=u*d+m*f+a}getOffsets(t){return this.sequence.offsets[this.sequence.resolveIndex(t)]}updateSequence(){this.sequence.update(this)}static computeUVs(t,s,n,i,r,c,l,a,o,h){if(!t)throw new Error("Region not set.");const d=l/t.originalWidth*i,f=a/t.originalHeight*r,u=-l/2*i+t.offsetX*d,m=-a/2*r+t.offsetY*f,g=u+t.width*d,p=m+t.height*f,x=c*X.degRad,b=Math.cos(x),w=Math.sin(x),T=u*b+s,y=u*w,v=m*b+n,S=m*w,C=g*b+s,A=g*w,P=p*b+n,k=p*w;o[0]=T-S,o[1]=v+y,o[2]=T-k,o[3]=P+y,o[4]=C-k,o[5]=P+A,o[6]=C-S,o[7]=v+A,t==null?(h[0]=0,h[1]=0,h[2]=0,h[3]=1,h[4]=1,h[5]=1,h[6]=1,h[7]=0):(h[1]=t.v2,h[2]=t.u,h[5]=t.v,h[6]=t.u2,t.degrees===90?(h[0]=t.u2,h[3]=t.v2,h[4]=t.u,h[7]=t.v):(h[0]=t.u,h[3]=t.v,h[4]=t.u2,h[7]=t.v2))}static X1=0;static Y1=1;static C1R=2;static C1G=3;static C1B=4;static C1A=5;static U1=6;static V1=7;static X2=8;static Y2=9;static C2R=10;static C2G=11;static C2B=12;static C2A=13;static U2=14;static V2=15;static X3=16;static Y3=17;static C3R=18;static C3G=19;static C3B=20;static C3A=21;static U3=22;static V3=23;static X4=24;static Y4=25;static C4R=26;static C4G=27;static C4B=28;static C4A=29;static U4=30;static V4=31},de=class Ke{static _nextID=0;id=Ke.nextID();regions;pathSuffix;uvs;offsets;start=0;digits=0;setupIndex=0;constructor(t,s){this.regions=new Array(t),this.pathSuffix=s}copy(){const t=this.regions.length,s=new Ke(t,this.pathSuffix);if(L.arrayCopy(this.regions,0,s.regions,0,t),s.start=this.start,s.digits=this.digits,s.setupIndex=this.setupIndex,this.uvs!=null){const n=this.uvs[0].length;s.uvs=[];for(let i=0;i<t;i++)s.uvs[i]=L.newFloatArray(n),L.arrayCopy(this.uvs[i],0,s.uvs[i],0,n)}if(this.offsets!=null){s.offsets=[];for(let n=0;n<t;n++)s.offsets[n]=[],L.arrayCopy(this.offsets[n],0,s.offsets[n],0,8)}return s}update(t){const s=this.regions.length;if(t instanceof H){this.uvs=[],this.offsets=[];for(let n=0;n<s;n++)this.uvs[n]=L.newFloatArray(8),this.offsets[n]=[],H.computeUVs(this.regions[n],t.x,t.y,t.scaleX,t.scaleY,t.rotation,t.width,t.height,this.offsets[n],this.uvs[n])}else if(t instanceof pt){const n=t.regionUVs;this.uvs=[],this.offsets=void 0;for(let i=0;i<s;i++)this.uvs[i]=L.newFloatArray(n.length),pt.computeUVs(this.regions[i],n,this.uvs[i])}}resolveIndex(t){let s=t.sequenceIndex;return s===-1&&(s=this.setupIndex),s>=this.regions.length&&(s=this.regions.length-1),s}getUVs(t){return this.uvs[t]}hasPathSuffix(){return this.pathSuffix}getPath(t,s){if(!this.pathSuffix)return t;let n=t;const i=(this.start+s).toString();for(let r=this.digits-i.length;r>0;r--)n+="0";return n+=i,n}static nextID(){return Ke._nextID++}},ot;(function(e){e[e.hold=0]="hold",e[e.once=1]="once",e[e.loop=2]="loop",e[e.pingpong=3]="pingpong",e[e.onceReverse=4]="onceReverse",e[e.loopReverse=5]="loopReverse",e[e.pingpongReverse=6]="pingpongReverse"})(ot||(ot={}));var os=[ot.hold,ot.once,ot.loop,ot.pingpong,ot.onceReverse,ot.loopReverse,ot.pingpongReverse],Ie=class{name;timelines=[];timelineIds;bones;color=new $(1,1,1,1);duration;constructor(e,t,s){if(!e)throw new Error("name cannot be null.");this.name=e,this.duration=s,this.timelineIds=new ss,this.bones=[],this.setTimelines(t)}setTimelines(e){if(!e)throw new Error("timelines cannot be null.");this.timelines=e;const t=e.length;this.timelineIds.clear(),this.bones.length=0;const s=new Set,n=e;for(let i=0;i<t;i++){const r=n[i];this.timelineIds.addAll(r.propertyIds),gn(r)&&s.add(r.boneIndex)&&this.bones.push(r.boneIndex)}}hasTimeline(e){for(let t=0;t<e.length;t++)if(this.timelineIds.contains(e[t]))return!0;return!1}apply(e,t,s,n,i,r,c,l,a,o){if(!e)throw new Error("skeleton cannot be null.");n&&this.duration!==0&&(s%=this.duration,t>0&&(t%=this.duration));const h=this.timelines;for(let d=0,f=h.length;d<f;d++)h[d].apply(e,t,s,i,r,c,l,a,o)}},W;(function(e){e[e.rotate=0]="rotate",e[e.x=1]="x",e[e.y=2]="y",e[e.scaleX=3]="scaleX",e[e.scaleY=4]="scaleY",e[e.shearX=5]="shearX",e[e.shearY=6]="shearY",e[e.inherit=7]="inherit",e[e.rgb=8]="rgb",e[e.alpha=9]="alpha",e[e.rgb2=10]="rgb2",e[e.attachment=11]="attachment",e[e.deform=12]="deform",e[e.event=13]="event",e[e.drawOrder=14]="drawOrder",e[e.ikConstraint=15]="ikConstraint",e[e.transformConstraint=16]="transformConstraint",e[e.pathConstraintPosition=17]="pathConstraintPosition",e[e.pathConstraintSpacing=18]="pathConstraintSpacing",e[e.pathConstraintMix=19]="pathConstraintMix",e[e.physicsConstraintInertia=20]="physicsConstraintInertia",e[e.physicsConstraintStrength=21]="physicsConstraintStrength",e[e.physicsConstraintDamping=22]="physicsConstraintDamping",e[e.physicsConstraintMass=23]="physicsConstraintMass",e[e.physicsConstraintWind=24]="physicsConstraintWind",e[e.physicsConstraintGravity=25]="physicsConstraintGravity",e[e.physicsConstraintMix=26]="physicsConstraintMix",e[e.physicsConstraintReset=27]="physicsConstraintReset",e[e.sequence=28]="sequence",e[e.sliderTime=29]="sliderTime",e[e.sliderMix=30]="sliderMix"})(W||(W={}));var tt=class{propertyIds;frames;additive=!1;instant=!1;constructor(e,...t){this.propertyIds=t,this.frames=L.newFloatArray(e*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 search(e,t,s=1){const n=e.length;for(let i=s;i<n;i+=s)if(e[i]>t)return i-s;return n-s}};function pn(e){return typeof e=="object"&&e!==null&&typeof e.slotIndex=="number"}var Dt=class extends tt{curves;constructor(e,t,...s){super(e,...s),this.curves=L.newFloatArray(e+t*18),this.curves[e-1]=1}setLinear(e){this.curves[e]=0}setStepped(e){this.curves[e]=1}shrink(e){const t=this.getFrameCount()+e*18;if(this.curves.length>t){const s=L.newFloatArray(t);L.arrayCopy(this.curves,0,s,0,t),this.curves=s}}setBezier(e,t,s,n,i,r,c,l,a,o,h){const d=this.curves;let f=this.getFrameCount()+e*18;s===0&&(d[t]=2+f);const u=(n-r*2+l)*.03,m=(i-c*2+a)*.03,g=((r-l)*3-n+o)*.006,p=((c-a)*3-i+h)*.006;let x=u*2+g,b=m*2+p,w=(r-n)*.3+u+g*.16666667,T=(c-i)*.3+m+p*.16666667,y=n+w,v=i+T;for(let S=f+18;f<S;f+=2)d[f]=y,d[f+1]=v,w+=x,T+=b,x+=g,b+=p,y+=w,v+=T}getBezierValue(e,t,s,n){const i=this.curves;if(i[n]>e){const a=this.frames[t],o=this.frames[t+s];return o+(e-a)/(i[n]-a)*(i[n+1]-o)}const r=n+18;for(n+=2;n<r;n+=2)if(i[n]>=e){const a=i[n-2],o=i[n-1];return o+(e-a)/(i[n]-a)*(i[n+1]-o)}t+=this.getFrameEntries();const c=i[r-2],l=i[r-1];return l+(e-c)/(this.frames[t]-c)*(this.frames[t+s]-l)}},fe=class extends Dt{constructor(e,t,s){super(e,t,s)}getFrameEntries(){return 2}setFrame(e,t,s){e<<=1,this.frames[e]=t,this.frames[e+1]=s}getCurveValue(e){const t=this.frames;let s=t.length-2;for(let i=2;i<=s;i+=2)if(t[i]>e){s=i-2;break}const n=this.curves[s>>1];switch(n){case 0:{const i=t[s],r=t[s+1];return r+(e-i)/(t[s+2]-i)*(t[s+2+1]-r)}case 1:return t[s+1]}return this.getBezierValue(e,s,1,n-2)}getRelativeValue(e,t,s,n,i,r){if(e<this.frames[0])return s?r:i;const c=this.getCurveValue(e);return s?r+c*t:i+(n?c:c+r-i)*t}getAbsoluteValue(e,t,s,n,i,r,c){return c===void 0?this.getAbsoluteValue1(e,t,s,n,i,r):this.getAbsoluteValue2(e,t,s,n,i,r,c)}getAbsoluteValue1(e,t,s,n,i,r){if(e<this.frames[0])return s?r:i;const c=this.getCurveValue(e);return s?r+(n?c:c-r)*t:i+(n?c:c-i)*t}getAbsoluteValue2(e,t,s,n,i,r,c){return e<this.frames[0]?s?r:i:s?r+(n?c:c-r)*t:i+(n?c:c-i)*t}getScaleValue(e,t,s,n,i,r,c){if(e<this.frames[0])return s?c:r;const l=this.getCurveValue(e)*c;if(t===1&&!n)return l;let a=s?c:r;return n?a+(l-c)*t:i?a+(Math.abs(l)*Math.sign(a)-a)*t:(a=Math.abs(a)*Math.sign(l),a+(l-a)*t)}};function gn(e){return typeof e=="object"&&e!==null&&typeof e.boneIndex=="number"}var Nt=class extends fe{boneIndex;constructor(e,t,s,n){super(e,t,`${n}|${s}`),this.boneIndex=s,this.additive=!0}apply(e,t,s,n,i,r,c,l,a){const o=e.bones[this.boneIndex];o.active&&this.apply1(a?o.appliedPose:o.pose,o.data.setupPose,s,i,r,c,l)}},ke=class extends Dt{boneIndex;constructor(e,t,s,n,i){super(e,t,`${n}|${s}`,`${i}|${s}`),this.boneIndex=s,this.additive=!0}getFrameEntries(){return 3}setFrame(e,t,s,n){e*=3,this.frames[e]=t,this.frames[e+1]=s,this.frames[e+2]=n}apply(e,t,s,n,i,r,c,l,a){const o=e.bones[this.boneIndex];o.active&&this.apply1(a?o.appliedPose:o.pose,o.data.setupPose,s,i,r,c,l)}},ue=class extends Nt{constructor(e,t,s){super(e,t,s,W.rotate)}apply1(e,t,s,n,i,r,c){e.rotation=this.getRelativeValue(s,n,i,r,e.rotation,t.rotation)}},as=class extends ke{constructor(e,t,s){super(e,t,s,W.x,W.y)}apply1(e,t,s,n,i,r,c){const l=this.frames;if(s<l[0]){i&&(e.x=t.x,e.y=t.y);return}let a=0,o=0;const h=tt.search(l,s,3),d=this.curves[h/3];switch(d){case 0:{const f=l[h];a=l[h+1],o=l[h+2];const u=(s-f)/(l[h+3]-f);a+=(l[h+3+1]-a)*u,o+=(l[h+3+2]-o)*u;break}case 1:a=l[h+1],o=l[h+2];break;default:a=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}i?(e.x=t.x+a*n,e.y=t.y+o*n):r?(e.x+=a*n,e.y+=o*n):(e.x+=(t.x+a-e.x)*n,e.y+=(t.y+o-e.y)*n)}},ls=class extends Nt{constructor(e,t,s){super(e,t,s,W.x)}apply1(e,t,s,n,i,r,c){e.x=this.getRelativeValue(s,n,i,r,e.x,t.x)}},cs=class extends Nt{constructor(e,t,s){super(e,t,s,W.y)}apply1(e,t,s,n,i,r,c){e.y=this.getRelativeValue(s,n,i,r,e.y,t.y)}},hs=class extends ke{constructor(e,t,s){super(e,t,s,W.scaleX,W.scaleY)}apply1(e,t,s,n,i,r,c){const l=this.frames;if(s<l[0]){i&&(e.scaleX=t.scaleX,e.scaleY=t.scaleY);return}let a,o;const h=tt.search(l,s,3),d=this.curves[h/3];switch(d){case 0:{const f=l[h];a=l[h+1],o=l[h+2];const u=(s-f)/(l[h+3]-f);a+=(l[h+3+1]-a)*u,o+=(l[h+3+2]-o)*u;break}case 1:a=l[h+1],o=l[h+2];break;default:a=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}if(a*=t.scaleX,o*=t.scaleY,n===1&&!r)e.scaleX=a,e.scaleY=o;else{let f=0,u=0;i?(f=t.scaleX,u=t.scaleY):(f=e.scaleX,u=e.scaleY),r?(e.scaleX=f+(a-t.scaleX)*n,e.scaleY=u+(o-t.scaleY)*n):c?(e.scaleX=f+(Math.abs(a)*Math.sign(f)-f)*n,e.scaleY=u+(Math.abs(o)*Math.sign(u)-u)*n):(f=Math.abs(f)*Math.sign(a),u=Math.abs(u)*Math.sign(o),e.scaleX=f+(a-f)*n,e.scaleY=u+(o-u)*n)}}},ds=class extends Nt{constructor(e,t,s){super(e,t,s,W.scaleX)}apply1(e,t,s,n,i,r,c){e.scaleX=this.getScaleValue(s,n,i,r,c,e.scaleX,t.scaleX)}},fs=class extends Nt{constructor(e,t,s){super(e,t,s,W.scaleY)}apply1(e,t,s,n,i,r,c){e.scaleY=this.getScaleValue(s,n,i,r,c,e.scaleY,t.scaleY)}},us=class extends ke{constructor(e,t,s){super(e,t,s,W.shearX,W.shearY)}apply1(e,t,s,n,i,r,c){const l=this.frames;if(s<l[0]){i&&(e.shearX=t.shearX,e.shearY=t.shearY);return}let a=0,o=0;const h=tt.search(l,s,3),d=this.curves[h/3];switch(d){case 0:{const f=l[h];a=l[h+1],o=l[h+2];const u=(s-f)/(l[h+3]-f);a+=(l[h+3+1]-a)*u,o+=(l[h+3+2]-o)*u;break}case 1:a=l[h+1],o=l[h+2];break;default:a=this.getBezierValue(s,h,1,d-2),o=this.getBezierValue(s,h,2,d+18-2)}i?(e.shearX=t.shearX+a*n,e.shearY=t.shearY+o*n):r?(e.shearX+=a*n,e.shearY+=o*n):(e.shearX+=(t.shearX+a-e.shearX)*n,e.shearY+=(t.shearY+o-e.shearY)*n)}},ms=class extends Nt{constructor(e,t,s){super(e,t,s,W.shearX)}apply1(e,t,s,n,i,r,c){e.shearX=this.getRelativeValue(s,n,i,r,e.shearX,t.shearX)}},ps=class extends Nt{constructor(e,t,s){super(e,t,s,W.shearY)}apply1(e,t,s,n,i,r,c){e.shearY=this.getRelativeValue(s,n,i,r,e.shearY,t.shearY)}},gs=class extends tt{boneIndex;constructor(e,t){super(e,`${W.inherit}|${t}`),this.boneIndex=t,this.instant=!0}getFrameEntries(){return 2}setFrame(e,t,s){e*=2,this.frames[e]=t,this.frames[e+1]=s}apply(e,t,s,n,i,r,c,l,a){const o=e.bones[this.boneIndex];if(!o.active)return;const h=a?o.appliedPose:o.pose;if(l)r&&(h.inherit=o.data.setupPose.inherit);else{const d=this.frames;s<d[0]?r&&(h.inherit=o.data.setupPose.inherit):h.inherit=this.frames[tt.search(d,s,2)+1]}}},me=class extends Dt{slotIndex;constructor(e,t,s,...n){super(e,t,...n),this.slotIndex=s}apply(e,t,s,n,i,r,c,l,a){const o=e.slots[this.slotIndex];o.bone.active&&this.apply1(o,a?o.appliedPose:o.pose,s,i,r,c)}},xs=class extends me{constructor(e,t,s){super(e,t,s,`${W.rgb}|${s}`,`${W.alpha}|${s}`)}getFrameEntries(){return 5}setFrame(e,t,s,n,i,r){e*=5,this.frames[e]=t,this.frames[e+1]=s,this.frames[e+2]=n,this.frames[e+3]=i,this.frames[e+4]=r}apply1(e,t,s,n,i,r){const c=t.color,l=this.frames;if(s<l[0]){i&&c.setFromColor(e.data.setupPose.color);return}let a=0,o=0,h=0,d=0;const f=tt.search(l,s,5),u=this.curves[f/5];switch(u){case 0:{const m=l[f];a=l[f+1],o=l[f+2],h=l[f+3],d=l[f+4];const g=(s-m)/(l[f+5]-m);a+=(l[f+5+1]-a)*g,o+=(l[f+5+2]-o)*g,h+=(l[f+5+3]-h)*g,d+=(l[f+5+4]-d)*g;break}case 1:a=l[f+1],o=l[f+2],h=l[f+3],d=l[f+4];break;default:a=this.getBezierValue(s,f,1,u-2),o=this.getBezierValue(s,f,2,u+18-2),h=this.getBezierValue(s,f,3,u+18*2-2),d=this.getBezierValue(s,f,4,u+18*3-2)}if(n===1)c.set(a,o,h,d);else if(i){const m=e.data.setupPose.color;c.set(m.r+(a-m.r)*n,m.g+(o-m.g)*n,m.b+(h-m.b)*n,m.a+(d-m.a)*n)}else c.add((a-c.r)*n,(o-c.g)*n,(h-c.b)*n,(d-c.a)*n)}},bs=class extends me{constructor(e,t,s){super(e,t,s,`${W.rgb}|${s}`)}getFrameEntries(){return 4}setFrame(e,t,s,n,i){e<<=2,this.frames[e]=t,this.frames[e+1]=s,this.frames[e+2]=n,this.frames[e+3]=i}apply1(e,t,s,n,i,r){const c=t.color;let l=0,a=0,o=0;const h=this.frames;if(s<h[0]){if(i){const u=e.data.setupPose.color;c.r=u.r,c.g=u.g,c.b=u.b}return}const d=tt.search(h,s,4),f=this.curves[d>>2];switch(f){case 0:{const u=h[d];l=h[d+1],a=h[d+2],o=h[d+3];const m=(s-u)/(h[d+4]-u);l+=(h[d+4+1]-l)*m,a+=(h[d+4+2]-a)*m,o+=(h[d+4+3]-o)*m;break}case 1:l=h[d+1],a=h[d+2],o=h[d+3];break;default:l=this.getBezierValue(s,d,1,f-2),a=this.getBezierValue(s,d,2,f+18-2),o=this.getBezierValue(s,d,3,f+18*2-2)}if(n!==1)if(i){const u=e.data.setupPose.color;l=u.r+(l-u.r)*n,a=u.g+(a-u.g)*n,o=u.b+(o-u.b)*n}else l=c.r+(l-c.r)*n,a=c.g+(a-c.g)*n,o=c.b+(o-c.b)*n;c.r=l<0?0:l>1?1:l,c.g=a<0?0:a>1?1:a,c.b=o<0?0:o>1?1:o}},ws=class extends fe{slotIndex=0;constructor(e,t,s){super(e,t,`${W.alpha}|${s}`),this.slotIndex=s}apply(e,t,s,n,i,r,c,l,a){const o=e.slots[this.slotIndex];if(!o.bone.active)return;const h=(a?o.appliedPose:o.pose).color;let d=0;const f=this.frames;if(s<f[0]){r&&(h.a=o.data.setupPose.color.a);return}if(d=this.getCurveValue(s),i!==1)if(r){const u=o.data.setupPose.color;d=u.a+(d-u.a)*i}else d=h.a+(d-h.a)*i;h.a=d<0?0:d>1?1:d}},ys=class extends me{constructor(e,t,s){super(e,t,s,`${W.rgb}|${s}`,`${W.alpha}|${s}`,`${W.rgb2}|${s}`)}getFrameEntries(){return 8}setFrame(e,t,s,n,i,r,c,l,a){e<<=3,this.frames[e]=t,this.frames[e+1]=s,this.frames[e+2]=n,this.frames[e+3]=i,this.frames[e+4]=r,this.frames[e+5]=c,this.frames[e+6]=l,this.frames[e+7]=a}apply1(e,t,s,n,i,r){const c=t.color,l=t.darkColor;let a=0,o=0,h=0;const d=this.frames;if(s<d[0]){if(i){const b=e.data.setupPose;c.setFromColor(b.color);const w=b.darkColor;l.r=w.r,l.g=w.g,l.b=w.b}return}let f=0,u=0,m=0,g=0;const p=tt.search(d,s,8),x=this.curves[p>>3];switch(x){case 0:{const b=d[p];f=d[p+1],u=d[p+2],m=d[p+3],g=d[p+4],a=d[p+5],o=d[p+6],h=d[p+7];const w=(s-b)/(d[p+8]-b);f+=(d[p+8+1]-f)*w,u+=(d[p+8+2]-u)*w,m+=(d[p+8+3]-m)*w,g+=(d[p+8+4]-g)*w,a+=(d[p+8+5]-a)*w,o+=(d[p+8+6]-o)*w,h+=(d[p+8+7]-h)*w;break}case 1:f=d[p+1],u=d[p+2],m=d[p+3],g=d[p+4],a=d[p+5],o=d[p+6],h=d[p+7];break;default:f=this.getBezierValue(s,p,1,x-2),u=this.getBezierValue(s,p,2,x+18-2),m=this.getBezierValue(s,p,3,x+18*2-2),g=this.getBezierValue(s,p,4,x+18*3-2),a=this.getBezierValue(s,p,5,x+18*4-2),o=this.getBezierValue(s,p,6,x+18*5-2),h=this.getBezierValue(s,p,7,x+18*6-2)}if(n===1)c.set(f,u,m,g);else if(i){const b=e.data.setupPose;let w=b.color;c.set(w.r+(f-w.r)*n,w.g+(u-w.g)*n,w.b+(m-w.b)*n,w.a+(g-w.a)*n),w=b.darkColor,a=w.r+(a-w.r)*n,o=w.g+(o-w.g)*n,h=w.b+(h-w.b)*n}else c.add((f-c.r)*n,(u-c.g)*n,(m-c.b)*n,(g-c.a)*n),a=l.r+(a-l.r)*n,o=l.g+(o-l.g)*n,h=l.b+(h-l.b)*n;l.r=a<0?0:a>1?1:a,l.g=o<0?0:o>1?1:o,l.b=h<0?0:h>1?1:h}},vs=class extends me{constructor(e,t,s){super(e,t,s,`${W.rgb}|${s}`,`${W.rgb2}|${s}`)}getFrameEntries(){return 7}setFrame(e,t,s,n,i,r,c,l){e*=7,this.frames[e]=t,this.frames[e+1]=s,this.frames[e+2]=n,this.frames[e+3]=i,this.frames[e+4]=r,this.frames[e+5]=c,this.frames[e+6]=l}apply1(e,t,s,n,i,r){const c=t.color,l=t.darkColor;let a=0,o=0,h=0,d=0,f=0,u=0;const m=this.frames;if(s<m[0]){if(i){const x=e.data.setupPose,b=x.color,w=x.darkColor;c.r=b.r,c.g=b.g,c.b=b.b,l.r=w.r,l.g=w.g,l.b=w.b}return}const g=tt.search(m,s,7),p=this.curves[g/7];switch(p){case 0:{const x=m[g];a=m[g+1],o=m[g+2],h=m[g+3],d=m[g+4],f=m[g+5],u=m[g+6];const b=(s-x)/(m[g+7]-x);a+=(m[g+7+1]-a)*b,o+=(m[g+7+2]-o)*b,h+=(m[g+7+3]-h)*b,d+=(m[g+7+4]-d)*b,f+=(m[g+7+5]-f)*b,u+=(m[g+7+6]-u)*b;break}case 1:a=m[g+1],o=m[g+2],h=m[g+3],d=m[g+4],f=m[g+5],u=m[g+6];break;default:a=this.getBezierValue(s,g,1,p-2),o=this.getBezierValue(s,g,2,p+18-2),h=this.getBezierValue(s,g,3,p+18*2-2),d=this.getBezierValue(s,g,4,p+18*3-2),f=this.getBezierValue(s,g,5,p+18*4-2),u=this.getBezierValue(s,g,6,p+18*5-2)}if(n!==1)if(i){const x=e.data.setupPose;let b=x.color;a=b.r+(a-b.r)*n,o=b.g+(o-b.g)*n,h=b.b+(h-b.b)*n,b=x.darkColor,d=b.r+(d-b.r)*n,f=b.g+(f-b.g)*n,u=b.b+(u-b.b)*n}else a=c.r+(a-c.r)*n,o=c.g+(o-c.g)*n,h=c.b+(h-c.b)*n,d=l.r+(d-l.r)*n,f=l.g+(f-l.g)*n,u=l.b+(u-l.b)*n;c.r=a<0?0:a>1?1:a,c.g=o<0?0:o>1?1:o,c.b=h<0?0:h>1?1:h,l.r=d<0?0:d>1?1:d,l.g=f<0?0:f>1?1:f,l.b=u<0?0:u>1?1:u}},ee=class extends tt{slotIndex=0;attachmentNames;constructor(e,t){super(e,`${W.attachment}|${t}`),this.slotIndex=t,this.attachmentNames=new Array(e),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(e,t,s){this.frames[e]=t,this.attachmentNames[e]=s}apply(e,t,s,n,i,r,c,l,a){const o=e.slots[this.slotIndex];if(!o.bone.active)return;const h=a?o.appliedPose:o.pose;l||s<this.frames[0]?r&&this.setAttachment(e,h,o.data.attachmentName):this.setAttachment(e,h,this.attachmentNames[tt.search(this.frames,s)])}setAttachment(e,t,s){t.setAttachment(s?e.getAttachment(this.slotIndex,s):null)}},Ts=class extends Dt{slotIndex;attachment;vertices;constructor(e,t,s,n){super(e,t,`${W.deform}|${s}|${n.id}`),this.slotIndex=s,this.attachment=n,this.vertices=new Array(e),this.additive=!0}getFrameCount(){return this.frames.length}setFrame(e,t,s){this.frames[e]=t,this.vertices[e]=s}setBezier(e,t,s,n,i,r,c,l,a,o,h){const d=this.curves;let f=this.getFrameCount()+e*18;s===0&&(d[t]=2+f);const u=(n-r*2+l)*.03,m=a*.03-c*.06,g=((r-l)*3-n+o)*.006,p=(c-a+.33333333)*.018;let x=u*2+g,b=m*2+p,w=(r-n)*.3+u+g*.16666667,T=c*.3+m+p*.16666667,y=n+w,v=T;for(let S=f+18;f<S;f+=2)d[f]=y,d[f+1]=v,w+=x,T+=b,x+=g,b+=p,y+=w,v+=T}getCurvePercent(e,t){const s=this.curves;let n=s[t];switch(n){case 0:{const l=this.frames[t];return(e-l)/(this.frames[t+this.getFrameEntries()]-l)}case 1:return 0}if(n-=2,s[n]>e){const l=this.frames[t];return s[n+1]*(e-l)/(s[n]-l)}const i=n+18;for(n+=2;n<i;n+=2)if(s[n]>=e){const l=s[n-2],a=s[n-1];return a+(e-l)/(s[n]-l)*(s[n+1]-a)}const r=s[i-2],c=s[i-1];return c+(1-c)*(e-r)/(this.frames[t+this.getFrameEntries()]-r)}apply(e,t,s,n,i,r,c,l,a){const o=e.slots;if(!this.attachment.isTimelineActive(o,this.slotIndex,a))return;const h=this.attachment.timelineSlots,d=this.frames;if(s<d[0]){this.applyBeforeFirst(o[this.slotIndex],a,r);for(const p of h)this.applyBeforeFirst(o[p],a,r);return}let f,u,m;if(s>=d[d.length-1])m=0,f=this.vertices[d.length-1],u=null;else{const p=tt.search(d,s);m=this.getCurvePercent(s,p),f=this.vertices[p],u=this.vertices[p+1]}const g=this.vertices[0].length;this.applyToSlot(o[this.slotIndex],a,f,u,m,g,i,r,c);for(const p of h)this.applyToSlot(o[p],a,f,u,m,g,i,r,c)}applyToSlot(e,t,s,n,i,r,c,l,a){if(!e.bone.active)return;const o=t?e.appliedPose:e.pose;if(o.attachment===null||o.attachment.timelineAttachment!==this.attachment)return;const h=o.attachment,d=o.deform;if(d.length===0&&(l=!0),d.length=r,n===null)if(c===1)if(a&&!l)if(h.bones)for(let f=0;f<r;f++)d[f]+=s[f];else{const f=h.vertices;for(let u=0;u<r;u++)d[u]+=s[u]-f[u]}else L.arrayCopy(s,0,d,0,r);else if(l)if(h.bones)for(let f=0;f<r;f++)d[f]=s[f]*c;else{const f=h.vertices;for(let u=0;u<r;u++){const m=f[u];d[u]=m+(s[u]-m)*c}}else if(a)if(h.bones)for(let f=0;f<r;f++)d[f]+=s[f]*c;else{const f=h.vertices;for(let u=0;u<r;u++)d[u]+=(s[u]-f[u])*c}else for(let f=0;f<r;f++)d[f]+=(s[f]-d[f])*c;else if(c===1)if(a&&!l)if(h.bones)for(let f=0;f<r;f++){const u=s[f];d[f]+=u+(n[f]-u)*i}else{const f=h.vertices;for(let u=0;u<r;u++){const m=s[u];d[u]+=m+(n[u]-m)*i-f[u]}}else if(i===0)L.arrayCopy(s,0,d,0,r);else for(let f=0;f<r;f++){const u=s[f];d[f]=u+(n[f]-u)*i}else if(l)if(h.bones)for(let f=0;f<r;f++){const u=s[f];d[f]=(u+(n[f]-u)*i)*c}else{const f=h.vertices;for(let u=0;u<r;u++){const m=s[u],g=f[u];d[u]=g+(m+(n[u]-m)*i-g)*c}}else if(a)if(h.bones)for(let f=0;f<r;f++){const u=s[f];d[f]+=(u+(n[f]-u)*i)*c}else{const f=h.vertices;for(let u=0;u<r;u++){const m=s[u];d[u]+=(m+(n[u]-m)*i-f[u])*c}}else for(let f=0;f<r;f++){const u=s[f];d[f]+=(u+(n[f]-u)*i-d[f])*c}}applyBeforeFirst(e,t,s){if(!e.bone.active)return;const n=t?e.appliedPose:e.pose;n.attachment==null||n.attachment.timelineAttachment!==this.attachment||(n.deform.length===0&&(s=!0),s&&(n.deform.length=0))}},Ss=class zt extends tt{static ENTRIES=3;static MODE=1;static DELAY=2;slotIndex;attachment;constructor(t,s,n){super(t,`${W.sequence}|${s}|${n.sequence.id}`),this.slotIndex=s,this.attachment=n,this.instant=!0}getFrameEntries(){return zt.ENTRIES}getSlotIndex(){return this.slotIndex}getAttachment(){return this.attachment}setFrame(t,s,n,i,r){const c=this.frames;t*=zt.ENTRIES,c[t]=s,c[t+zt.MODE]=n|i<<4,c[t+zt.DELAY]=r}apply(t,s,n,i,r,c,l,a,o){const h=t.slots;if(!this.attachment.isTimelineActive(h,this.slotIndex,o))return;const d=this.attachment.timelineSlots,f=this.frames;if(a||n<f[0]){if(c){this.setupPose(h[this.slotIndex],o);for(const x of d)this.setupPose(h[x],o)}return}const u=tt.search(f,n,zt.ENTRIES),m=f[u],g=f[u+zt.MODE],p=f[u+zt.DELAY];this.applyToSlot(h[this.slotIndex],o,n,m,g,p);for(const x of d)this.applyToSlot(h[x],o,n,m,g,p)}setupPose(t,s){if(!t.bone.active)return;const n=s?t.appliedPose:t.pose;n.attachment===null||n.attachment.timelineAttachment!==this.attachment||(n.sequenceIndex=-1)}applyToSlot(t,s,n,i,r,c){if(!t.bone.active)return;const l=s?t.appliedPose:t.pose;if(l.attachment===null||l.attachment.timelineAttachment!==this.attachment)return;let a=r>>4,o=l.attachment.sequence.regions.length;const h=os[r&15];if(h!==ot.hold)switch(a+=(n-i)/c+1e-5|0,h){case ot.once:a=Math.min(o-1,a);break;case ot.loop:a%=o;break;case ot.pingpong:{const d=(o<<1)-2;a=d===0?0:a%d,a>=o&&(a=d-a);break}case ot.onceReverse:a=Math.max(o-1-a,0);break;case ot.loopReverse:a=o-1-a%o;break;case ot.pingpongReverse:{const d=(o<<1)-2;a=d===0?0:(a+o-1)%d,a>=o&&(a=d-a)}}l.sequenceIndex=a}},Me=class zn extends tt{static propertyIds=[`${W.event}`];events;constructor(t){super(t,...zn.propertyIds),this.events=new Array(t),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(t,s){this.frames[t]=s.time,this.events[t]=s}apply(t,s,n,i,r,c,l,a,o){if(!i)return;const h=this.frames,d=this.frames.length;if(s>n)this.apply(null,s,Number.MAX_VALUE,i,0,!1,!1,!1,!1),s=-1;else if(s>=h[d-1])return;if(n<h[0])return;let f=0;if(s<h[0])f=0;else{f=tt.search(h,s)+1;const u=h[f];for(;f>0&&h[f-1]===u;)f--}for(;f<d&&n>=h[f];f++)i.push(this.events[f])}},Wt=class an extends tt{static propertyID=`${W.drawOrder}`;static propertyIds=[an.propertyID];drawOrders;constructor(t){super(t,...an.propertyIds),this.drawOrders=new Array(t),this.instant=!0}getFrameCount(){return this.frames.length}setFrame(t,s,n){this.frames[t]=s,this.drawOrders[t]=n}apply(t,s,n,i,r,c,l,a,o){const h=o?t.drawOrder.appliedPose:t.drawOrder.pose,d=t.slots;if(a||n<this.frames[0]){c&&L.arrayCopy(d,0,h,0,t.slots.length);return}const f=this.drawOrders[tt.search(this.frames,n)];if(!f)L.arrayCopy(d,0,h,0,t.slots.length);else for(let u=0,m=f.length;u<m;u++)h[u]=d[f[u]]}},pe=class Wn extends tt{slots;inFolder;drawOrders;constructor(t,s,n){super(t,...Wn.propertyIds(s)),this.slots=s,this.drawOrders=new Array(t),this.inFolder=new Array(n);for(const i of s)this.inFolder[i]=!0;this.instant=!0}static propertyIds(t){const s=t.length,n=new Array(s);for(let i=0;i<s;i++)n[i]=`d${t[i]}`;return n}getFrameCount(){return this.frames.length}getSlots(){return this.slots}getDrawOrders(){return this.drawOrders}setFrame(t,s,n){this.frames[t]=s,this.drawOrders[t]=n}apply(t,s,n,i,r,c,l,a,o){const h=o?t.drawOrder.appliedPose:t.drawOrder.pose,d=t.slots;if(a||n<this.frames[0])c&&this.setup(h,d);else{const f=this.drawOrders[tt.search(this.frames,n)];if(!f)this.setup(h,d);else{const u=this.inFolder,m=this.slots;for(let g=0,p=0,x=m.length;!(u[h[g].data.index]&&(h[g]=d[m[f[p]]],++p===x));g++);}}}setup(t,s){const{inFolder:n,slots:i}=this;for(let r=0,c=0,l=i.length;!(n[t[r].data.index]&&(t[r]=s[i[c]],++c===l));r++);}};function xn(e){return typeof e=="object"&&e!==null&&typeof e.constraintIndex=="number"}var Cs=class extends Dt{constraintIndex=0;constructor(e,t,s){super(e,t,`${W.ikConstraint}|${s}`),this.constraintIndex=s}getFrameEntries(){return 6}setFrame(e,t,s,n,i,r,c){e*=6,this.frames[e]=t,this.frames[e+1]=s,this.frames[e+2]=n,this.frames[e+3]=i,this.frames[e+4]=r?1:0,this.frames[e+5]=c?1:0}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(!o.active)return;const h=a?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){if(r){const x=o.data.setupPose;h.mix=x.mix,h.softness=x.softness,h.bendDirection=x.bendDirection,h.compress=x.compress,h.stretch=x.stretch}return}let f=0,u=0;const m=tt.search(d,s,6),g=this.curves[m/6];switch(g){case 0:{const x=d[m];f=d[m+1],u=d[m+2];const b=(s-x)/(d[m+6]-x);f+=(d[m+6+1]-f)*b,u+=(d[m+6+2]-u)*b;break}case 1:f=d[m+1],u=d[m+2];break;default:f=this.getBezierValue(s,m,1,g-2),u=this.getBezierValue(s,m,2,g+18-2)}const p=r?o.data.setupPose:h;h.mix=p.mix+(f-p.mix)*i,h.softness=p.softness+(u-p.softness)*i,l?r&&(h.bendDirection=p.bendDirection,h.compress=p.compress,h.stretch=p.stretch):(h.bendDirection=d[m+3],h.compress=d[m+4]!==0,h.stretch=d[m+5]!==0)}},As=class extends Dt{constraintIndex=0;constructor(e,t,s){super(e,t,`${W.transformConstraint}|${s}`),this.constraintIndex=s,this.additive=!0}getFrameEntries(){return 7}setFrame(e,t,s,n,i,r,c,l){const a=this.frames;e*=7,a[e]=t,a[e+1]=s,a[e+2]=n,a[e+3]=i,a[e+4]=r,a[e+5]=c,a[e+6]=l}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(!o.active)return;const h=a?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){if(r){const y=o.data.setupPose;h.mixRotate=y.mixRotate,h.mixX=y.mixX,h.mixY=y.mixY,h.mixScaleX=y.mixScaleX,h.mixScaleY=y.mixScaleY,h.mixShearY=y.mixShearY}return}let f,u,m,g,p,x;const b=tt.search(d,s,7),w=this.curves[b/7];switch(w){case 0:{const y=d[b];f=d[b+1],u=d[b+2],m=d[b+3],g=d[b+4],p=d[b+5],x=d[b+6];const v=(s-y)/(d[b+7]-y);f+=(d[b+7+1]-f)*v,u+=(d[b+7+2]-u)*v,m+=(d[b+7+3]-m)*v,g+=(d[b+7+4]-g)*v,p+=(d[b+7+5]-p)*v,x+=(d[b+7+6]-x)*v;break}case 1:f=d[b+1],u=d[b+2],m=d[b+3],g=d[b+4],p=d[b+5],x=d[b+6];break;default:f=this.getBezierValue(s,b,1,w-2),u=this.getBezierValue(s,b,2,w+18-2),m=this.getBezierValue(s,b,3,w+18*2-2),g=this.getBezierValue(s,b,4,w+18*3-2),p=this.getBezierValue(s,b,5,w+18*4-2),x=this.getBezierValue(s,b,6,w+18*5-2)}const T=r?o.data.setupPose:h;c?(h.mixRotate=T.mixRotate+f*i,h.mixX=T.mixX+u*i,h.mixY=T.mixY+m*i,h.mixScaleX=T.mixScaleX+g*i,h.mixScaleY=T.mixScaleY+p*i,h.mixShearY=T.mixShearY+x*i):(h.mixRotate=T.mixRotate+(f-T.mixRotate)*i,h.mixX=T.mixX+(u-T.mixX)*i,h.mixY=T.mixY+(m-T.mixY)*i,h.mixScaleX=T.mixScaleX+(g-T.mixScaleX)*i,h.mixScaleY=T.mixScaleY+(p-T.mixScaleY)*i,h.mixShearY=T.mixShearY+(x-T.mixShearY)*i)}},se=class extends fe{constraintIndex;constructor(e,t,s,n){super(e,t,`${n}|${s}`),this.constraintIndex=s}},Ps=class extends se{constructor(e,t,s){super(e,t,s,W.pathConstraintPosition),this.additive=!0}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(o.active){const h=a?o.appliedPose:o.pose;h.position=this.getAbsoluteValue(s,i,r,c,h.position,o.data.setupPose.position)}}},Is=class extends se{constructor(e,t,s){super(e,t,s,W.pathConstraintSpacing)}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(o.active){const h=a?o.appliedPose:o.pose;h.spacing=this.getAbsoluteValue(s,i,r,!1,h.spacing,o.data.setupPose.spacing)}}},ks=class extends Dt{constraintIndex;constructor(e,t,s){super(e,t,`${W.pathConstraintMix}|${s}`),this.constraintIndex=s}getFrameEntries(){return 4}setFrame(e,t,s,n,i){const r=this.frames;e<<=2,r[e]=t,r[e+1]=s,r[e+2]=n,r[e+3]=i}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(!o.active)return;const h=a?o.appliedPose:o.pose,d=this.frames;if(s<d[0]){if(r){const b=o.data.setupPose;h.mixRotate=b.mixRotate,h.mixX=b.mixX,h.mixY=b.mixY}return}let f,u,m;const g=tt.search(d,s,4),p=this.curves[g>>2];switch(p){case 0:{const b=d[g];f=d[g+1],u=d[g+2],m=d[g+3];const w=(s-b)/(d[g+4]-b);f+=(d[g+4+1]-f)*w,u+=(d[g+4+2]-u)*w,m+=(d[g+4+3]-m)*w;break}case 1:f=d[g+1],u=d[g+2],m=d[g+3];break;default:f=this.getBezierValue(s,g,1,p-2),u=this.getBezierValue(s,g,2,p+18-2),m=this.getBezierValue(s,g,3,p+18*2-2)}const x=r?o.data.setupPose:h;c?(h.mixRotate=x.mixRotate+f*i,h.mixX=x.mixX+u*i,h.mixY=x.mixY+m*i):(h.mixRotate=x.mixRotate+(f-x.mixRotate)*i,h.mixX=x.mixX+(u-x.mixX)*i,h.mixY=x.mixY+(m-x.mixY)*i)}},Et=class extends se{constructor(e,t,s,n){super(e,t,s,n)}apply(e,t,s,n,i,r,c,l,a){if(c&&!this.additive&&(c=!1),this.constraintIndex===-1){const o=s>=this.frames[0]?this.getCurveValue(s):0,h=e.physics;for(const d of h)if(d.active&&this.global(d.data)){const f=a?d.appliedPose:d.pose;this.set(f,this.getAbsoluteValue(s,i,r,c,this.get(f),this.get(d.data.setupPose),o))}}else{const o=e.constraints[this.constraintIndex];if(o.active){const h=a?o.appliedPose:o.pose;this.set(h,this.getAbsoluteValue(s,i,r,c,this.get(h),this.get(o.data.setupPose)))}}}},Ms=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintInertia)}get(e){return e.inertia}set(e,t){e.inertia=t}global(e){return e.inertiaGlobal}},Fs=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintStrength)}get(e){return e.strength}set(e,t){e.strength=t}global(e){return e.strengthGlobal}},Ys=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintDamping)}get(e){return e.damping}set(e,t){e.damping=t}global(e){return e.dampingGlobal}},Rs=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintMass)}get(e){return 1/e.massInverse}set(e,t){e.massInverse=1/t}global(e){return e.massGlobal}},Es=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintWind),this.additive=!0}get(e){return e.wind}set(e,t){e.wind=t}global(e){return e.windGlobal}},Bs=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintGravity),this.additive=!0}get(e){return e.gravity}set(e,t){e.gravity=t}global(e){return e.gravityGlobal}},Xs=class extends Et{constructor(e,t,s){super(e,t,s,W.physicsConstraintMix)}get(e){return e.mix}set(e,t){e.mix=t}global(e){return e.mixGlobal}},Ls=class Gn extends tt{static propertyIds=[W.physicsConstraintReset.toString()];constraintIndex;constructor(t,s){super(t,...Gn.propertyIds),this.constraintIndex=s,this.instant=!0}getFrameCount(){return this.frames.length}setFrame(t,s){this.frames[t]=s}apply(t,s,n,i,r,c,l,a,o){let h;if(this.constraintIndex!==-1&&(h=t.constraints[this.constraintIndex],!h.active))return;const d=this.frames;if(s>n)this.apply(t,s,Number.MAX_VALUE,[],r,!1,!1,!1,!1),s=-1;else if(s>=d[d.length-1])return;if(!(n<d[0])&&(s<d[0]||n>=d[tt.search(d,s)+1]))if(h!=null)h.reset(t);else for(const f of t.physics)f.active&&f.reset(t)}},Vs=class extends se{constructor(e,t,s){super(e,t,s,W.sliderTime)}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(o.active){const h=a?o.appliedPose:o.pose;h.time=this.getAbsoluteValue(s,i,r,c,h.time,o.data.setupPose.time)}}},_s=class extends se{constructor(e,t,s){super(e,t,s,W.sliderMix),this.additive=!0}apply(e,t,s,n,i,r,c,l,a){const o=e.constraints[this.constraintIndex];if(o.active){const h=a?o.appliedPose:o.pose;h.mix=this.getAbsoluteValue(s,i,r,c,h.mix,o.data.setupPose.mix)}}},Os=class ln{static emptyAnimation=new Ie("<empty>",[],0);data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new wn(this);propertyIds=new ss;animationsChanged=!1;trackEntryPool=new te(()=>new bn);constructor(t){this.data=t}update(t){t*=this.timeScale;const s=this.tracks;for(let n=0,i=s.length;n<i;n++){const r=s[n];if(!r)continue;r.animationLast=r.nextAnimationLast,r.trackLast=r.nextTrackLast;let c=t*r.timeScale;if(r.delay>0){if(r.delay-=c,r.delay>0)continue;c=-r.delay,r.delay=0}let l=r.next;if(l){const a=r.trackLast-l.delay;if(a>=0){for(l.delay=0,l.trackTime+=r.timeScale===0?0:(a/r.timeScale+t)*l.timeScale,r.trackTime+=c,this.setTrack(n,l,!0);l.mixingFrom;)l.mixTime+=t,l=l.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&!r.mixingFrom){s[n]=null,this.queue.end(r),this.clearNext(r);continue}if(r.mixingFrom&&this.updateMixingFrom(r,t)){let a=r.mixingFrom;for(r.mixingFrom=null,a&&(a.mixingTo=null);a;)this.queue.end(a),a=a.mixingFrom}r.trackTime+=c}this.queue.drain()}updateMixingFrom(t,s){const n=t.mixingFrom;if(!n)return!0;const i=this.updateMixingFrom(n,s);if(n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast,t.nextTrackLast!==-1&&t.mixTime>=t.mixDuration){if(n.totalAlpha===0||t.mixDuration===0){if(t.mixingFrom=n.mixingFrom,n.mixingFrom!=null&&(n.mixingFrom.mixingTo=t),n.totalAlpha===0)for(let r=t;r.mixingTo!=null;r=r.mixingTo)r.keepHold=!0;this.queue.end(n)}return i}return n.trackTime+=s*n.timeScale,t.mixTime+=s,!1}apply(t){if(!t)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();const s=this.events,n=this.tracks;let i=!1;for(let l=0,a=n.length;l<a;l++){const o=n[l];if(!o||o.delay>0)continue;i=!0;let h=o.alpha;o.mixingFrom?h*=this.applyMixingFrom(o,t):o.trackTime>=o.trackEnd&&!o.next&&(h=0);let d=o.animationLast,f=o.getAnimationTime(),u=f,m=s;o.reverse&&(u=o.animation.duration-u,m=null);const g=o.animation.timelines,p=g.length;if(l===0&&h===1)for(let x=0;x<p;x++){L.webkit602BugfixHelper(h);const b=g[x];b instanceof ee?this.applyAttachmentTimeline(b,t,u,!0,!0):b.apply(t,d,u,m,h,!0,!1,!1,!1)}else{const x=o.timelineMode,b=h>=o.alphaAttachmentThreshold,w=o.additive,T=w||o.shortestRotation,y=!T&&o.timelinesRotation.length!==p<<1;y&&(o.timelinesRotation.length=p<<1);for(let v=0;v<p;v++){const S=g[v],C=(x[v]&ge)!==0;!T&&S instanceof ue?this.applyRotateTimeline(S,t,u,h,C,o.timelinesRotation,v<<1,y):S instanceof ee?this.applyAttachmentTimeline(S,t,u,C,b):(L.webkit602BugfixHelper(h),S.apply(t,d,u,m,h,C,w,!1,!1))}}o.reverse&&this.eventsReverse(o,d,f),this.queueEvents(o,f),s.length=0,o.nextAnimationLast=f,o.nextTrackLast=o.trackTime}const r=this.unkeyedState+Ds,c=t.slots;for(let l=0,a=t.slots.length;l<a;l++){const o=c[l];if(o.attachmentState===r){const h=o.data.attachmentName;o.pose.setAttachment(h?t.getAttachment(o.data.index,h):null)}}return this.unkeyedState+=2,this.queue.drain(),i}applyMixingFrom(t,s){const n=t.mixingFrom,i=n.mixingFrom!==null?this.applyMixingFrom(n,s):1,r=t.mix(),c=n.alpha*i,l=1-r*t.alpha,a=c*(1-r),o=l>0?a/l:c,h=n.animation.timelines,d=h.length,f=n.timelineMode,u=n.timelineHoldMix,m=r<n.mixAttachmentThreshold,g=r<n.mixDrawOrderThreshold,p=n.additive,x=p||n.shortestRotation,b=!x&&n.timelinesRotation.length!==d<<1;b&&(n.timelinesRotation.length=d<<1);const w=n.timelinesRotation;let T=n.animationLast,y=n.getAnimationTime(),v=y,S=null;n.reverse?v=n.animation.duration-v:r<n.eventThreshold&&(S=this.events),n.totalAlpha=0;for(let C=0;C<d;C++){const A=h[C],P=f[C],k=(P&ge)!==0;let F=0;if((P&xe)!==0){const R=u[C];F=R==null?o:o*(1-R.mix())}else{if(!g&&A instanceof Wt&&!k)continue;F=a}if(n.totalAlpha+=F,!x&&A instanceof ue)this.applyRotateTimeline(A,s,v,F,k,w,C<<1,b);else if(A instanceof ee)this.applyAttachmentTimeline(A,s,v,k,m&&F>=n.alphaAttachmentThreshold);else{const R=!g||!(A instanceof Wt)||!k;A.apply(s,T,v,S,F,k,p,R,!1)}}return n.reverse&&r<n.eventThreshold&&this.eventsReverse(n,T,y),t.mixDuration>0&&this.queueEvents(n,y),this.events.length=0,n.nextAnimationLast=y,n.nextTrackLast=n.trackTime,r}applyAttachmentTimeline(t,s,n,i,r){const c=s.slots[t.slotIndex];if(!c.bone.active||!r&&c.attachmentState===this.unkeyedState+Ns)return;let l=n<t.frames[0],a=null;if(l||(a=t.attachmentNames[tt.search(t.frames,n)],l=!r&&a==null),l){if(!i)return;a=c.data.attachmentName}c.pose.setAttachment(a==null?null:s.getAttachment(c.data.index,a)),r?c.attachmentState=this.unkeyedState+Ns:l||(c.attachmentState=this.unkeyedState+Ds)}applyRotateTimeline(t,s,n,i,r,c,l,a){if(a&&(c[l]=0),i===1){t.apply(s,0,n,null,1,r,!1,!1,!1);return}const o=s.bones[t.boneIndex];if(!o.active)return;const h=o.pose,d=o.data.setupPose,f=t.frames;if(n<f[0]){r&&(h.rotation=d.rotation);return}const u=r?d.rotation:h.rotation,m=d.rotation+t.getCurveValue(n);let g=0,p=m-u;if(p-=Math.ceil(p/360-.5)*360,p===0)g=c[l];else{let x=0,b=0;a?(x=0,b=p):(x=c[l],b=c[l+1]);const w=x-x%360;g=p+w;let T=p>=0,y=x>=0;Math.abs(b)<=90&&X.signum(b)!==X.signum(p)&&(Math.abs(x-w)>180?(g+=360*X.signum(x),y=T):w!==0?g-=360*X.signum(x):y=T),y!==T&&(g+=360*X.signum(x)),c[l]=g}c[l+1]=p,h.rotation=u+g*i}queueEvents(t,s){const n=t.animationStart,i=t.animationEnd,r=i-n,c=t.reverse;let l=t.trackLast%r;c&&(l=r-l);const a=this.events;let o=0,h=a.length;for(;o<h;o++){const f=a[o];if(f.time<l!==c)break;f.time>=n&&f.time<=i&&this.queue.event(t,f)}let d=!1;if(t.loop)if(r===0)d=!0;else{const f=Math.floor(t.trackTime/r);d=f>0&&f>Math.floor(t.trackLast/r)}else d=s>=i&&t.animationLast<i;for(d&&this.queue.complete(t);o<h;o++){const f=a[o];f.time>=n&&f.time<=i&&this.queue.event(t,f)}}eventsReverse(t,s,n){const i=t.animation.duration,r=i-s,c=i-n,l=t.animation.timelines;for(let a=0,o=t.animation.timelines.length;a<o;a++){const h=l[a];if(!(h instanceof Me))continue;const d=h.events,f=h.frames,u=f.length;if(r>=c){for(let m=0;m<u;m++)if(!(f[m]<c)){if(f[m]>=r)break;this.events.push(d[m])}}else{for(let g=0;g<u&&!(f[g]>=r);g++)this.events.push(d[g]);let m=0;for(;m<u&&!(f[m]>=c);m++);for(;m<u;m++)this.events.push(d[m])}}}clearTracks(){const t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let s=0,n=this.tracks.length;s<n;s++)this.clearTrack(s);this.tracks.length=0,this.queue.drainDisabled=t,this.queue.drain()}clearTrack(t){if(t<0)throw new Error("trackIndex must be >= 0.");if(t>=this.tracks.length)return;const s=this.tracks[t];if(!s)return;this.queue.end(s),this.clearNext(s);let n=s;for(;;){const i=n.mixingFrom;if(!i)break;this.queue.end(i),n.mixingFrom=null,n.mixingTo=null,n=i}this.tracks[s.trackIndex]=null,this.queue.drain()}setTrack(t,s,n){const i=this.expandToIndex(t);this.tracks[t]=s,s.previous=null,i&&(i.next=null,n&&this.queue.interrupt(i),s.mixingFrom=i,i.mixingTo=s,s.mixTime=0,i.timelinesRotation.length=0),this.queue.start(s)}setAnimation(t,s,n=!1){return typeof s=="string"?this.setAnimation1(t,s,n):this.setAnimation2(t,s,n)}setAnimation1(t,s,n=!1){const i=this.data.skeletonData.findAnimation(s);if(!i)throw new Error(`Animation not found: ${s}`);return this.setAnimation2(t,i,n)}setAnimation2(t,s,n=!1){if(t<0)throw new Error("trackIndex must be >= 0.");if(!s)throw new Error("animation cannot be null.");let i=!0,r=this.expandToIndex(t);r&&(r.nextTrackLast===-1&&r.animation===s?(this.tracks[t]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.clearNext(r),r=r.mixingFrom,i=!1):this.clearNext(r));const c=this.trackEntry(t,s,n,r);return this.setTrack(t,c,i),this.queue.drain(),c}addAnimation(t,s,n=!1,i=0){return typeof s=="string"?this.addAnimation1(t,s,n,i):this.addAnimation2(t,s,n,i)}addAnimation1(t,s,n=!1,i=0){const r=this.data.skeletonData.findAnimation(s);if(!r)throw new Error(`Animation not found: ${s}`);return this.addAnimation2(t,r,n,i)}addAnimation2(t,s,n=!1,i=0){if(t<0)throw new Error("trackIndex must be >= 0.");if(!s)throw new Error("animation cannot be null.");let r=this.expandToIndex(t);if(r)for(;r.next;)r=r.next;const c=this.trackEntry(t,s,n,r);return r?(r.next=c,c.previous=r,i<=0&&(i=Math.max(i+r.getTrackComplete()-c.mixDuration,0))):(this.setTrack(t,c,!0),this.queue.drain(),i<0&&(i=0)),c.delay=i,c}setEmptyAnimation(t,s=0){const n=this.setAnimation(t,ln.emptyAnimation,!1);return n.mixDuration=s,n.trackEnd=s,n}addEmptyAnimation(t,s=0,n=0){const i=this.addAnimation(t,ln.emptyAnimation,!1,n);return n<=0&&(i.delay=Math.max(i.delay+i.mixDuration-s,0)),i.mixDuration=s,i.trackEnd=s,i}setEmptyAnimations(t=0){const s=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(let n=0,i=this.tracks.length;n<i;n++){const r=this.tracks[n];r&&this.setEmptyAnimation(r.trackIndex,t)}this.queue.drainDisabled=s,this.queue.drain()}expandToIndex(t){return t<this.tracks.length?this.tracks[t]:(L.ensureArrayCapacity(this.tracks,t+1,null),this.tracks.length=t+1,null)}trackEntry(t,s,n,i){const r=this.trackEntryPool.obtain();return r.reset(),r.trackIndex=t,r.animation=s,r.loop=n,r.additive=!1,r.reverse=!1,r.shortestRotation=!1,r.eventThreshold=0,r.alphaAttachmentThreshold=0,r.mixAttachmentThreshold=0,r.mixDrawOrderThreshold=0,r.animationStart=0,r.animationEnd=s.duration,r.animationLast=-1,r.nextAnimationLast=-1,r.delay=0,r.trackTime=0,r.trackLast=-1,r.nextTrackLast=-1,r.trackEnd=Number.MAX_VALUE,r.timeScale=1,r.alpha=1,r.mixTime=0,r.mixDuration=i?this.data.getMix(i.animation,s):0,r.totalAlpha=0,r.keepHold=!1,r}clearNext(t){let s=t.next;for(;s;)this.queue.dispose(s),s=s.next;t.next=null}_animationsChanged(){this.animationsChanged=!1;const t=this.tracks;for(let s=0,n=t.length;s<n;s++){let i=t[s];if(i){for(;i.mixingFrom;)i=i.mixingFrom;do this.computeHold(i),i=i.mixingTo;while(i)}}this.propertyIds.clear()}computeHold(t){const s=t.animation.timelines,n=t.animation.timelines.length,i=t.timelineMode;i.length=n;const r=t.timelineHoldMix;r.length=0;const c=this.propertyIds,l=t.additive,a=t.keepHold,o=t.mixingTo;t:for(let h=0;h<n;h++){const d=s[h],f=d.propertyIds,u=c.addAll(f)&&!(d instanceof pe&&c.contains(Wt.propertyID));if(l&&d.additive){i[h]=u?ge:Fe;continue}for(let g=t.mixingFrom;g!=null;g=g.mixingFrom)if(g.animation.hasTimeline(f)){i[h]=Fe;continue t}let m;if(o===null||d.instant||o.additive&&d.additive||!o.animation?.hasTimeline(f))m=u?ge:Fe;else{m=u?yn:xe;for(let g=o.mixingTo;g!=null;g=g.mixingTo)if(g.additive&&d.additive||!g.animation?.hasTimeline(f)){g.mixDuration>0&&(r[h]=g);break}}a&&(m=m&~xe|i[h]&xe),i[h]=m}}getTrack(t){if(t<0)throw new Error("trackIndex must be >= 0.");return t>=this.tracks.length?null:this.tracks[t]}addListener(t){if(!t)throw new Error("listener cannot be null.");this.listeners.push(t)}removeListener(t){const s=this.listeners.indexOf(t);s>=0&&this.listeners.splice(s,1)}clearListeners(){this.listeners.length=0}clearListenerNotifications(){this.queue.clear()}},bn=class{animation=null;previous=null;next=null;mixingFrom=null;mixingTo=null;listener=null;trackIndex=0;loop=!1;additive=!1;reverse=!1;shortestRotation=!1;keepHold=!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;totalAlpha=0;mixInterpolation=he.linear;setMixDuration(e,t){this.mixDuration=e,t!==void 0&&(t<=0&&(t=this.previous==null?0:Math.max(t+this.previous.getTrackComplete()-e,0)),this.delay=t)}setMixInterpolation(e){if(!e)throw new Error("mixInterpolation cannot be null.");this.mixInterpolation=e}mix(){if(this.mixDuration===0)return 1;let e=this.mixTime/this.mixDuration;return e>=1?1:this.mixInterpolation===he.linear?e:(e=this.mixInterpolation.apply(e),e<0?0:e>1?1:e)}timelineMode=[];timelineHoldMix=[];timelinesRotation=[];reset(){this.next=null,this.previous=null,this.mixingFrom=null,this.mixingTo=null,this.mixInterpolation=he.linear,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0}getAnimationTime(){if(!this.loop)return Math.min(this.trackTime+this.animationStart,this.animationEnd);const e=this.animationEnd-this.animationStart;return e===0?this.animationStart:this.trackTime%e+this.animationStart}setAnimationLast(e){this.animationLast=e,this.nextAnimationLast=e}isComplete(){return this.trackTime>=this.animationEnd-this.animationStart}resetRotationDirections(){this.timelinesRotation.length=0}getTrackComplete(){const e=this.animationEnd-this.animationStart;if(e!==0){if(this.loop)return e*(1+(this.trackTime/e|0));if(this.trackTime<e)return e}return this.trackTime}wasApplied(){return this.nextTrackLast!==-1}isNextReady(){return this.next!=null&&this.nextTrackLast-this.next.delay>=0}},wn=class{objects=[];drainDisabled=!1;animState;constructor(e){this.animState=e}start(e){this.objects.push(ft.start),this.objects.push(e),this.animState.animationsChanged=!0}interrupt(e){this.objects.push(ft.interrupt),this.objects.push(e)}end(e){this.objects.push(ft.end),this.objects.push(e),this.animState.animationsChanged=!0}dispose(e){this.objects.push(ft.dispose),this.objects.push(e)}complete(e){this.objects.push(ft.complete),this.objects.push(e)}event(e,t){this.objects.push(ft.event),this.objects.push(e),this.objects.push(t)}drain(){if(!this.drainDisabled){this.drainDisabled=!0;for(let e=0;e<this.objects.length;e+=2){const t=this.objects,s=t[e],n=t[e+1],i=this.animState.listeners.slice();switch(s){case ft.start:n.listener?.start&&n.listener.start(n);for(let r=0;r<i.length;r++){const c=i[r];c.start&&c.start(n)}break;case ft.interrupt:n.listener?.interrupt&&n.listener.interrupt(n);for(let r=0;r<i.length;r++){const c=i[r];c.interrupt&&c.interrupt(n)}break;case ft.end:n.listener?.end&&n.listener.end(n);for(let r=0;r<i.length;r++){const c=i[r];c.end&&c.end(n)}case ft.dispose:n.listener?.dispose&&n.listener.dispose(n);for(let r=0;r<i.length;r++){const c=i[r];c.dispose&&c.dispose(n)}this.animState.trackEntryPool.free(n);break;case ft.complete:n.listener?.complete&&n.listener.complete(n);for(let r=0;r<i.length;r++){const c=i[r];c.complete&&c.complete(n)}break;case ft.event:{const r=t[e+++2];n.listener?.event&&n.listener.event(n,r);for(let c=0;c<i.length;c++){const l=i[c];l.event&&l.event(n,r)}break}}}this.clear(),this.drainDisabled=!1}}clear(){this.objects.length=0}},ft;(function(e){e[e.start=0]="start",e[e.interrupt=1]="interrupt",e[e.end=2]="end",e[e.dispose=3]="dispose",e[e.complete=4]="complete",e[e.event=5]="event"})(ft||(ft={}));var xi=class{start(e){}interrupt(e){}end(e){}dispose(e){}complete(e){}event(e,t){}},Fe=0,ge=1,xe=2,yn=3,Ds=1,Ns=2,vn=class{skeletonData;animationToMixTime={};defaultMix=0;constructor(e){if(!e)throw new Error("skeletonData cannot be null.");this.skeletonData=e}setMix(e,t,s){return typeof e=="string"?this.setMix1(e,t,s):this.setMix2(e,t,s)}setMix1(e,t,s){const n=this.skeletonData.findAnimation(e);if(!n)throw new Error(`Animation not found: ${e}`);const i=this.skeletonData.findAnimation(t);if(!i)throw new Error(`Animation not found: ${t}`);this.setMix2(n,i,s)}setMix2(e,t,s){if(!e)throw new Error("from cannot be null.");if(!t)throw new Error("to cannot be null.");const n=`${e.name}.${t.name}`;this.animationToMixTime[n]=s}getMix(e,t){const s=`${e.name}.${t.name}`,n=this.animationToMixTime[s];return n===void 0?this.defaultMix:n}},bi=class{textureLoader;pathPrefix;downloader;cache;errors={};toLoad=0;loaded=0;texturePmaInfo={};constructor(e,t="",s=new Sn,n=new Tn){this.textureLoader=e,this.pathPrefix=t,this.downloader=s,this.cache=n}start(e){return this.toLoad++,this.pathPrefix+e}success(e,t,s){this.toLoad--,this.loaded++,this.cache.assets[t]=s,this.cache.assetsRefCount[t]=(this.cache.assetsRefCount[t]||0)+1,e&&e(t,s)}error(e,t,s){this.toLoad--,this.loaded++,this.errors[t]=s,e&&e(t,s)}loadAll(){return new Promise((t,s)=>{const n=()=>{if(this.isLoadingComplete()){this.hasErrors()?s(this.errors):t(this);return}requestAnimationFrame(n)};requestAnimationFrame(n)})}setRawDataURI(e,t){this.downloader.rawDataUris[this.pathPrefix+e]=t}loadBinary(e,t=()=>{},s=()=>{}){e=this.start(e),!this.reuseAssets(e,t,s)&&(this.cache.assetsLoaded[e]=new Promise((n,i)=>{this.downloader.downloadBinary(e,r=>{this.success(t,e,r),n(r)},(r,c)=>{const l=`Couldn't load binary ${e}: status ${r}, ${c}`;this.error(s,e,l),i(l)})}))}loadText(e,t=()=>{},s=()=>{}){e=this.start(e),this.downloader.downloadText(e,n=>{this.success(t,e,n)},(n,i)=>{this.error(s,e,`Couldn't load text ${e}: status ${n}, ${i}`)})}loadJson(e,t=()=>{},s=()=>{}){e=this.start(e),!this.reuseAssets(e,t,s)&&(this.cache.assetsLoaded[e]=new Promise((n,i)=>{this.downloader.downloadJson(e,r=>{this.success(t,e,r),n(r)},(r,c)=>{const l=`Couldn't load JSON ${e}: status ${r}, ${c}`;this.error(s,e,l),i(l)})}))}reuseAssets(e,t=()=>{},s=()=>{}){const n=this.cache.getAsset(e),i=n!==void 0;return i&&(this.cache.assetsLoaded[e]=n.then(r=>(r=r instanceof Image||r instanceof ImageBitmap?this.textureLoader(r):r,this.success(t,e,r),r)).catch(r=>{this.error(s,e,r)})),i}loadTexture(e,t=()=>{},s=()=>{}){if(e=this.start(e),this.reuseAssets(e,t,s))return;const n=this.texturePmaInfo[e];this.cache.assetsLoaded[e]=new Promise((i,r)=>{if(!!!(typeof window<"u"&&typeof navigator<"u"&&window.document))fetch(e,{mode:"cors"}).then(a=>{if(a.ok)return a.blob();const o=`Couldn't load image: ${e}`;this.error(s,e,`Couldn't load image: ${e}`),r(o)}).then(a=>a?createImageBitmap(a,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(a=>{if(a){const o=this.createTexture(e,n,a);this.success(t,e,o),i(o)}});else{const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const o=this.createTexture(e,n,a);this.success(t,e,o),i(o)},a.onerror=()=>{const o=`Couldn't load image: ${e}`;this.error(s,e,o),r(o)},this.downloader.rawDataUris[e]&&(e=this.downloader.rawDataUris[e]),a.src=e}})}loadTextureAtlas(e,t=()=>{},s=()=>{},n){const i=e.lastIndexOf("/"),r=i>=0?e.substring(0,i+1):"";e=this.start(e),!this.reuseAssets(e,t,s)&&(this.cache.assetsLoaded[e]=new Promise((c,l)=>{this.downloader.downloadText(e,a=>{try{const o=this.createTextureAtlas(a,r,e,n);let h=o.pages.length,d=!1;if(h===0){this.success(t,e,o),c(o);return}for(const f of o.pages)this.loadTexture(this.texturePath(r,f.name,n),(u,m)=>{d||(f.setTexture(m),--h===0&&(this.success(t,e,o),c(o)))},(u,m)=>{if(!d){const g=`Couldn't load texture ${e} page image: ${u}`;this.error(s,e,g),l(g)}d=!0})}catch(o){const h=`Couldn't parse texture atlas ${e}: ${o.message}`;this.error(s,e,h),l(h)}},(a,o)=>{const h=`Couldn't load texture atlas ${e}: status ${a}, ${o}`;this.error(s,e,h),l(h)})}))}loadTextureAtlasButNoTextures(e,t=()=>{},s=()=>{}){const n=e.lastIndexOf("/"),i=n>=0?e.substring(0,n+1):"";e=this.start(e),!this.reuseAssets(e,t,s)&&(this.cache.assetsLoaded[e]=new Promise((r,c)=>{this.downloader.downloadText(e,l=>{try{const a=this.createTextureAtlas(l,i,e);this.success(t,e,a),r(a)}catch(a){const o=`Couldn't parse texture atlas ${e}: ${a.message}`;this.error(s,e,o),c(o)}},(l,a)=>{const o=`Couldn't load texture atlas ${e}: status ${l}, ${a}`;this.error(s,e,o),c(o)})}))}async loadBinaryAsync(e){return new Promise((t,s)=>{this.loadBinary(e,(n,i)=>t(i),(n,i)=>s(i))})}async loadJsonAsync(e){return new Promise((t,s)=>{this.loadJson(e,(n,i)=>t(i),(n,i)=>s(i))})}async loadTextureAsync(e){return new Promise((t,s)=>{this.loadTexture(e,(n,i)=>t(i),(n,i)=>s(i))})}async loadTextureAtlasAsync(e){return new Promise((t,s)=>{this.loadTextureAtlas(e,(n,i)=>t(i),(n,i)=>s(i))})}async loadTextureAtlasButNoTexturesAsync(e){return new Promise((t,s)=>{this.loadTextureAtlasButNoTextures(e,(n,i)=>t(i),(n,i)=>s(i))})}setCache(e){this.cache=e}get(e){return this.cache.assets[this.pathPrefix+e]}require(e){e=this.pathPrefix+e;const t=this.cache.assets[e];if(t)return t;const s=this.errors[e];throw Error(`Asset not found: ${e}${s?`
${s}`:""}`)}remove(e){e=this.pathPrefix+e;const t=this.cache.assets[e];return t.dispose&&t.dispose(),delete this.cache.assets[e],delete this.cache.assetsRefCount[e],delete this.cache.assetsLoaded[e],t}removeAll(){for(const e in this.cache.assets){const t=this.cache.assets[e];t.dispose&&t.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(e){const t=this.cache.assets[e];if(t instanceof Pe){t.dispose();return}this.disposeAssetInternal(e)}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}disposeAssetInternal(e){if(this.cache.assetsRefCount[e]>0&&--this.cache.assetsRefCount[e]===0)return this.remove(e)}createTextureAtlas(e,t,s,n){const i=new Pe(e);i.dispose=()=>{if(!(this.cache.assetsRefCount[s]<=0)){this.disposeAssetInternal(s);for(const r of i.pages)r.texture?.dispose()}};for(const r of i.pages){const c=this.texturePath(t,r.name,n);this.texturePmaInfo[this.pathPrefix+c]=r.pma}return i}createTexture(e,t,s){const n=this.textureLoader(s,t),i=n.dispose.bind(n);return n.dispose=()=>{this.disposeAssetInternal(e)&&i()},n}texturePath(e,t,s){return s?s[t]:e+t}},Tn=class Qe{assets={};assetsRefCount={};assetsLoaded={};static AVAILABLE_CACHES=new Map;static getCache(t){const s=Qe.AVAILABLE_CACHES.get(t);if(s)return s;const n=new Qe;return Qe.AVAILABLE_CACHES.set(t,n),n}async addAsset(t,s){return this.assetsLoaded[t]=Promise.resolve(s),this.assets[t]=s,s}getAsset(t){return this.assetsLoaded[t]}},Sn=class{callbacks={};rawDataUris={};dataUriToString(e){if(!e.startsWith("data:"))throw new Error("Not a data URI.");let t=e.indexOf("base64,");return t!==-1?(t+=7,atob(e.substr(t))):e.substr(e.indexOf(",")+1)}base64ToUint8Array(e){var t=window.atob(e),s=t.length,n=new Uint8Array(s);for(let i=0;i<s;i++)n[i]=t.charCodeAt(i);return n}dataUriToUint8Array(e){if(!e.startsWith("data:"))throw new Error("Not a data URI.");let t=e.indexOf("base64,");if(t===-1)throw new Error("Not a binary data URI.");return t+=7,this.base64ToUint8Array(e.substr(t))}downloadText(e,t,s){if(this.start(e,t,s))return;const n=this.rawDataUris[e];if(n&&!n.includes(".")){try{this.finish(e,200,this.dataUriToString(n))}catch(c){this.finish(e,400,JSON.stringify(c))}return}const i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",n||e,!0);const r=()=>{this.finish(e,i.status,i.responseText)};i.onload=r,i.onerror=r,i.send()}downloadJson(e,t,s){this.downloadText(e,n=>{t(JSON.parse(n))},s)}downloadBinary(e,t,s){if(this.start(e,t,s))return;const n=this.rawDataUris[e];if(n&&!n.includes(".")){try{this.finish(e,200,this.dataUriToUint8Array(n))}catch(c){this.finish(e,400,JSON.stringify(c))}return}const i=new XMLHttpRequest;i.open("GET",n||e,!0),i.responseType="arraybuffer";const r=()=>{this.finish(e,i.status,i.response)};i.onload=()=>{i.status===200||i.status===0?this.finish(e,200,new Uint8Array(i.response)):r()},i.onerror=r,i.send()}start(e,t,s){let n=this.callbacks[e];try{if(n)return!0;this.callbacks[e]=n=[]}finally{n.push(t,s)}}finish(e,t,s){const n=this.callbacks[e];if(delete this.callbacks[e],t===200||t===0)for(let i=0,r=n.length;i<r;i+=2)n[i](s);else for(let i=1,r=n.length;i<r;i+=2)n[i](t,s)}},Us=class Hn extends Ot{color=new $(1,1,1,1);constructor(t){super(t)}copy(){const t=new Hn(this.name);return this.copyTo(t),t.color.setFromColor(this.color),t}},Bt=class jn extends Ot{endSlot=null;convex=!1;inverse=!1;color=new $(.2275,.2275,.8078,1);constructor(t){super(t)}copy(){const t=new jn(this.name);return this.copyTo(t),t.endSlot=this.endSlot,t.convex=this.convex,t.inverse=this.inverse,t.color.setFromColor(this.color),t}},be=class Jn extends Ot{lengths=[];closed=!1;constantSpeed=!1;color=new $(1,1,1,1);constructor(t){super(t)}copy(){const t=new Jn(this.name);return this.copyTo(t),t.lengths=[],L.arrayCopy(this.lengths,0,t.lengths,0,this.lengths.length),t.closed=this.closed,t.constantSpeed=this.constantSpeed,t.color.setFromColor(this.color),t}},Cn=class Kn extends Ot{x=0;y=0;rotation=0;color=new $(.38,.94,0,1);constructor(t){super(t)}computeWorldPosition(t,s){return s.x=this.x*t.a+this.y*t.b+t.worldX,s.y=this.x*t.c+this.y*t.d+t.worldY,s}computeWorldRotation(t){const s=this.rotation*X.degRad,n=Math.cos(s),i=Math.sin(s),r=n*t.a+i*t.b,c=n*t.c+i*t.d;return X.atan2Deg(c,r)}copy(){const t=new Kn(this.name);return t.x=this.x,t.y=this.y,t.rotation=this.rotation,t.color.setFromColor(this.color),t}},An=class{atlas;allowMissingRegions;constructor(e,t=!1){this.atlas=e,this.allowMissingRegions=t}findRegions(e,t,s){const n=s.regions;for(let i=0,r=n.length;i<r;i++)n[i]=this.findRegion(e,s.getPath(t,i))}findRegion(e,t){const s=this.atlas.findRegion(t);if(!s&&!this.allowMissingRegions)throw new Error(`Region not found in atlas: ${t} (attachment: ${e})`);return s}newRegionAttachment(e,t,s,n,i){return this.findRegions(s,n,i),new H(s,i)}newMeshAttachment(e,t,s,n,i){return this.findRegions(s,n,i),new pt(s,i)}newBoundingBoxAttachment(e,t,s){return new Us(s)}newPathAttachment(e,t,s){return new be(s)}newPointAttachment(e,t,s){return new Cn(s)}newClippingAttachment(e,t,s){return new Bt(s)}},Ye=class{name;setupPose;skinRequired=!1;constructor(e,t){if(e==null)throw new Error("name cannot be null.");this.name=e,this.setupPose=t}},qs=class Qn extends Ye{index=0;parent=null;length=0;color=new $;icon;iconSize=1;iconRotation=0;visible=!1;constructor(t,s,n){if(super(s,new Re),t<0)throw new Error("index must be >= 0.");if(!s)throw new Error("name cannot be null.");this.index=t,this.parent=n}copy(t){const s=new Qn(this.index,this.name,t);return s.length=this.length,s.setupPose.set(this.setupPose),s}},et;(function(e){e[e.Normal=0]="Normal",e[e.OnlyTranslation=1]="OnlyTranslation",e[e.NoRotationOrReflection=2]="NoRotationOrReflection",e[e.NoScale=3]="NoScale",e[e.NoScaleOrReflection=4]="NoScaleOrReflection"})(et||(et={}));var Re=class{bone;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;inherit=et.Normal;a=0;b=0;c=0;d=0;worldY=0;worldX=0;world=0;local=0;set(e){if(e==null)throw new Error("pose cannot be null.");this.x=e.x,this.y=e.y,this.rotation=e.rotation,this.scaleX=e.scaleX,this.scaleY=e.scaleY,this.shearX=e.shearX,this.shearY=e.shearY,this.inherit=e.inherit}setPosition(e,t){this.x=e,this.y=t}setScale(e,t){this.scaleX=e,this.scaleY=t===void 0?e:t}getInherit(){return this.inherit}setInherit(e){if(e==null)throw new Error("inherit cannot be null.");this.inherit=e}update(e,t){this.world!==e._update&&this.updateWorldTransform(e)}updateWorldTransform(e){this.local===e._update?this.updateLocalTransform(e):this.world=e._update;const t=this.rotation,s=this.scaleX,n=this.scaleY,i=this.shearX,r=this.shearY;if(!this.bone.parent){const d=e.scaleX,f=e.scaleY,u=(t+i)*X.degRad,m=(t+90+r)*X.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(m)*n*d,this.c=Math.sin(u)*s*f,this.d=Math.sin(m)*n*f,this.worldX=this.x*d+e.x,this.worldY=this.y*f+e.y;return}const c=this.bone.parent.appliedPose;let l=c.a,a=c.b,o=c.c,h=c.d;switch(this.worldX=l*this.x+a*this.y+c.worldX,this.worldY=o*this.x+h*this.y+c.worldY,this.inherit){case et.Normal:{const d=(t+i)*X.degRad,f=(t+90+r)*X.degRad,u=Math.cos(d)*s,m=Math.cos(f)*n,g=Math.sin(d)*s,p=Math.sin(f)*n;this.a=l*u+a*g,this.b=l*m+a*p,this.c=o*u+h*g,this.d=o*m+h*p;return}case et.OnlyTranslation:{const d=e.scaleX,f=e.scaleY,u=(t+i)*X.degRad,m=(t+90+r)*X.degRad;this.a=Math.cos(u)*s*d,this.b=Math.cos(m)*n*d,this.c=Math.sin(u)*s*f,this.d=Math.sin(m)*n*f;break}case et.NoRotationOrReflection:{const d=e.scaleX,f=e.scaleY,u=1/d,m=1/f;l*=u,o*=m;let g=l*l+o*o,p=0;g>X.epsilon2?(g=Math.abs(l*h*m-a*u*o)/g,a=o*g,h=l*g,p=t-X.atan2Deg(o,l)):(l=0,o=0,p=t-90+X.atan2Deg(h,a));const x=(p+i)*X.degRad,b=(p+r+90)*X.degRad,w=Math.cos(x)*s,T=Math.cos(b)*n,y=Math.sin(x)*s,v=Math.sin(b)*n;this.a=(l*w-a*y)*d,this.b=(l*T-a*v)*d,this.c=(o*w+h*y)*f,this.d=(o*T+h*v)*f;break}case et.NoScale:case et.NoScaleOrReflection:{const d=e.scaleX,f=e.scaleY,u=1/d,m=1/f,g=t*X.degRad,p=Math.cos(g),x=Math.sin(g);let b=(l*p+a*x)*u,w=(o*p+h*x)*m;const T=1/Math.sqrt(b*b+w*w);b*=T,w*=T;let y=-w,v=b;this.inherit===et.NoScale&&l*h-a*o<0!=(d<0!=f<0)&&(y=-y,v=-v);const S=i*X.degRad,C=(90+r)*X.degRad,A=Math.cos(S)*s,P=Math.cos(C)*n,k=Math.sin(S)*s,F=Math.sin(C)*n;this.a=(b*A+y*k)*d,this.b=(b*P+y*F)*d,this.c=(w*A+v*k)*f,this.d=(w*P+v*F)*f;break}}}updateLocalTransform(e){this.local=0,this.world=e._update;const t=e.scaleX,s=e.scaleY;if(!this.bone.parent){const p=1/t,x=1/s;this.x=(this.worldX-e.x)*p,this.y=(this.worldY-e.y)*x,this.set5(this.a*p,this.b*p,this.c*x,this.d*x,0);return}const n=this.bone.parent.appliedPose;let i=n.a,r=n.b,c=n.c,l=n.d;const a=i*l-r*c,o=1/(i*l-r*c),h=l*o,d=r*o,f=c*o,u=i*o,m=this.worldX-n.worldX,g=this.worldY-n.worldY;switch(this.x=m*h-g*d,this.y=g*u-m*f,this.inherit){case et.Normal:this.set5(h*this.a-d*this.c,h*this.b-d*this.d,u*this.c-f*this.a,u*this.d-f*this.b,0);break;case et.OnlyTranslation:{const p=1/t,x=1/s;this.set5(this.a*p,this.b*p,this.c*x,this.d*x,0);break}case et.NoRotationOrReflection:{const p=1/t,x=1/s;i*=p,c*=x;const b=this.a*p,w=this.b*p,T=this.c*x,y=this.d*x,v=1/(i*i+c*c),S=1/Math.abs(a*p*x);this.set5((i*b+c*T)*v,(i*w+c*y)*v,(i*T-c*b)*S,(i*y-c*w)*S,X.atan2Deg(c,i));break}case et.NoScale:case et.NoScaleOrReflection:{const p=1/t,x=1/s,b=this.a*p,w=this.b*p,T=this.c*x,y=this.d*x;let v=l*this.a-r*this.c,S=i*this.c-c*this.a;a<0&&(v=-v,S=-S);let C=X.atan2Deg(S,v);this.rotation=C,C*=X.degRad;const A=Math.cos(C),P=Math.sin(C);let k=(i*A+r*P)*p,F=(c*A+l*P)*x;const R=1/Math.sqrt(k*k+F*F);k*=R,F*=R;const E=this.inherit===et.NoScale&&a<0!=(t<0!=s<0)?-1:1;this.set4(k*b+F*T,k*w+F*y,(k*T-F*b)*E,(k*y-F*w)*E)}}}set4(e,t,s,n){const i=e*e+s*s,r=t*t+n*n;i>X.epsilon2?(this.shearX=X.atan2Deg(s,e),this.scaleX=Math.sqrt(i)):(this.shearX=0,this.scaleX=0),this.scaleY=Math.sqrt(r),r>X.epsilon2?(this.shearY=X.atan2Deg(n,t),e*n-t*s<0?(this.scaleY=-this.scaleY,this.shearY+=90):this.shearY-=90,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}set5(e,t,s,n,i){this.shearX=0;const r=e*e+s*s,c=t*t+n*n;if(r>X.epsilon2){const l=X.atan2Deg(s,e);this.rotation=l+i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(c),c>X.epsilon2?(this.shearY=X.atan2Deg(n,t),e*n-t*s<0?(this.scaleY=-this.scaleY,this.shearY+=90-l):this.shearY-=90+l,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}else this.scaleX=0,this.scaleY=Math.sqrt(c),this.shearY=0,this.rotation=c>X.epsilon2?X.atan2Deg(n,t)-90+i:i}validateLocalTransform(e){this.local===e._update&&this.updateLocalTransform(e)}modifyLocal(e){this.local===e._update&&this.updateLocalTransform(e),this.world=0,this.resetWorld(e._update)}modifyWorld(e){this.local=e,this.world=e,this.resetWorld(e)}resetWorld(e){const t=this.bone.children;for(let s=0,n=t.length;s<n;s++){const i=t[s].appliedPose;i.world===e&&(i.world=0,i.local=0,i.resetWorld(e))}}getWorldRotationX(){return X.atan2Deg(this.c,this.a)}getWorldRotationY(){return X.atan2Deg(this.d,this.b)}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(e){if(e==null)throw new Error("world cannot be null.");const t=this.a*this.d-this.b*this.c,s=e.x-this.worldX,n=e.y-this.worldY;return e.x=(s*this.d-n*this.b)/t,e.y=(n*this.a-s*this.c)/t,e}localToWorld(e){if(e==null)throw new Error("local cannot be null.");const t=e.x,s=e.y;return e.x=t*this.a+s*this.b+this.worldX,e.y=t*this.c+s*this.d+this.worldY,e}worldToParent(e){if(e==null)throw new Error("world cannot be null.");return this.bone.parent==null?e:this.bone.parent.appliedPose.worldToLocal(e)}parentToWorld(e){if(e==null)throw new Error("world cannot be null.");return this.bone.parent==null?e:this.bone.parent.appliedPose.localToWorld(e)}worldToLocalRotation(e){e*=X.degRad;const t=Math.sin(e),s=Math.cos(e);return X.atan2Deg(this.a*t-this.c*s,this.d*s-this.b*t)+this.rotation-this.shearX}localToWorldRotation(e){e=(e-this.rotation-this.shearX)*X.degRad;const t=Math.sin(e),s=Math.cos(e);return X.atan2Deg(s*this.c+t*this.d,s*this.a+t*this.b)}rotateWorld(e){e*=X.degRad;const t=Math.sin(e),s=Math.cos(e),n=this.a,i=this.b;this.a=s*n-t*this.c,this.b=s*i-t*this.d,this.c=t*n+s*this.c,this.d=t*i+s*this.d}},$s=class{data;pose;constrainedPose;appliedPose;constructor(e,t,s){if(e==null)throw new Error("data cannot be null.");this.data=e,this.pose=t,this.constrainedPose=s,this.appliedPose=t}setupPose(){this.pose.set(this.data.setupPose)}getData(){return this.data}getPose(){return this.pose}getAppliedPose(){return this.appliedPose}unconstrained(){this.appliedPose=this.pose}constrained(){this.appliedPose=this.constrainedPose}resetConstrained(){this.constrainedPose.set(this.pose)}},zs=class extends $s{active=!1;constructor(e,t,s){super(e,t,s),this.setupPose()}isActive(){return this.active}},Ee=class Zn extends zs{parent=null;children=[];sorted=!1;constructor(t,s){super(t,new Re,new Re),this.parent=s,this.appliedPose.bone=this,this.constrainedPose.bone=this}copy(t){const s=new Zn(this.data,t);return s.pose.set(this.pose),s}},ne=class extends zs{constructor(e,t,s){super(e,t,s)}isSourceActive(){return!0}},Pn=class{_setupPose;pose;constrainedPose;appliedPose;constructor(e){this._setupPose=e,this.pose=[...e],this.constrainedPose=[],this.appliedPose=this.pose}setupPose(){this.pose.length=this._setupPose.length,L.arrayCopy(this._setupPose,0,this.pose,0,this._setupPose.length)}unconstrained(){this.appliedPose=this.pose}constrained(){this.appliedPose=this.constrainedPose}resetConstrained(){this.constrainedPose.length=this.pose.length,L.arrayCopy(this.pose,0,this.constrainedPose,0,this.pose.length)}},ie=class extends Ye{constructor(e,t){super(e,t)}},ct;(function(e){e[e.None=0]="None",e[e.Uniform=1]="Uniform",e[e.Volume=2]="Volume"})(ct||(ct={}));var Be=class{time=0;data;intValue=0;floatValue=0;stringValue=null;volume=0;balance=0;constructor(e,t){if(!t)throw new Error("data cannot be null.");this.time=e,this.data=t}},Ws=class{name;_audioPath=null;get audioPath(){return this._audioPath}set audioPath(e){if(e==null)throw new Error("audioPath cannot be null.");this._audioPath=e}setupPose=new Be(-1,this);constructor(e){this.name=e}},Xe=class{bendDirection=0;compress=!1;stretch=!1;mix=0;softness=0;set(e){this.mix=e.mix,this.softness=e.softness,this.bendDirection=e.bendDirection,this.compress=e.compress,this.stretch=e.stretch}},In=class Qt extends ne{bones;target;constructor(t,s){if(super(t,new Xe,new Xe),!s)throw new Error("skeleton cannot be null.");this.bones=[];for(const n of t.bones)this.bones.push(s.bones[n.index].constrainedPose);this.target=s.bones[t.target.index]}copy(t){var s=new Qt(this.data,t);return s.pose.set(this.pose),s}update(t,s){const n=this.appliedPose;if(n.mix===0)return;const i=this.target.appliedPose,r=this.bones;switch(r.length){case 1:Qt.apply(t,r[0],i.worldX,i.worldY,n.compress,n.stretch,this.data.scaleYMode,n.mix);break;case 2:Qt.apply(t,r[0],r[1],i.worldX,i.worldY,n.bendDirection,n.stretch,this.data.scaleYMode,n.softness,n.mix);break}}sort(t){t.sortBone(this.target);const s=this.bones[0].bone;t.sortBone(s),t._updateCache.push(this),s.sorted=!1,t.sortReset(s.children),t.constrained(s),this.bones.length>1&&t.constrained(this.bones[1].bone)}isSourceActive(){return this.target.active}static apply(t,s,n,i,r,c,l,a,o,h){typeof n=="number"?Qt.apply1(t,s,n,i,r,c,l,a):Qt.apply2(t,s,n,i,r,c,l,a,o,h)}static apply1(t,s,n,i,r,c,l,a){s.modifyLocal(t);const o=s.bone.parent.appliedPose;let h=o.a,d=o.b,f=o.c,u=o.d,m=-s.shearX-s.rotation,g=0,p=0;switch(s.inherit){case et.OnlyTranslation:g=(n-s.worldX)*X.signum(t.scaleX),p=(i-s.worldY)*X.signum(t.scaleY);break;case et.NoRotationOrReflection:{const x=Math.abs(h*u-d*f)/Math.max(X.epsilon,h*h+f*f),b=h/t.scaleX,w=f/t.scaleY;d=-w*x*t.scaleX,u=b*x*t.scaleY,m+=X.atan2Deg(w,b)}default:{const x=n-o.worldX,b=i-o.worldY,w=h*u-d*f;Math.abs(w)<=X.epsilon?(g=0,p=0):(g=(x*u-b*d)/w-s.x,p=(b*h-x*f)/w-s.y)}}if(m+=X.atan2Deg(p,g),s.scaleX<0&&(m+=180),m>180?m-=360:m<=-180&&(m+=360),s.rotation+=m*a,r||c){switch(s.inherit){case et.NoScale:case et.NoScaleOrReflection:g=n-s.worldX,p=i-s.worldY}const x=s.bone.data.length*s.scaleX;if(x>X.epsilon){const b=g*g+p*p;if(r&&b<x*x||c&&b>x*x){const w=(Math.sqrt(b)/x-1)*a+1;switch(s.scaleX*=w,l){case ct.Uniform:s.scaleY*=w;break;case ct.Volume:s.scaleY/=w<.7?.25+.642857*w:w}}}}}static apply2(t,s,n,i,r,c,l,a,o,h){if(s.inherit!==et.Normal||n.inherit!==et.Normal)return;s.modifyLocal(t),n.modifyLocal(t);let d=s.x,f=s.y,u=s.scaleX,m=s.scaleY,g=n.scaleX,p=0,x=0,b=0;u<0?(u=-u,p=180,b=-1):(p=0,b=1),m<0&&(m=-m,b=-b),g<0?(g=-g,x=180):x=0;let w=0,T=0,y=s.a,v=s.b,S=s.c,C=s.d;const A=Math.abs(u-m)<=X.epsilon;!A||l?(n.y=0,w=y*n.x+s.worldX,T=S*n.x+s.worldY):(w=y*n.x+v*n.y+s.worldX,T=S*n.x+C*n.y+s.worldY);const P=s.bone.parent.appliedPose;y=P.a,v=P.b,S=P.c,C=P.d;let k=y*C-v*S,F=w-P.worldX,R=T-P.worldY;k=Math.abs(k)<=X.epsilon?0:1/k;const E=(F*C-R*v)*k-d,B=(R*y-F*S)*k-f;let O=Math.sqrt(E*E+B*B),q=n.bone.data.length*g,_,Y;if(O<X.epsilon){Qt.apply(t,s,i,r,!1,l,ct.None,h),n.rotation=0;return}F=i-P.worldX,R=r-P.worldY;let M=(F*C-R*v)*k-d,N=(R*y-F*S)*k-f,D=M*M+N*N;if(o!==0){o*=u*(g+1)*.5;const V=Math.sqrt(D),z=V-O-q*u+o;if(z>0){let U=Math.min(1,z/(o*2))-1;U=(z-o*(1-U*U))/V,M-=U*M,N-=U*N,D=M*M+N*N}}t:if(A){q*=u;let V=(D-O*O-q*q)/(2*O*q);if(V<-1)V=-1,Y=Math.PI*c;else if(V>1){if(V=1,Y=0,l)switch(y=(Math.sqrt(D)/(O+q)-1)*h+1,s.scaleX*=y,a){case ct.Uniform:s.scaleY*=y;break;case ct.Volume:s.scaleY/=y<.7?.25+.642857*y:y}}else Y=Math.acos(V)*c;y=O+q*V,v=q*Math.sin(Y),_=Math.atan2(N*y-M*v,M*y+N*v)}else{y=u*q,v=m*q;const V=y*y,z=v*v,U=Math.atan2(N,M);S=z*O*O+V*D-V*z;const Q=-2*z*O,rt=z-V;if(C=Q*Q-4*rt*S,C>=0){let Yt=Math.sqrt(C);Q<0&&(Yt=-Yt),Yt=-(Q+Yt)*.5;let Vt=Yt/rt,Ce=S/Yt;const Je=Math.abs(Vt)<Math.abs(Ce)?Vt:Ce;if(Vt=D-Je*Je,Vt>=0){R=Math.sqrt(Vt)*c,_=U-Math.atan2(R,Je),Y=Math.atan2(R/m,(Je-O)/u);break t}}let Z=X.PI,at=O-y,dt=at*at,lt=0,Ct=0,mt=O+y,gt=mt*mt,At=0;S=-y*O/(V-z),S>=-1&&S<=1&&(S=Math.acos(S),F=y*Math.cos(S)+O,R=v*Math.sin(S),C=F*F+R*R,C<dt&&(Z=S,dt=C,at=F,lt=R),C>gt&&(Ct=S,gt=C,mt=F,At=R)),D<=(dt+gt)*.5?(_=U-Math.atan2(lt*c,at),Y=Z*c):(_=U-Math.atan2(At*c,mt),Y=Ct*c)}const G=Math.atan2(n.y,n.x)*b;_=(_-G)*X.radDeg+p-s.rotation,_>180?_-=360:_<=-180&&(_+=360),s.rotation+=_*h,Y=((Y+G)*X.radDeg-n.shearX)*b+x-n.rotation,Y>180?Y-=360:Y<=-180&&(Y+=360),n.rotation+=Y*h}},we=class extends ie{bones=[];_target=null;set target(e){this._target=e}get target(){if(!this._target)throw new Error("target cannot be null.");return this._target}_scaleYMode=ct.None;set scaleYMode(e){this._scaleYMode=e}get scaleYMode(){if(this._scaleYMode==null)throw new Error("scaleYMode cannot be null.");return this._scaleYMode}constructor(e){super(e,new Xe)}create(e){return new In(this,e)}},Le=class{position=0;spacing=0;mixRotate=0;mixX=0;mixY=0;set(e){this.position=e.position,this.spacing=e.spacing,this.mixRotate=e.mixRotate,this.mixX=e.mixX,this.mixY=e.mixY}},ye=class extends ie{bones=[];set slot(e){this._slot=e}get slot(){if(this._slot)return this._slot;throw new Error("SlotData not set.")}_slot=null;positionMode=Tt.Fixed;spacingMode=nt.Fixed;rotateMode=Ut.Chain;offsetRotation=0;constructor(e){super(e,new Le)}create(e){return new kn(this,e)}},Tt;(function(e){e[e.Fixed=0]="Fixed",e[e.Percent=1]="Percent"})(Tt||(Tt={}));var nt;(function(e){e[e.Length=0]="Length",e[e.Fixed=1]="Fixed",e[e.Percent=2]="Percent",e[e.Proportional=3]="Proportional"})(nt||(nt={}));var Ut;(function(e){e[e.Tangent=0]="Tangent",e[e.Chain=1]="Chain",e[e.ChainScale=2]="ChainScale"})(Ut||(Ut={}));var kn=class Zt extends ne{static NONE=-1;static BEFORE=-2;static AFTER=-3;data;bones;slot;spaces=[];positions=[];world=[];curves=[];lengths=[];segments=[];constructor(t,s){if(super(t,new Le,new Le),!s)throw new Error("skeleton cannot be null.");this.data=t,this.bones=[];for(const n of this.data.bones)this.bones.push(s.bones[n.index].constrainedPose);this.slot=s.slots[t.slot.index]}copy(t){var s=new Zt(this.data,t);return s.pose.set(this.pose),s}update(t,s){const n=this.slot.appliedPose.attachment;if(!(n instanceof be))return;const i=this.appliedPose,r=i.mixRotate,c=i.mixX,l=i.mixY;if(r===0&&c===0&&l===0)return;const a=this.data,o=a.rotateMode===Ut.Tangent,h=a.rotateMode===Ut.ChainScale,d=this.bones,f=d.length,u=o?f:f+1,m=L.setArraySize(this.spaces,u),g=h?this.lengths=L.setArraySize(this.lengths,f):[],p=i.spacing;switch(a.spacingMode){case nt.Percent:if(h)for(let v=0,S=u-1;v<S;v++){const C=d[v],A=C.bone.data.length,P=A*C.a,k=A*C.c;g[v]=Math.sqrt(P*P+k*k)}L.arrayFill(m,1,u,p);break;case nt.Proportional:{let v=0;for(let S=0,C=u-1;S<C;){const A=d[S],P=A.bone.data.length;if(P<X.epsilon)h&&(g[S]=0),m[++S]=p;else{const k=P*A.a,F=P*A.c,R=Math.sqrt(k*k+F*F);h&&(g[S]=R),m[++S]=R,v+=R}}if(v>0){v=u/v*p;for(let S=1;S<u;S++)m[S]*=v}break}default:{const v=a.spacingMode===nt.Length;for(let S=0,C=u-1;S<C;){const A=d[S],P=A.bone.data.length;if(P<X.epsilon)h&&(g[S]=0),m[++S]=p;else{const k=P*A.a,F=P*A.c,R=Math.sqrt(k*k+F*F);h&&(g[S]=R),m[++S]=(v?Math.max(0,P+p):p)*R/P}}}}const x=this.computeWorldPositions(t,n,u,o);let b=x[0],w=x[1],T=a.offsetRotation,y=!1;if(T===0)y=a.rotateMode===Ut.Chain;else{y=!1;const v=this.slot.bone.appliedPose;T*=v.a*v.d-v.b*v.c>0?X.degRad:-X.degRad}for(let v=0,S=3,C=t._update;v<f;v++,S+=3){const A=d[v];A.worldX+=(b-A.worldX)*c,A.worldY+=(w-A.worldY)*l;const P=x[S],k=x[S+1],F=P-b,R=k-w;if(h){const E=g[v];if(E!==0){const B=(Math.sqrt(F*F+R*R)/E-1)*r+1;A.a*=B,A.c*=B}}if(b=P,w=k,r>0){let E=A.a,B=A.b,O=A.c,q=A.d,_=0,Y=0,M=0;if(o?_=x[S-1]:m[v+1]===0?_=x[S+2]:_=Math.atan2(R,F),_-=Math.atan2(O,E),y){Y=Math.cos(_),M=Math.sin(_);const N=A.bone.data.length;b+=(N*(Y*E-M*O)-F)*r,w+=(N*(M*E+Y*O)-R)*r}else _+=T;_>X.PI?_-=X.PI2:_<-X.PI&&(_+=X.PI2),_*=r,Y=Math.cos(_),M=Math.sin(_),A.a=Y*E-M*O,A.b=Y*B-M*q,A.c=M*E+Y*O,A.d=M*B+Y*q}A.modifyWorld(C)}}computeWorldPositions(t,s,n,i){const r=this.slot;let c=this.appliedPose.position,l=this.spaces,a=L.setArraySize(this.positions,n*3+2),o=this.world;const h=s.closed;let d=s.worldVerticesLength,f=d/6,u=Zt.NONE;if(!s.constantSpeed){const Y=s.lengths;f-=h?1:2;const M=Y[f];this.data.positionMode===Tt.Percent&&(c*=M);let N;switch(this.data.spacingMode){case nt.Percent:N=M;break;case nt.Proportional:N=M/n;break;default:N=1}o=L.setArraySize(this.world,8);for(let D=0,G=0,V=0;D<n;D++,G+=3){const z=l[D]*N;c+=z;let U=c;if(h)U%=M,U<0&&(U+=M),V=0;else if(U<0){u!==Zt.BEFORE&&(u=Zt.BEFORE,s.computeWorldVertices(t,r,2,4,o,0,2)),this.addBeforePosition(U,o,0,a,G);continue}else if(U>M){u!==Zt.AFTER&&(u=Zt.AFTER,s.computeWorldVertices(t,r,d-6,4,o,0,2)),this.addAfterPosition(U-M,o,0,a,G);continue}for(;;V++){const Q=Y[V];if(!(U>Q)){if(V===0)U/=Q;else{const rt=Y[V-1];U=(U-rt)/(Q-rt)}break}}V!==u&&(u=V,h&&V===f?(s.computeWorldVertices(t,r,d-4,4,o,0,2),s.computeWorldVertices(t,r,0,4,o,4,2)):s.computeWorldVertices(t,r,V*6+2,8,o,0,2)),this.addCurvePosition(U,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],a,G,i||D>0&&z===0)}return a}h?(d+=2,o=L.setArraySize(this.world,d),s.computeWorldVertices(t,r,2,d-4,o,0,2),s.computeWorldVertices(t,r,0,2,o,d-4,2),o[d-2]=o[0],o[d-1]=o[1]):(f--,d-=4,o=L.setArraySize(this.world,d),s.computeWorldVertices(t,r,2,d,o,0,2));const m=L.setArraySize(this.curves,f);let g=0,p=o[0],x=o[1],b=0,w=0,T=0,y=0,v=0,S=0,C=0,A=0,P=0,k=0,F=0,R=0,E=0,B=0;for(let Y=0,M=2;Y<f;Y++,M+=6)b=o[M],w=o[M+1],T=o[M+2],y=o[M+3],v=o[M+4],S=o[M+5],C=(p-b*2+T)*.1875,A=(x-w*2+y)*.1875,P=((b-T)*3-p+v)*.09375,k=((w-y)*3-x+S)*.09375,F=C*2+P,R=A*2+k,E=(b-p)*.75+C+P*.16666667,B=(w-x)*.75+A+k*.16666667,g+=Math.sqrt(E*E+B*B),E+=F,B+=R,F+=P,R+=k,g+=Math.sqrt(E*E+B*B),E+=F,B+=R,g+=Math.sqrt(E*E+B*B),E+=F+P,B+=R+k,g+=Math.sqrt(E*E+B*B),m[Y]=g,p=v,x=S;this.data.positionMode===Tt.Percent&&(c*=g);let O;switch(this.data.spacingMode){case nt.Percent:O=g;break;case nt.Proportional:O=g/n;break;default:O=1}const q=this.segments;let _=0;for(let Y=0,M=0,N=0,D=0;Y<n;Y++,M+=3){const G=l[Y]*O;c+=G;let V=c;if(h)V%=g,V<0&&(V+=g),N=0,D=0;else if(V<0){this.addBeforePosition(V,o,0,a,M);continue}else if(V>g){this.addAfterPosition(V-g,o,d-4,a,M);continue}for(;;N++){const z=m[N];if(!(V>z)){if(N===0)V/=z;else{const U=m[N-1];V=(V-U)/(z-U)}break}}if(N!==u){u=N;let z=N*6;for(p=o[z],x=o[z+1],b=o[z+2],w=o[z+3],T=o[z+4],y=o[z+5],v=o[z+6],S=o[z+7],C=(p-b*2+T)*.03,A=(x-w*2+y)*.03,P=((b-T)*3-p+v)*.006,k=((w-y)*3-x+S)*.006,F=C*2+P,R=A*2+k,E=(b-p)*.3+C+P*.16666667,B=(w-x)*.3+A+k*.16666667,_=Math.sqrt(E*E+B*B),q[0]=_,z=1;z<8;z++)E+=F,B+=R,F+=P,R+=k,_+=Math.sqrt(E*E+B*B),q[z]=_;E+=F,B+=R,_+=Math.sqrt(E*E+B*B),q[8]=_,E+=F+P,B+=R+k,_+=Math.sqrt(E*E+B*B),q[9]=_,D=0}for(V*=_;;D++){const z=q[D];if(!(V>z)){if(D===0)V/=z;else{const U=q[D-1];V=D+(V-U)/(z-U)}break}}this.addCurvePosition(V*.1,p,x,b,w,T,y,v,S,a,M,i||Y>0&&G===0)}return a}addBeforePosition(t,s,n,i,r){const c=s[n],l=s[n+1],a=s[n+2]-c,o=s[n+3]-l,h=Math.atan2(o,a);i[r]=c+t*Math.cos(h),i[r+1]=l+t*Math.sin(h),i[r+2]=h}addAfterPosition(t,s,n,i,r){const c=s[n+2],l=s[n+3],a=c-s[n],o=l-s[n+1],h=Math.atan2(o,a);i[r]=c+t*Math.cos(h),i[r+1]=l+t*Math.sin(h),i[r+2]=h}addCurvePosition(t,s,n,i,r,c,l,a,o,h,d,f){if(t===0||Number.isNaN(t)){h[d]=s,h[d+1]=n,h[d+2]=Math.atan2(r-n,i-s);return}const u=t*t,m=u*t,g=1-t,p=g*g,x=p*g,b=g*t,w=b*3,T=g*w,y=w*t,v=s*x+i*T+c*y+a*m,S=n*x+r*T+l*y+o*m;h[d]=v,h[d+1]=S,f&&(t<.001?h[d+2]=Math.atan2(r-n,i-s):h[d+2]=Math.atan2(S-(n*p+r*b*2+l*u),v-(s*p+i*b*2+c*u)))}sort(t){const s=this.slot.data.index,n=this.slot.bone;t.skin!=null&&this.sortPathSlot(t,t.skin,s,n),t.data.defaultSkin!=null&&t.data.defaultSkin!==t.skin&&this.sortPathSlot(t,t.data.defaultSkin,s,n),this.sortPath(t,this.slot.pose.attachment,n);const i=this.bones,r=this.bones.length;for(let c=0;c<r;c++){const l=i[c].bone;t.sortBone(l),t.constrained(l)}t._updateCache.push(this);for(let c=0;c<r;c++)t.sortReset(i[c].bone.children);for(let c=0;c<r;c++)i[c].bone.sorted=!0}sortPathSlot(t,s,n,i){const r=s.getAttachments();for(let c=0,l=r.length;c<l;c++){const a=r[c];a.slotIndex===n&&this.sortPath(t,a.attachment,i)}}sortPath(t,s,n){if(!(s instanceof be))return;const i=s.bones;if(i==null)t.sortBone(n);else{const r=t.bones;for(let c=0,l=i.length;c<l;){let a=i[c++];for(a+=c;c<a;)t.sortBone(r[i[c++]])}}}isSourceActive(){return this.slot.bone.active}},vt;(function(e){e[e.none=0]="none",e[e.reset=1]="reset",e[e.update=2]="update",e[e.pose=3]="pose"})(vt||(vt={}));var Ve=class{inertia=0;strength=0;damping=0;massInverse=0;wind=0;gravity=0;mix=0;set(e){this.inertia=e.inertia,this.strength=e.strength,this.damping=e.damping,this.massInverse=e.massInverse,this.wind=e.wind,this.gravity=e.gravity,this.mix=e.mix}},_e=class{color=new $(1,1,1,1);darkColor=null;attachment=null;sequenceIndex=0;deform=[];SlotPose(){}set(e){if(e==null)throw new Error("pose cannot be null.");this.color.setFromColor(e.color),this.darkColor!=null&&e.darkColor!=null&&this.darkColor.setFromColor(e.darkColor),this.attachment=e.attachment,this.sequenceIndex=e.sequenceIndex,this.deform.length=0,this.deform.push(...e.deform)}getAttachment(){return this.attachment}setAttachment(e){this.attachment!==e&&((!(e instanceof Ot)||!(this.attachment instanceof Ot)||e.timelineAttachment!==this.attachment.timelineAttachment)&&(this.deform.length=0),this.attachment=e,this.sequenceIndex=-1)}},Mn=class ti extends $s{skeleton;bone;attachmentState=0;constructor(t,s){if(super(t,new _e,new _e),!s)throw new Error("skeleton cannot be null.");this.skeleton=s,this.bone=s.bones[t.boneData.index],t.setupPose.darkColor!=null&&(this.pose.darkColor=new $,this.constrainedPose.darkColor=new $),this.setupPose()}copy(t,s,n){const i=new ti(t.data,this.skeleton);return this.data.setupPose.darkColor!=null&&(i.pose.darkColor=new $,i.constrainedPose.darkColor=new $),i.pose.set(t.pose),i}setupPose(){this.pose.color.setFromColor(this.data.setupPose.color),this.pose.darkColor&&this.pose.darkColor.setFromColor(this.data.setupPose.darkColor),this.pose.sequenceIndex=this.data.setupPose.sequenceIndex,this.data.attachmentName?(this.pose.attachment=null,this.pose.setAttachment(this.skeleton.getAttachment(this.data.index,this.data.attachmentName))):this.pose.setAttachment(null)}},re=class Ze{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;static get yDir(){return Ze.yDown?-1:1}data;bones;slots;drawOrder;constraints;physics;_updateCache=[];resetCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return this._scaleY*Ze.yDir}set scaleY(t){this._scaleY=t}x=0;y=0;time=0;windX=1;windY=0;gravityX=0;gravityY=1;_update=0;constructor(t){if(!t)throw new Error("data cannot be null.");this.data=t,this.bones=[];for(let s=0;s<t.bones.length;s++){const n=t.bones[s];let i;if(!n.parent)i=new Ee(n,null);else{const r=this.bones[n.parent.index];i=new Ee(n,r),r.children.push(i)}this.bones.push(i)}this.slots=[];for(const s of this.data.slots)this.slots.push(new Mn(s,this));this.drawOrder=new Pn(this.slots),this.physics=[],this.constraints=[];for(const s of this.data.constraints){const n=s.create(this);n instanceof Gs&&this.physics.push(n),this.constraints.push(n)}this.color=new $(1,1,1,1),this.updateCache()}updateCache(){this._updateCache.length=0,this.resetCache.length=0,this.drawOrder.unconstrained();const t=this.slots;for(let c=0,l=t.length;c<l;c++)t[c].unconstrained();const s=this.bones,n=s.length;for(let c=0,l=n;c<l;c++){const a=s[c];a.sorted=a.data.skinRequired,a.active=!a.sorted,a.unconstrained()}if(this.skin){const c=this.skin.bones;for(let l=0,a=this.skin.bones.length;l<a;l++){let o=this.bones[c[l].index];do o.sorted=!1,o.active=!0,o=o.parent;while(o)}}const i=this.constraints;let r=this.constraints.length;for(let c=0;c<r;c++)i[c].unconstrained();for(let c=0;c<r;c++){const l=i[c];l.active=l.isSourceActive()&&(!l.data.skinRequired||this.skin!=null&&this.skin.constraints.includes(l.data)),l.active&&l.sort(this)}for(let c=0;c<n;c++)this.sortBone(s[c]);r=this._updateCache.length;for(let c=0;c<r;c++){const l=this._updateCache[c];l instanceof Ee&&(this._updateCache[c]=l.appliedPose)}}constrained(t){t.pose===t.appliedPose&&(t.constrained(),this.resetCache.push(t))}sortBone(t){if(t.sorted||!t.active)return;const s=t.parent;s&&this.sortBone(s),t.sorted=!0,this._updateCache.push(t)}sortReset(t){for(let s=0,n=t.length;s<n;s++){const i=t[s];i.active&&(i.sorted&&this.sortReset(i.children),i.sorted=!1)}}updateWorldTransform(t){this._update++,this.drawOrder.appliedPose===this.drawOrder.constrainedPose&&this.drawOrder.resetConstrained();const s=this.resetCache;for(let i=0,r=this.resetCache.length;i<r;i++)s[i].resetConstrained();const n=this._updateCache;for(let i=0,r=this._updateCache.length;i<r;i++)n[i].update(this,t)}setupPose(){this.setupPoseBones(),this.setupPoseSlots()}setupPoseBones(){const t=this.bones;for(let n=0,i=t.length;n<i;n++)t[n].setupPose();const s=this.constraints;for(let n=0,i=s.length;n<i;n++)s[n].setupPose()}setupPoseSlots(){this.drawOrder.setupPose();const t=this.slots;for(let s=0,n=t.length;s<n;s++)t[s].setupPose()}getRootBone(){return this.bones.length===0?null:this.bones[0]}findBone(t){if(!t)throw new Error("boneName cannot be null.");const s=this.bones;for(let n=0,i=s.length;n<i;n++)if(s[n].data.name===t)return s[n];return null}findSlot(t){if(!t)throw new Error("slotName cannot be null.");const s=this.slots;for(let n=0,i=s.length;n<i;n++)if(s[n].data.name===t)return s[n];return null}setSkin(t){typeof t=="string"?this.setSkinByName(t):this.setSkinBySkin(t)}setSkinByName(t){const s=this.data.findSkin(t);if(!s)throw new Error(`Skin not found: ${t}`);this.setSkin(s)}setSkinBySkin(t){if(t!==this.skin){if(t)if(this.skin)t.attachAll(this,this.skin);else{const s=this.slots;for(let n=0,i=s.length;n<i;n++){const r=s[n],c=r.data.attachmentName;if(c){const l=t.getAttachment(n,c);l&&r.pose.setAttachment(l)}}}this.skin=t,this.updateCache()}}getAttachment(t,s){return typeof t=="string"?this.getAttachmentByName(t,s):this.getAttachmentByIndex(t,s)}getAttachmentByName(t,s){const n=this.data.findSlot(t);if(!n)throw new Error(`Can't find slot with name ${t}`);return this.getAttachment(n.index,s)}getAttachmentByIndex(t,s){if(!s)throw new Error("placeholder cannot be null.");if(this.skin){const n=this.skin.getAttachment(t,s);if(n)return n}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,s):null}setAttachment(t,s){if(!t)throw new Error("slotName cannot be null.");const n=this.findSlot(t);if(!n)throw new Error(`Slot not found: ${t}`);let i=null;if(s&&(i=this.getAttachment(n.data.index,s),!i))throw new Error(`Attachment not found: ${s}, for slot: ${t}`);n.pose.setAttachment(i)}findConstraint(t,s){if(t==null)throw new Error("constraintName cannot be null.");if(s==null)throw new Error("type cannot be null.");const n=this.constraints;for(let i=0,r=n.length;i<r;i++){const c=n[i];if(c instanceof s&&c.data.name===t)return c}return null}getBoundsRect(t){const s=new Ae,n=new Ae;return this.getBounds(s,n,void 0,t),{x:s.x,y:s.y,width:n.x,height:n.y}}getBounds(t,s,n=new Array(2),i=null){if(!t)throw new Error("offset cannot be null.");if(!s)throw new Error("size cannot be null.");const r=this.drawOrder.appliedPose,c=r;let l=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(let d=0,f=r.length;d<f;d++){const u=c[d];if(!u.bone.active)continue;let m=0,g=null,p=null;const x=u.appliedPose.attachment;if(x){if(x instanceof H)m=8,g=L.setArraySize(n,m,0),x.computeWorldVertices(u,x.getOffsets(u.appliedPose),g,0,2),p=Ze.quadTriangles;else if(x instanceof pt)m=x.worldVerticesLength,g=L.setArraySize(n,m,0),x.computeWorldVertices(this,u,0,m,g,0,2),p=x.triangles;else if(x instanceof Bt&&i){i.clipEnd(u),i.clipStart(this,u,x);continue}if(g&&p){i?.isClipping()&&i.clipTriangles(g,p,p.length)&&(g=i.clippedVertices,m=i.clippedVertices.length);for(let b=0,w=g.length;b<w;b+=2){const T=g[b],y=g[b+1];l=Math.min(l,T),a=Math.min(a,y),o=Math.max(o,T),h=Math.max(h,y)}}}i&&i.clipEnd(u)}i&&i.clipEnd(),t.set(l,a),s.set(o-l,h-a)}setScale(t,s){this.scaleX=t,this.scaleY=s}setPosition(t,s){this.x=t,this.y=s}update(t){this.time+=t}physicsTranslate(t,s){const n=this.physics;for(let i=0,r=n.length;i<r;i++)n[i].translate(t,s)}physicsRotate(t,s,n){const i=this.physics;for(let r=0,c=i.length;r<c;r++)i[r].rotate(t,s,n)}},Gs=class ei extends ne{bone;_reset=!0;ux=0;uy=0;cx=0;cy=0;tx=0;ty=0;xOffset=0;xLag=0;xVelocity=0;yOffset=0;yLag=0;yVelocity=0;rotateOffset=0;rotateLag=0;rotateVelocity=0;scaleOffset=0;scaleLag=0;scaleVelocity=0;remaining=0;lastTime=0;constructor(t,s){if(super(t,new Ve,new Ve),s==null)throw new Error("skeleton cannot be null.");this.bone=s.bones[t.bone.index].constrainedPose}copy(t){var s=new ei(this.data,t);return s.pose.set(this.pose),s}reset(t){this.remaining=0,this.lastTime=t.time,this._reset=!0,this.xOffset=0,this.xLag=0,this.xVelocity=0,this.yOffset=0,this.yLag=0,this.yVelocity=0,this.rotateOffset=0,this.rotateLag=0,this.rotateVelocity=0,this.scaleOffset=0,this.scaleLag=0,this.scaleVelocity=0}translate(t,s){this.ux-=t,this.uy-=s,this.cx-=t,this.cy-=s}rotate(t,s,n){const i=n*X.degRad,r=Math.cos(i),c=Math.sin(i),l=this.cx-t,a=this.cy-s;this.translate(l*r-a*c-l,l*c+a*r-a)}update(t,s){const n=this.appliedPose,i=n.mix;if(i===0)return;const r=this.data.x>0,c=this.data.y>0,l=this.data.rotate>0||this.data.shearX>0,a=this.data.scaleX>0,o=this.bone;let h=o.bone.data.length,d=this.data.step,f=0;switch(s){case vt.none:return;case vt.reset:this.reset(t);case vt.update:{const u=Math.max(t.time-this.lastTime,0),m=this.remaining;this.remaining+=u,this.lastTime=t.time;const g=o.worldX,p=o.worldY;if(this._reset)this._reset=!1,this.ux=g,this.uy=p;else{let x=this.remaining,b=n.inertia,w=t.data.referenceScale,T=-1,y=0,v=0,S=this.data.limit*u,C=S*Math.abs(t.scaleY);if(S*=Math.abs(t.scaleX),r||c){if(r){const A=(this.ux-g)*b;this.xOffset+=A>S?S:A<-S?-S:A,this.ux=g}if(c){const A=(this.uy-p)*b;this.yOffset+=A>C?C:A<-C?-C:A,this.uy=p}if(x>=d){const A=this.xOffset,P=this.yOffset;T=n.damping**(60*d),y=d*n.massInverse,v=n.strength;const k=w*n.wind,F=w*n.gravity,R=(k*t.windX+F*t.gravityX)*t.scaleX,E=(k*t.windY+F*t.gravityY)*t.scaleY;do r&&(this.xVelocity+=(R-this.xOffset*v)*y,this.xOffset+=this.xVelocity*d,this.xVelocity*=T),c&&(this.yVelocity-=(E+this.yOffset*v)*y,this.yOffset+=this.yVelocity*d,this.yVelocity*=T),x-=d;while(x>=d);this.xLag=this.xOffset-A,this.yLag=this.yOffset-P}f=Math.max(0,1-x/d),r&&(o.worldX+=(this.xOffset-this.xLag*f)*i*this.data.x),c&&(o.worldY+=(this.yOffset-this.yLag*f)*i*this.data.y)}if(l||a){let A=Math.atan2(o.c,o.a),P=0,k=0,F=0,R=this.cx-o.worldX,E=this.cy-o.worldY;if(R>S?R=S:R<-S&&(R=-S),E>C?E=C:E<-C&&(E=-C),x=this.remaining,l){F=(this.data.rotate+this.data.shearX)*i,f=this.rotateLag*Math.max(0,1-m/d);let B=Math.atan2(E+this.ty,R+this.tx)-A-(this.rotateOffset-f)*F;this.rotateOffset+=(B-Math.ceil(B*X.invPI2-.5)*X.PI2)*b,B=(this.rotateOffset-f)*F+A,P=Math.cos(B),k=Math.sin(B),a&&(B=h*o.getWorldScaleX(),B>0&&(this.scaleOffset+=(R*P+E*k)*b/B))}else{P=Math.cos(A),k=Math.sin(A);const B=h*o.getWorldScaleX()-this.scaleLag*Math.max(0,1-m/d);B>0&&(this.scaleOffset+=(R*P+E*k)*b/B)}if(x>=d){T===-1&&(T=n.damping**(60*d),y=d*n.massInverse,v=n.strength);const B=n.wind*t.windX+n.gravity*t.gravityX,O=(n.wind*t.windY+n.gravity*t.gravityY)*re.yDir,q=this.rotateOffset,_=this.scaleOffset,Y=h/w;for(;;)if(x-=d,a&&(this.scaleVelocity+=(B*P-O*k-this.scaleOffset*v)*y,this.scaleOffset+=this.scaleVelocity*d,this.scaleVelocity*=T),l){if(this.rotateVelocity-=((B*k+O*P)*Y+this.rotateOffset*v)*y,this.rotateOffset+=this.rotateVelocity*d,this.rotateVelocity*=T,x<d)break;const M=this.rotateOffset*F+A;P=Math.cos(M),k=Math.sin(M)}else if(x<d)break;this.rotateLag=this.rotateOffset-q,this.scaleLag=this.scaleOffset-_}f=Math.max(0,1-x/d)}this.remaining=x}this.cx=o.worldX,this.cy=o.worldY;break}case vt.pose:f=Math.max(0,1-this.remaining/d),r&&(o.worldX+=(this.xOffset-this.xLag*f)*i*this.data.x),c&&(o.worldY+=(this.yOffset-this.yLag*f)*i*this.data.y)}if(l){let u=(this.rotateOffset-this.rotateLag*f)*i,m=0,g=0,p=0;if(this.data.shearX>0){let x=0;this.data.rotate>0&&(x=u*this.data.rotate,m=Math.sin(x),g=Math.cos(x),p=o.b,o.b=g*p-m*o.d,o.d=m*p+g*o.d),x+=u*this.data.shearX,m=Math.sin(x),g=Math.cos(x),p=o.a,o.a=g*p-m*o.c,o.c=m*p+g*o.c}else u*=this.data.rotate,m=Math.sin(u),g=Math.cos(u),p=o.a,o.a=g*p-m*o.c,o.c=m*p+g*o.c,p=o.b,o.b=g*p-m*o.d,o.d=m*p+g*o.d}if(a){let u=1+(this.scaleOffset-this.scaleLag*f)*i*this.data.scaleX;switch(o.a*=u,o.c*=u,this.data.scaleYMode){case ct.Uniform:o.b*=u,o.d*=u;break;case ct.Volume:u=Math.abs(u),u=u>=.7?1/u:4-3.67347*u,o.b*=u,o.d*=u}}s!==vt.pose&&(this.tx=h*o.a,this.ty=h*o.c),o.modifyWorld(t._update)}sort(t){const s=this.bone.bone;t.sortBone(s),t._updateCache.push(this),t.sortReset(s.children),t.constrained(s)}isSourceActive(){return this.bone.bone.active}},ve=class extends ie{set bone(e){this._bone=e}get bone(){if(this._bone)return this._bone;throw new Error("BoneData not set.")}_bone=null;x=0;y=0;rotate=0;scaleX=0;shearX=0;limit=0;step=0;inertiaGlobal=!1;strengthGlobal=!1;dampingGlobal=!1;massGlobal=!1;windGlobal=!1;gravityGlobal=!1;mixGlobal=!1;_scaleYMode=ct.None;get scaleYMode(){return this._scaleYMode}set scaleYMode(e){if(e==null)throw new Error("scaleYMode cannot be null.");this._scaleYMode=e}constructor(e){super(e,new Ve)}create(e){return new Gs(this,e)}};typeof Math.fround>"u"&&(Math.fround=(e=>t=>(e[0]=t,e[0]))(new Float32Array(1)));var Oe=class{time=0;mix=0;set(e){this.time=e.time,this.mix=e.mix}},Fn=class cn extends ne{static offsets=[0,0,0,0,0,0];bone=null;constructor(t,s){if(super(t,new Oe,new Oe),!s)throw new Error("skeleton cannot be null.");t.bone!=null&&(this.bone=s.bones[t.bone.index])}copy(t){var s=new cn(this.data,t);return s.pose.set(this.pose),s}update(t,s){const n=this.appliedPose;if(n.mix===0)return;const i=this.data,r=i.animation,c=this.bone;if(c!==null){if(!c.active)return;i.local&&c.appliedPose.validateLocalTransform(t),n.time=i.offset+(i.property.value(t,c.appliedPose,i.local,cn.offsets)-i.property.offset)*i.scale,i.loop?n.time=r.duration+n.time%r.duration:n.time=Math.max(0,n.time)}const l=t.bones,a=r.bones;for(let o=0,h=r.bones.length;o<h;o++)l[a[o]].appliedPose.modifyLocal(t);r.apply(t,n.time,n.time,i.loop,null,n.mix,!1,i.additive,!1,!0)}sort(t){const s=this.bone,n=this.data;s&&!n.local&&t.sortBone(s),t._updateCache.push(this);const i=t.bones,r=n.animation.bones;for(let d=0,f=n.animation.bones.length;d<f;d++){const u=i[r[d]];u.sorted=!1,t.sortReset(u.children),t.constrained(u)}const c=n.animation.timelines,l=t.slots,a=t.constraints,o=t.physics,h=t.physics.length;for(let d=0,f=n.animation.timelines.length;d<f;d++){const u=c[d];if(pn(u))t.constrained(l[u.slotIndex]);else if(u instanceof Wt||u instanceof pe)t.drawOrder.constrained();else if(u instanceof Et)if(u.constraintIndex===-1)for(let m=0;m<h;m++)t.constrained(o[m]);else t.constrained(a[u.constraintIndex]);else if(xn(u)){const m=u.constraintIndex;m!==-1&&t.constrained(a[m])}}}},qt=class extends ie{animation;additive=!1;loop=!1;bone=null;property;scale=0;offset=0;local=!1;max=0;constructor(e){super(e,new Oe)}create(e){return new Fn(this,e)}},De=class{name=null;bones=[];slots=[];skins=[];defaultSkin=null;events=[];animations=[];constraints=[];x=0;y=0;width=0;height=0;referenceScale=100;version=null;hash=null;fps=30;imagesPath=null;audioPath=null;findBone(e){if(!e)throw new Error("boneName cannot be null.");const t=this.bones;for(let s=0,n=t.length;s<n;s++)if(t[s].name===e)return t[s];return null}findSlot(e){if(!e)throw new Error("slotName cannot be null.");const t=this.slots;for(let s=0,n=t.length;s<n;s++)if(t[s].name===e)return t[s];return null}findSkin(e){if(!e)throw new Error("skinName cannot be null.");const t=this.skins;for(let s=0,n=t.length;s<n;s++)if(t[s].name===e)return t[s];return null}findEvent(e){if(!e)throw new Error("eventDataName cannot be null.");const t=this.events;for(let s=0,n=t.length;s<n;s++)if(t[s].name===e)return t[s];return null}findSliderAnimations(e){const t=this.constraints;for(let s=0,n=this.constraints.length;s<n;s++){const i=t[s];i instanceof qt&&i.animation!=null&&e.push(i.animation)}return e}findAnimation(e){if(!e)throw new Error("animationName cannot be null.");const t=this.animations;for(let s=0,n=t.length;s<n;s++)if(t[s].name===e)return t[s];return null}findConstraint(e,t){if(!e)throw new Error("constraintName cannot be null.");if(t==null)throw new Error("type cannot be null.");const s=this.constraints;for(let n=0,i=this.constraints.length;n<i;n++){const r=s[n];if(r instanceof t&&r.name===e)return r}return null}},Hs=class{slotIndex=0;placeholder;attachment;constructor(e=0,t,s){this.slotIndex=e,this.placeholder=t,this.attachment=s}},Te=class{name;attachments=[];bones=[];constraints=[];color=new $(.99607843,.61960787,.30980393,1);constructor(e){if(!e)throw new Error("name cannot be null.");this.name=e}setAttachment(e,t,s){if(!s)throw new Error("attachment cannot be null.");const n=this.attachments;e>=n.length&&(n.length=e+1),n[e]||(n[e]={}),n[e][t]=s}addSkin(e){for(let s=0;s<e.bones.length;s++){const n=e.bones[s];let i=!1;for(let r=0;r<this.bones.length;r++)if(this.bones[r]===n){i=!0;break}i||this.bones.push(n)}for(let s=0;s<e.constraints.length;s++){const n=e.constraints[s];let i=!1;for(let r=0;r<this.constraints.length;r++)if(this.constraints[r]===n){i=!0;break}i||this.constraints.push(n)}const t=e.getAttachments();for(let s=0;s<t.length;s++){const n=t[s];this.setAttachment(n.slotIndex,n.placeholder,n.attachment)}}copySkin(e){for(let s=0;s<e.bones.length;s++){const n=e.bones[s];let i=!1;for(let r=0;r<this.bones.length;r++)if(this.bones[r]===n){i=!0;break}i||this.bones.push(n)}for(let s=0;s<e.constraints.length;s++){const n=e.constraints[s];let i=!1;for(let r=0;r<this.constraints.length;r++)if(this.constraints[r]===n){i=!0;break}i||this.constraints.push(n)}const t=e.getAttachments();for(let s=0;s<t.length;s++){const n=t[s];n.attachment&&(n.attachment instanceof pt?(n.attachment=n.attachment.newLinkedMesh(),this.setAttachment(n.slotIndex,n.placeholder,n.attachment)):(n.attachment=n.attachment.copy(),this.setAttachment(n.slotIndex,n.placeholder,n.attachment)))}}getAttachment(e,t){const s=this.attachments[e];return s?s[t]:null}removeAttachment(e,t){const s=this.attachments[e];s&&delete s[t]}getAttachments(){const e=[];for(let t=0;t<this.attachments.length;t++){const s=this.attachments[t];if(s)for(const n in s){const i=s[n];i&&e.push(new Hs(t,n,i))}}return e}getAttachmentsForSlot(e,t){const s=this.attachments[e];if(s)for(const n in s){const i=s[n];i&&t.push(new Hs(e,n,i))}}clear(){this.attachments.length=0,this.bones.length=0,this.constraints.length=0}attachAll(e,t){let s=0;for(let n=0;n<e.slots.length;n++){const i=e.slots[n],r=i.pose.getAttachment();if(r&&s<t.attachments.length){const c=t.attachments[s];for(const l in c){const a=c[l];if(r===a){const o=this.getAttachment(s,l);o&&i.pose.setAttachment(o);break}}}s++}}},js=class extends Ye{index=0;boneData;attachmentName=null;blendMode=It.Normal;visible=!0;constructor(e,t,s){if(super(t,new _e),e<0)throw new Error("index must be >= 0.");if(!s)throw new Error("boneData cannot be null.");this.index=e,this.boneData=s}},It;(function(e){e[e.Normal=0]="Normal",e[e.Additive=1]="Additive",e[e.Multiply=2]="Multiply",e[e.Screen=3]="Screen"})(It||(It={}));var Ne=class{mixRotate=0;mixX=0;mixY=0;mixScaleX=0;mixScaleY=0;mixShearY=0;set(e){this.mixRotate=e.mixRotate,this.mixX=e.mixX,this.mixY=e.mixY,this.mixScaleX=e.mixScaleX,this.mixScaleY=e.mixScaleY,this.mixShearY=e.mixShearY}},Yn=class si extends ne{bones;source;constructor(t,s){if(super(t,new Ne,new Ne),!s)throw new Error("skeleton cannot be null.");this.bones=[];for(const i of t.bones)this.bones.push(s.bones[i.index].constrainedPose);const n=s.bones[t.source.index];if(n==null)throw new Error("source cannot be null.");this.source=n}copy(t){var s=new si(this.data,t);return s.pose.set(this.pose),s}update(t,s){const n=this.appliedPose;if(n.mixRotate===0&&n.mixX===0&&n.mixY===0&&n.mixScaleX===0&&n.mixScaleY===0&&n.mixShearY===0)return;const i=this.data,r=i.localSource,c=i.localTarget,l=i.additive,a=i.clamp,o=i.offsets,h=this.source.appliedPose;r&&h.validateLocalTransform(t);const d=i.properties,f=i.properties.length,u=t._update,m=this.bones;for(let g=0,p=this.bones.length;g<p;g++){const x=m[g];c?x.modifyLocal(t):x.modifyWorld(u);for(let b=0;b<f;b++){const w=d[b],T=w.value(t,h,r,o)-w.offset,y=w.to;for(let v=0,S=w.to.length;v<S;v++){const C=y[v];if(C.mix(n)!==0){let A=C.offset+T*C.scale;a&&(C.offset<C.max?A=X.clamp(A,C.offset,C.max):A=X.clamp(A,C.max,C.offset)),C.apply(t,n,x,A,c,l)}}}}}sort(t){this.data.localSource||t.sortBone(this.source);const s=this.bones,n=this.bones.length,i=!this.data.localTarget;if(i)for(let r=0;r<n;r++)t.sortBone(s[r].bone);t._updateCache.push(this);for(let r=0;r<n;r++){const c=s[r].bone;t.sortReset(c.children),t.constrained(c)}for(let r=0;r<n;r++)s[r].bone.sorted=i}isSourceActive(){return this.source.active}},K=class yt extends ie{static ROTATION=0;static X=1;static Y=2;static SCALEX=3;static SCALEY=4;static SHEARY=5;bones=[];set source(t){this._source=t}get source(){if(this._source)return this._source;throw new Error("BoneData not set.")}_source=null;offsets=[0,0,0,0,0,0];offsetX=0;offsetY=0;localSource=!1;localTarget=!1;additive=!1;clamp=!1;properties=[];constructor(t){super(t,new Ne)}create(t){return new Yn(this,t)}getOffsetRotation(){return this.offsets[yt.ROTATION]}setOffsetRotation(t){this.offsets[yt.ROTATION]=t}getOffsetX(){return this.offsets[yt.X]}setOffsetX(t){this.offsets[yt.X]=t}getOffsetY(){return this.offsets[yt.Y]}setOffsetY(t){this.offsets[yt.Y]=t}getOffsetScaleX(){return this.offsets[yt.SCALEX]}setOffsetScaleX(t){this.offsets[yt.SCALEX]=t}getOffsetScaleY(){return this.offsets[yt.SCALEY]}setOffsetScaleY(t){this.offsets[yt.SCALEY]=t}getOffsetShearY(){return this.offsets[yt.SHEARY]}setOffsetShearY(t){this.offsets[yt.SHEARY]=t}},Gt=class{offset=0;to=[]},Ht=class{offset=0;max=0;scale=0},Ue=class extends Gt{value(e,t,s,n){if(s)return t.rotation+n[K.ROTATION];const i=e.scaleX,r=e.scaleY;let c=Math.atan2(t.c/r,t.a/i)*X.radDeg+((t.a*t.d-t.b*t.c)*i*r>0?n[K.ROTATION]:-n[K.ROTATION]);return c<0&&(c+=360),c}},Js=class extends Ht{mix(e){return e.mixRotate}apply(e,t,s,n,i,r){if(i)s.rotation+=(r?n:n-s.rotation)*t.mixRotate;else{const c=e.scaleX,l=e.scaleY,a=1/c,o=1/l,h=s.a*a,d=s.b*a,f=s.c*o,u=s.d*o;n*=X.degRad,r||(n-=Math.atan2(f,h)),n>X.PI?n-=X.PI2:n<-X.PI&&(n+=X.PI2),n*=t.mixRotate;const m=Math.cos(n),g=Math.sin(n);s.a=(m*h-g*f)*c,s.b=(m*d-g*u)*c,s.c=(g*h+m*f)*l,s.d=(g*d+m*u)*l}}},qe=class extends Gt{value(e,t,s,n){return s?t.x+n[K.X]:(n[K.X]*t.a+n[K.Y]*t.b+t.worldX)/e.scaleX}},Ks=class extends Ht{mix(e){return e.mixX}apply(e,t,s,n,i,r){i?s.x+=(r?n:n-s.x)*t.mixX:(r||(n-=s.worldX/e.scaleX),s.worldX+=n*t.mixX*e.scaleX)}},$e=class extends Gt{value(e,t,s,n){return s?t.y+n[K.Y]:(n[K.X]*t.c+n[K.Y]*t.d+t.worldY)/e.scaleY}},Qs=class extends Ht{mix(e){return e.mixY}apply(e,t,s,n,i,r){i?s.y+=(r?n:n-s.y)*t.mixY:(r||(n-=s.worldY/e.scaleY),s.worldY+=n*t.mixY*e.scaleY)}},ze=class extends Gt{value(e,t,s,n){if(s)return t.scaleX+n[K.SCALEX];const i=t.a/e.scaleX,r=t.c/e.scaleY;return Math.sqrt(i*i+r*r)+n[K.SCALEX]}},Zs=class extends Ht{mix(e){return e.mixScaleX}apply(e,t,s,n,i,r){if(i)r?s.scaleX*=1+(n-1)*t.mixScaleX:s.scaleX!==0&&(s.scaleX+=(n-s.scaleX)*t.mixScaleX);else if(r){const c=1+(n-1)*t.mixScaleX;s.a*=c,s.c*=c}else{let c=s.a/e.scaleX,l=s.c/e.scaleY,a=Math.sqrt(c*c+l*l);a!==0&&(a=1+(n-a)*t.mixScaleX/a,s.a*=a,s.c*=a)}}},We=class extends Gt{value(e,t,s,n){if(s)return t.scaleY+n[K.SCALEY];const i=t.b/e.scaleX,r=t.d/e.scaleY;return Math.sqrt(i*i+r*r)+n[K.SCALEY]}},tn=class extends Ht{mix(e){return e.mixScaleY}apply(e,t,s,n,i,r){if(i)r?s.scaleY*=1+(n-1)*t.mixScaleY:s.scaleY!==0&&(s.scaleY+=(n-s.scaleY)*t.mixScaleY);else if(r){const c=1+(n-1)*t.mixScaleY;s.b*=c,s.d*=c}else{let c=s.b/e.scaleX,l=s.d/e.scaleY,a=Math.sqrt(c*c+l*l);a!==0&&(a=1+(n-a)*t.mixScaleY/a,s.b*=a,s.d*=a)}}},Ge=class extends Gt{value(e,t,s,n){if(s)return t.shearY+n[K.SHEARY];const i=1/e.scaleX,r=1/e.scaleY;return(Math.atan2(t.d*r,t.b*i)-Math.atan2(t.c*r,t.a*i))*X.radDeg-90+n[K.SHEARY]}},en=class extends Ht{mix(e){return e.mixShearY}apply(e,t,s,n,i,r){if(i)r||(n-=s.shearY),s.shearY+=n*t.mixShearY;else{const c=e.scaleX,l=e.scaleY,a=s.b/c,o=s.d/l,h=Math.atan2(o,a);n=(n+90)*X.degRad,r?n-=X.PI/2:(n-=h-Math.atan2(s.c/l,s.a/c),n>X.PI?n-=X.PI2:n<-X.PI&&(n+=X.PI2)),n=h+n*t.mixShearY;const d=Math.sqrt(a*a+o*o);s.b=Math.cos(n)*d*c,s.d=Math.sin(n)*d*l}}},Rn=class{scale=1;attachmentLoader;linkedMeshes=[];constructor(e){this.attachmentLoader=e}readSkeletonData(e){const t=this.scale,s=new De;s.name="";const n=new En(e),i=n.readInt32(),r=n.readInt32();s.hash=r===0&&i===0?null:r.toString(16)+i.toString(16),s.version=n.readString(),s.x=n.readFloat(),s.y=n.readFloat(),s.width=n.readFloat(),s.height=n.readFloat(),s.referenceScale=n.readFloat()*t;const c=n.readBoolean();c&&(s.fps=n.readFloat(),s.imagesPath=n.readString(),s.audioPath=n.readString());let l=0;l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("String in string table must not be null.");n.strings.push(m)}const a=s.bones;l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Bone name must not be null.");const g=u===0?null:a[n.readInt(!0)],p=new qs(u,m,g),x=p.setupPose;x.rotation=n.readFloat(),x.x=n.readFloat()*t,x.y=n.readFloat()*t,x.scaleX=n.readFloat(),x.scaleY=n.readFloat(),x.shearX=n.readFloat(),x.shearY=n.readFloat(),x.inherit=n.readByte(),p.length=n.readFloat()*t,p.skinRequired=n.readBoolean(),c&&($.rgba8888ToColor(p.color,n.readInt32()),p.icon=n.readString()??void 0,p.iconSize=n.readFloat(),p.iconRotation=n.readFloat(),p.visible=n.readBoolean()),a.push(p)}l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Slot name must not be null.");const g=a[n.readInt(!0)],p=new js(u,m,g);$.rgba8888ToColor(p.setupPose.color,n.readInt32());const x=n.readInt32();x!==-1&&$.rgb888ToColor(p.setupPose.darkColor=new $,x),p.attachmentName=n.readStringRef(),p.blendMode=n.readInt(!0),c&&(p.visible=n.readBoolean()),s.slots.push(p)}const o=s.constraints,h=n.readInt(!0);for(let u=0;u<h;u++){const m=n.readString();if(!m)throw new Error("Constraint data name must not be null.");let g;switch(n.readByte()){case Oi:{const p=new we(m);g=n.readInt(!0);for(let w=0;w<g;w++)p.bones.push(a[n.readInt(!0)]);p.target=a[n.readInt(!0)];const x=n.readByte();p.skinRequired=(x&1)!==0,(x&2)!==0&&(p.scaleYMode=n.readUnsignedByte());const b=p.setupPose;b.bendDirection=(x&4)!==0?-1:1,b.compress=(x&8)!==0,b.stretch=(x&16)!==0,(x&32)!==0&&(b.mix=(x&64)!==0?n.readFloat():1),(x&128)!==0&&(b.softness=n.readFloat()*t),o.push(p);break}case Ni:{const p=new K(m);g=n.readInt(!0);for(let w=0;w<g;w++)p.bones.push(a[n.readInt(!0)]);p.source=a[n.readInt(!0)];let x=n.readUnsignedByte();p.skinRequired=(x&1)!==0,p.localSource=(x&2)!==0,p.localTarget=(x&4)!==0,p.additive=(x&8)!==0,p.clamp=(x&16)!==0,g=x>>5;for(let w=0,T;w<g;w++){let y=1,v;switch(n.readByte()){case 0:v=new Ue;break;case 1:{y=t,v=new qe;break}case 2:{y=t,v=new $e;break}case 3:v=new ze;break;case 4:v=new We;break;case 5:v=new Ge;break;default:v=null}if(v){v.offset=n.readFloat()*y,T=n.readByte();for(let S=0;S<T;S++){let C=1,A;switch(n.readByte()){case 0:A=new Js;break;case 1:{C=t,A=new Ks;break}case 2:{C=t,A=new Qs;break}case 3:A=new Zs;break;case 4:A=new tn;break;case 5:A=new en;break;default:A=null}A&&(A.offset=n.readFloat()*C,A.max=n.readFloat()*C,A.scale=n.readFloat()*C/y,v.to[S]=A)}p.properties[w]=v}}x=n.readByte(),(x&1)!==0&&(p.offsets[K.ROTATION]=n.readFloat()),(x&2)!==0&&(p.offsets[K.X]=n.readFloat()*t),(x&4)!==0&&(p.offsets[K.Y]=n.readFloat()*t),(x&8)!==0&&(p.offsets[K.SCALEX]=n.readFloat()),(x&16)!==0&&(p.offsets[K.SCALEY]=n.readFloat()),(x&32)!==0&&(p.offsets[K.SHEARY]=n.readFloat()),x=n.readByte();const b=p.setupPose;(x&1)!==0&&(b.mixRotate=n.readFloat()),(x&2)!==0&&(b.mixX=n.readFloat()),(x&4)!==0&&(b.mixY=n.readFloat()),(x&8)!==0&&(b.mixScaleX=n.readFloat()),(x&16)!==0&&(b.mixScaleY=n.readFloat()),(x&32)!==0&&(b.mixShearY=n.readFloat()),o.push(p);break}case Di:{const p=new ye(m);g=n.readInt(!0);for(let w=0;w<g;w++)p.bones.push(a[n.readInt(!0)]);p.slot=s.slots[n.readInt(!0)];const x=n.readByte();p.skinRequired=(x&1)!==0,p.positionMode=x>>1&1,p.spacingMode=x>>2&3,p.rotateMode=x>>4&3,(x&128)!==0&&(p.offsetRotation=n.readFloat());const b=p.setupPose;b.position=n.readFloat(),p.positionMode===Tt.Fixed&&(b.position*=t),b.spacing=n.readFloat(),(p.spacingMode===nt.Length||p.spacingMode===nt.Fixed)&&(b.spacing*=t),b.mixRotate=n.readFloat(),b.mixX=n.readFloat(),b.mixY=n.readFloat(),o.push(p);break}case Ui:{const p=new ve(m);p.bone=a[n.readInt(!0)];let x=n.readByte();if(p.skinRequired=(x&1)!==0,(x&2)!==0&&(p.x=n.readFloat()),(x&4)!==0&&(p.y=n.readFloat()),(x&8)!==0&&(p.rotate=n.readFloat()),(x&16)!==0){let w=n.readFloat();w<-2?(p.scaleYMode=ct.Volume,w=-2-w):w<0&&(p.scaleYMode=ct.Uniform,w=-1-w),p.scaleX=w}(x&32)!==0&&(p.shearX=n.readFloat()),p.limit=((x&64)!==0?n.readFloat():5e3)*t,p.step=1/n.readUnsignedByte();const b=p.setupPose;b.inertia=n.readFloat(),b.strength=n.readFloat(),b.damping=n.readFloat(),b.massInverse=(x&128)!==0?n.readFloat():1,b.wind=n.readFloat(),b.gravity=n.readFloat(),x=n.readByte(),(x&1)!==0&&(p.inertiaGlobal=!0),(x&2)!==0&&(p.strengthGlobal=!0),(x&4)!==0&&(p.dampingGlobal=!0),(x&8)!==0&&(p.massGlobal=!0),(x&16)!==0&&(p.windGlobal=!0),(x&32)!==0&&(p.gravityGlobal=!0),(x&64)!==0&&(p.mixGlobal=!0),b.mix=(x&128)!==0?n.readFloat():1,o.push(p);break}case qi:{const p=new qt(m),x=n.readByte();if(p.skinRequired=(x&1)!==0,p.loop=(x&2)!==0,p.additive=(x&4)!==0,(x&8)!==0){const b=n.readFloat();c&&(x&64)!==0?p.max=b:p.setupPose.time=b}if((x&16)!==0&&(p.setupPose.mix=(x&32)!==0?n.readFloat():1),(x&64)!==0){p.local=(x&128)!==0,p.bone=a[n.readInt(!0)];const b=n.readFloat();let w=1;switch(n.readByte()){case 0:p.property=new Ue;break;case 1:{w=t,p.property=new qe;break}case 2:{w=t,p.property=new $e;break}case 3:p.property=new ze;break;case 4:p.property=new We;break;case 5:p.property=new Ge;break;default:continue}p.property.offset=b*w,p.offset=n.readFloat(),p.scale=n.readFloat()/w}o.push(p);break}}}const d=this.readSkin(n,s,!0,c);d&&(s.defaultSkin=d,s.skins.push(d));{let u=s.skins.length;for(L.setArraySize(s.skins,l=u+n.readInt(!0));u<l;u++){const m=this.readSkin(n,s,!1,c);if(!m)throw new Error("readSkin() should not have returned null.");s.skins[u]=m}}l=this.linkedMeshes.length;for(let u=0;u<l;u++){const m=this.linkedMeshes[u],g=s.skins[m.skinIndex];if(!m.source)throw new Error("Linked mesh parent must not be null");const p=g.getAttachment(m.sourceIndex,m.source);if(!p)throw new Error(`Source mesh not found: ${m.source}`);m.mesh.timelineAttachment=m.inheritTimelines?p:m.mesh,m.mesh.setSourceMesh(p),m.mesh.updateSequence()}this.linkedMeshes.length=0,l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Event data name must not be null");const g=new Ws(m),p=g.setupPose;p.intValue=n.readInt(!1),p.floatValue=n.readFloat(),p.stringValue=n.readString(),g._audioPath=n.readString(),g.audioPath&&(p.volume=n.readFloat(),p.balance=n.readFloat()),s.events.push(g)}const f=s.animations;l=n.readInt(!0);for(let u=0;u<l;u++){const m=n.readString();if(!m)throw new Error("Animation name must not be null.");f.push(this.readAnimation(n,m,s,c))}for(let u=0;u<h;u++){const m=o[u];m instanceof qt&&(m.animation=f[n.readInt(!0)])}return s}readSkin(e,t,s,n){let i=null,r=0;if(s){if(r=e.readInt(!0),r===0)return null;i=new Te("default")}else{const c=e.readString();if(!c)throw new Error("Skin name must not be null.");i=new Te(c),n&&$.rgba8888ToColor(i.color,e.readInt32());let l=e.readInt(!0),a=t.bones,o=i.bones;for(let h=0;h<l;h++)o[h]=a[e.readInt(!0)];l=e.readInt(!0),a=t.constraints,o=i.constraints;for(let h=0;h<l;h++)o[h]=a[e.readInt(!0)];r=e.readInt(!0)}for(let c=0;c<r;c++){const l=e.readInt(!0);for(let a=0,o=e.readInt(!0);a<o;a++){const h=e.readStringRef();if(!h)throw new Error("Attachment name must not be null");const d=this.readAttachment(e,t,i,l,h,n);d&&i.setAttachment(l,h,d)}}return i}readAttachment(e,t,s,n,i,r){const c=this.scale,l=e.readByte(),a=(l&8)!==0?e.readStringRef():i;if(!a)throw new Error("Attachment name must not be null");switch(l&7){case Xt.Region:{let o=(l&16)!==0?e.readStringRef():null;const h=(l&32)!==0?e.readInt32():4294967295,d=this.readSequence(e,(l&64)!==0),f=(l&128)!==0?e.readFloat():0,u=e.readFloat(),m=e.readFloat(),g=e.readFloat(),p=e.readFloat(),x=e.readFloat(),b=e.readFloat();o||(o=a);const w=this.attachmentLoader.newRegionAttachment(s,i,a,o,d);return w?(w.path=o,w.x=u*c,w.y=m*c,w.scaleX=g,w.scaleY=p,w.rotation=f,w.width=x*c,w.height=b*c,$.rgba8888ToColor(w.color,h),w.updateSequence(),w):null}case Xt.BoundingBox:{const o=this.readVertices(e,(l&16)!==0),h=r?e.readInt32():0,d=this.attachmentLoader.newBoundingBoxAttachment(s,i,a);return d?(d.worldVerticesLength=o.length,d.vertices=o.vertices,d.bones=o.bones,r&&$.rgba8888ToColor(d.color,h),d):null}case Xt.Mesh:{let o=(l&16)!==0?e.readStringRef():a;const h=(l&32)!==0?e.readInt32():4294967295,d=this.readSequence(e,(l&64)!==0),f=e.readInt(!0),u=this.readVertices(e,(l&128)!==0),m=this.readFloatArray(e,u.length,1),g=this.readShortArray(e,(u.length-f-2)*3),p=e.readInt(!0);let x=null;if(p>0){x=[];for(let v=0;v<p;v++)x[v]=e.readInt(!0)}let b=[],w=0,T=0;r&&(b=this.readShortArray(e,e.readInt(!0)),w=e.readFloat(),T=e.readFloat()),o||(o=a);const y=this.attachmentLoader.newMeshAttachment(s,i,a,o,d);return y?(y.path=o,$.rgba8888ToColor(y.color,h),y.hullLength=f<<1,y.bones=u.bones,y.vertices=u.vertices,y.worldVerticesLength=u.length,y.regionUVs=m,y.triangles=g,x&&(y.timelineSlots=x),r&&(y.edges=b,y.width=w*c,y.height=T*c),y.updateSequence(),y):null}case Xt.LinkedMesh:{const o=(l&16)!==0?e.readStringRef():a;if(o==null)throw new Error("Path of linked mesh must not be null");const h=(l&32)!==0?e.readInt32():4294967295,d=this.readSequence(e,(l&64)!==0),f=(l&128)!==0,u=e.readInt(!0),m=e.readInt(!0),g=e.readStringRef();let p=0,x=0;r&&(p=e.readFloat(),x=e.readFloat());const b=this.attachmentLoader.newMeshAttachment(s,i,a,o,d);return b?(b.path=o,$.rgba8888ToColor(b.color,h),r&&(b.width=p*c,b.height=x*c),this.linkedMeshes.push(new wi(b,m,n,u,g,f)),b):null}case Xt.Path:{const o=(l&16)!==0,h=(l&32)!==0,d=this.readVertices(e,(l&64)!==0),f=this.readFloatArray(e,d.length/6,c),u=r?e.readInt32():0,m=this.attachmentLoader.newPathAttachment(s,i,a);return m?(m.closed=o,m.constantSpeed=h,m.worldVerticesLength=d.length,m.vertices=d.vertices,m.bones=d.bones,m.lengths=f,r&&$.rgba8888ToColor(m.color,u),m):null}case Xt.Point:{const o=e.readFloat(),h=e.readFloat(),d=e.readFloat(),f=r?e.readInt32():0,u=this.attachmentLoader.newPointAttachment(s,i,a);return u?(u.x=h*c,u.y=d*c,u.rotation=o,r&&$.rgba8888ToColor(u.color,f),u):null}case Xt.Clipping:{const o=e.readInt(!0),h=this.readVertices(e,(l&16)!==0),d=r?e.readInt32():0,f=this.attachmentLoader.newClippingAttachment(s,i,a);return f?(f.endSlot=t.slots[o],f.convex=(l&32)!==0,f.inverse=(l&64)!==0,f.worldVerticesLength=h.length,f.vertices=h.vertices,f.bones=h.bones,r&&$.rgba8888ToColor(f.color,d),f):null}}}readSequence(e,t){if(!t)return new de(1,!1);const s=new de(e.readInt(!0),!0);return s.start=e.readInt(!0),s.digits=e.readInt(!0),s.setupIndex=e.readInt(!0),s}readVertices(e,t){const s=this.scale,i=e.readInt(!0)<<1;if(!t)return new Bn(null,this.readFloatArray(e,i,s),i);const r=e.readInt(!0),c=[],l=[];for(let a=0,o=0;a<r;){const h=e.readInt(!0);c[a++]=h;for(let d=0;d<h;d++,o+=3)c[a++]=e.readInt(!0),l[o]=e.readFloat()*s,l[o+1]=e.readFloat()*s,l[o+2]=e.readFloat()}return new Bn(c,L.toFloatArray(l),i)}readFloatArray(e,t,s){const n=[];if(s===1)for(let i=0;i<t;i++)n[i]=e.readFloat();else for(let i=0;i<t;i++)n[i]=e.readFloat()*s;return n}readShortArray(e,t){const s=[];for(let n=0;n<t;n++)s[n]=e.readInt(!0);return s}readAnimation(e,t,s,n){e.readInt(!0);const i=[],r=this.scale;for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0);for(let g=0,p=e.readInt(!0);g<p;g++){const x=e.readByte(),b=e.readInt(!0),w=b-1;switch(x){case Ei:{const T=new ee(b,m);for(let y=0;y<b;y++)T.setFrame(y,e.readFloat(),e.readStringRef());i.push(T);break}case Bi:{const T=e.readInt(!0),y=new xs(b,T,m);let v=e.readFloat(),S=e.readUnsignedByte()/255,C=e.readUnsignedByte()/255,A=e.readUnsignedByte()/255,P=e.readUnsignedByte()/255;for(let k=0,F=0;y.setFrame(k,v,S,C,A,P),k!==w;k++){const R=e.readFloat(),E=e.readUnsignedByte()/255,B=e.readUnsignedByte()/255,O=e.readUnsignedByte()/255,q=e.readUnsignedByte()/255;switch(e.readByte()){case kt:y.setStepped(k);break;case Mt:j(e,y,F++,k,0,v,R,S,E,1),j(e,y,F++,k,1,v,R,C,B,1),j(e,y,F++,k,2,v,R,A,O,1),j(e,y,F++,k,3,v,R,P,q,1)}v=R,S=E,C=B,A=O,P=q}i.push(y);break}case Xi:{const T=e.readInt(!0),y=new bs(b,T,m);let v=e.readFloat(),S=e.readUnsignedByte()/255,C=e.readUnsignedByte()/255,A=e.readUnsignedByte()/255;for(let P=0,k=0;y.setFrame(P,v,S,C,A),P!==w;P++){const F=e.readFloat(),R=e.readUnsignedByte()/255,E=e.readUnsignedByte()/255,B=e.readUnsignedByte()/255;switch(e.readByte()){case kt:y.setStepped(P);break;case Mt:j(e,y,k++,P,0,v,F,S,R,1),j(e,y,k++,P,1,v,F,C,E,1),j(e,y,k++,P,2,v,F,A,B,1)}v=F,S=R,C=E,A=B}i.push(y);break}case Li:{const T=e.readInt(!0),y=new ys(b,T,m);let v=e.readFloat(),S=e.readUnsignedByte()/255,C=e.readUnsignedByte()/255,A=e.readUnsignedByte()/255,P=e.readUnsignedByte()/255,k=e.readUnsignedByte()/255,F=e.readUnsignedByte()/255,R=e.readUnsignedByte()/255;for(let E=0,B=0;y.setFrame(E,v,S,C,A,P,k,F,R),E!==w;E++){const O=e.readFloat(),q=e.readUnsignedByte()/255,_=e.readUnsignedByte()/255,Y=e.readUnsignedByte()/255,M=e.readUnsignedByte()/255,N=e.readUnsignedByte()/255,D=e.readUnsignedByte()/255,G=e.readUnsignedByte()/255;switch(e.readByte()){case kt:y.setStepped(E);break;case Mt:j(e,y,B++,E,0,v,O,S,q,1),j(e,y,B++,E,1,v,O,C,_,1),j(e,y,B++,E,2,v,O,A,Y,1),j(e,y,B++,E,3,v,O,P,M,1),j(e,y,B++,E,4,v,O,k,N,1),j(e,y,B++,E,5,v,O,F,D,1),j(e,y,B++,E,6,v,O,R,G,1)}v=O,S=q,C=_,A=Y,P=M,k=N,F=D,R=G}i.push(y);break}case Vi:{const T=e.readInt(!0),y=new vs(b,T,m);let v=e.readFloat(),S=e.readUnsignedByte()/255,C=e.readUnsignedByte()/255,A=e.readUnsignedByte()/255,P=e.readUnsignedByte()/255,k=e.readUnsignedByte()/255,F=e.readUnsignedByte()/255;for(let R=0,E=0;y.setFrame(R,v,S,C,A,P,k,F),R!==w;R++){const B=e.readFloat(),O=e.readUnsignedByte()/255,q=e.readUnsignedByte()/255,_=e.readUnsignedByte()/255,Y=e.readUnsignedByte()/255,M=e.readUnsignedByte()/255,N=e.readUnsignedByte()/255;switch(e.readByte()){case kt:y.setStepped(R);break;case Mt:j(e,y,E++,R,0,v,B,S,O,1),j(e,y,E++,R,1,v,B,C,q,1),j(e,y,E++,R,2,v,B,A,_,1),j(e,y,E++,R,3,v,B,P,Y,1),j(e,y,E++,R,4,v,B,k,M,1),j(e,y,E++,R,5,v,B,F,N,1)}v=B,S=O,C=q,A=_,P=Y,k=M,F=N}i.push(y);break}case _i:{const T=new ws(b,e.readInt(!0),m);let y=e.readFloat(),v=e.readUnsignedByte()/255;for(let S=0,C=0;T.setFrame(S,y,v),S!==w;S++){const A=e.readFloat(),P=e.readUnsignedByte()/255;switch(e.readByte()){case kt:T.setStepped(S);break;case Mt:j(e,T,C++,S,0,y,A,v,P,1)}y=A,v=P}i.push(T)}}}}for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0);for(let g=0,p=e.readInt(!0);g<p;g++){const x=e.readByte(),b=e.readInt(!0);if(x===Ri){const T=new gs(b,m);for(let y=0;y<b;y++)T.setFrame(y,e.readFloat(),e.readByte());i.push(T);continue}const w=e.readInt(!0);switch(x){case Ti:st(e,i,new ue(b,w,m),1);break;case Si:st(e,i,new as(b,w,m),r);break;case Ci:st(e,i,new ls(b,w,m),r);break;case Ai:st(e,i,new cs(b,w,m),r);break;case Pi:st(e,i,new hs(b,w,m),1);break;case Ii:st(e,i,new ds(b,w,m),1);break;case ki:st(e,i,new fs(b,w,m),1);break;case Mi:st(e,i,new us(b,w,m),1);break;case Fi:st(e,i,new ms(b,w,m),1);break;case Yi:st(e,i,new ps(b,w,m),1);break}}}for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0),g=e.readInt(!0),p=g-1,x=new Cs(g,e.readInt(!0),m);let b=e.readByte(),w=e.readFloat(),T=(b&1)!==0?(b&2)!==0?e.readFloat():1:0,y=(b&4)!==0?e.readFloat()*r:0;for(let v=0,S=0;x.setFrame(v,w,T,y,(b&8)!==0?1:-1,(b&16)!==0,(b&32)!==0),v!==p;v++){b=e.readByte();const C=e.readFloat(),A=(b&1)!==0?(b&2)!==0?e.readFloat():1:0,P=(b&4)!==0?e.readFloat()*r:0;(b&64)!==0?x.setStepped(v):(b&128)!==0&&(j(e,x,S++,v,0,w,C,T,A,1),j(e,x,S++,v,1,w,C,y,P,r)),w=C,T=A,y=P}i.push(x)}for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0),g=e.readInt(!0),p=g-1,x=new As(g,e.readInt(!0),m);let b=e.readFloat(),w=e.readFloat(),T=e.readFloat(),y=e.readFloat(),v=e.readFloat(),S=e.readFloat(),C=e.readFloat();for(let A=0,P=0;x.setFrame(A,b,w,T,y,v,S,C),A!==p;A++){const k=e.readFloat(),F=e.readFloat(),R=e.readFloat(),E=e.readFloat(),B=e.readFloat(),O=e.readFloat(),q=e.readFloat();switch(e.readByte()){case kt:x.setStepped(A);break;case Mt:j(e,x,P++,A,0,b,k,w,F,1),j(e,x,P++,A,1,b,k,T,R,1),j(e,x,P++,A,2,b,k,y,E,1),j(e,x,P++,A,3,b,k,v,B,1),j(e,x,P++,A,4,b,k,S,O,1),j(e,x,P++,A,5,b,k,C,q,1)}b=k,w=F,T=R,y=E,v=B,S=O,C=q}i.push(x)}for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0),g=s.constraints[m];for(let p=0,x=e.readInt(!0);p<x;p++){const b=e.readByte(),w=e.readInt(!0),T=e.readInt(!0);switch(b){case Wi:st(e,i,new Ps(w,T,m),g.positionMode===Tt.Fixed?r:1);break;case Gi:st(e,i,new Is(w,T,m),g.spacingMode===nt.Length||g.spacingMode===nt.Fixed?r:1);break;case Hi:{const y=new ks(w,T,m);let v=e.readFloat(),S=e.readFloat(),C=e.readFloat(),A=e.readFloat();for(let P=0,k=0,F=y.getFrameCount()-1;y.setFrame(P,v,S,C,A),P!==F;P++){const R=e.readFloat(),E=e.readFloat(),B=e.readFloat(),O=e.readFloat();switch(e.readByte()){case kt:y.setStepped(P);break;case Mt:j(e,y,k++,P,0,v,R,S,E,1),j(e,y,k++,P,1,v,R,C,B,1),j(e,y,k++,P,2,v,R,A,O,1)}v=R,S=E,C=B,A=O}i.push(y)}}}}for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0)-1;for(let g=0,p=e.readInt(!0);g<p;g++){const x=e.readByte(),b=e.readInt(!0);if(x===sr){const T=new Ls(b,m);for(let y=0;y<b;y++)T.setFrame(y,e.readFloat());i.push(T);continue}const w=e.readInt(!0);switch(x){case ji:st(e,i,new Ms(b,w,m),1);break;case Ji:st(e,i,new Fs(b,w,m),1);break;case Ki:st(e,i,new Ys(b,w,m),1);break;case Qi:st(e,i,new Rs(b,w,m),1);break;case Zi:st(e,i,new Es(b,w,m),1);break;case tr:st(e,i,new Bs(b,w,m),1);break;case er:st(e,i,new Xs(b,w,m),1);break;default:throw new Error("Unknown physics timeline type.")}}}for(let f=0,u=e.readInt(!0);f<u;f++){const m=e.readInt(!0);for(let g=0,p=e.readInt(!0);g<p;g++){const x=e.readByte(),b=e.readInt(!0),w=e.readInt(!0);switch(x){case nr:st(e,i,new Vs(b,w,m),1);break;case ir:st(e,i,new _s(b,w,m),1);break;default:throw new Error(`Uknown slider type: ${x}`)}}}for(let f=0,u=e.readInt(!0);f<u;f++){const m=s.skins[e.readInt(!0)];for(let g=0,p=e.readInt(!0);g<p;g++){const x=e.readInt(!0);for(let b=0,w=e.readInt(!0);b<w;b++){const T=e.readStringRef();if(!T)throw new Error("attachmentName must not be null.");const y=m.getAttachment(x,T),v=e.readByte(),S=e.readInt(!0),C=S-1;switch(v){case $i:{const A=y,P=A.bones,k=A.vertices,F=P?k.length/3*2:k.length,R=e.readInt(!0),E=new Ts(S,R,x,A);let B=e.readFloat();for(let O=0,q=0;;O++){let _,Y=e.readInt(!0);if(Y===0)_=P?L.newFloatArray(F):k;else{_=L.newFloatArray(F);const N=e.readInt(!0);if(Y+=N,r===1)for(let D=N;D<Y;D++)_[D]=e.readFloat();else for(let D=N;D<Y;D++)_[D]=e.readFloat()*r;if(!P)for(let D=0,G=_.length;D<G;D++)_[D]+=k[D]}if(E.setFrame(O,B,_),O===C)break;const M=e.readFloat();switch(e.readByte()){case kt:E.setStepped(O);break;case Mt:j(e,E,q++,O,0,B,M,0,1,1)}B=M}i.push(E);break}case zi:{const A=new Ss(S,x,y);for(let P=0;P<S;P++){const k=e.readFloat(),F=e.readInt32();A.setFrame(P,k,os[F&15],F>>4,e.readFloat())}i.push(A);break}}}}}const c=s.slots.length,l=e.readInt(!0);if(l>0){const f=new Wt(l);for(let u=0;u<l;u++)f.setFrame(u,e.readFloat(),Xn(e,c));i.push(f)}const a=e.readInt(!0);for(let f=0;f<a;f++){const u=e.readInt(!0),m=new Array(u);for(let x=0;x<u;x++)m[x]=e.readInt(!0);const g=e.readInt(!0),p=new pe(g,m,c);for(let x=0;x<g;x++)p.setFrame(x,e.readFloat(),Xn(e,u));i.push(p)}const o=e.readInt(!0);if(o>0){const f=new Me(o);for(let u=0;u<o;u++){const m=e.readFloat(),g=s.events[e.readInt(!0)],p=new Be(m,g);p.intValue=e.readInt(!1),p.floatValue=e.readFloat(),p.stringValue=e.readString(),p.stringValue==null&&(p.stringValue=g.setupPose.stringValue),p.data.audioPath&&(p.volume=e.readFloat(),p.balance=e.readFloat()),f.setFrame(u,p)}i.push(f)}let h=0;for(let f=0,u=i.length;f<u;f++)h=Math.max(h,i[f].getDuration());const d=new Ie(t,i,h);return n&&$.rgba8888ToColor(d.color,e.readInt32()),d}},En=class{strings;index;buffer;constructor(e,t=[],s=0,n=new DataView(e instanceof ArrayBuffer?e:e.buffer)){this.strings=t,this.index=s,this.buffer=n}readByte(){return this.buffer.getInt8(this.index++)}readUnsignedByte(){return this.buffer.getUint8(this.index++)}readShort(){const e=this.buffer.getInt16(this.index);return this.index+=2,e}readInt32(){const e=this.buffer.getInt32(this.index);return this.index+=4,e}readInt(e){let t=this.readByte(),s=t&127;return(t&128)!==0&&(t=this.readByte(),s|=(t&127)<<7,(t&128)!==0&&(t=this.readByte(),s|=(t&127)<<14,(t&128)!==0&&(t=this.readByte(),s|=(t&127)<<21,(t&128)!==0&&(t=this.readByte(),s|=(t&127)<<28)))),e?s:s>>>1^-(s&1)}readStringRef(){const e=this.readInt(!0);return e===0?null:this.strings[e-1]}readString(){let e=this.readInt(!0);switch(e){case 0:return null;case 1:return""}e--;let t="";for(let s=0;s<e;){const n=this.readUnsignedByte();switch(n>>4){case 12:case 13:t+=String.fromCharCode((n&31)<<6|this.readByte()&63),s+=2;break;case 14:t+=String.fromCharCode((n&15)<<12|(this.readByte()&63)<<6|this.readByte()&63),s+=3;break;default:t+=String.fromCharCode(n),s++}}return t}readFloat(){const e=this.buffer.getFloat32(this.index);return this.index+=4,e}readBoolean(){return this.readByte()!==0}},wi=class{source;skinIndex;slotIndex;sourceIndex;mesh;inheritTimelines;constructor(e,t,s,n,i,r){this.mesh=e,this.skinIndex=t,this.slotIndex=s,this.sourceIndex=n,this.source=i,this.inheritTimelines=r}},Bn=class{bones;vertices;length;constructor(e=null,t,s=0){this.bones=e,this.vertices=t,this.length=s}},Xt;(function(e){e[e.Region=0]="Region",e[e.BoundingBox=1]="BoundingBox",e[e.Mesh=2]="Mesh",e[e.LinkedMesh=3]="LinkedMesh",e[e.Path=4]="Path",e[e.Point=5]="Point",e[e.Clipping=6]="Clipping"})(Xt||(Xt={}));function st(e,t,s,n){s instanceof fe?yi(e,t,s,n):vi(e,t,s,n)}function yi(e,t,s,n){let i=e.readFloat(),r=e.readFloat()*n;for(let c=0,l=0,a=s.getFrameCount()-1;s.setFrame(c,i,r),c!==a;c++){const o=e.readFloat(),h=e.readFloat()*n;switch(e.readByte()){case kt:s.setStepped(c);break;case Mt:j(e,s,l++,c,0,i,o,r,h,n)}i=o,r=h}t.push(s)}function vi(e,t,s,n){let i=e.readFloat(),r=e.readFloat()*n,c=e.readFloat()*n;for(let l=0,a=0,o=s.getFrameCount()-1;s.setFrame(l,i,r,c),l!==o;l++){const h=e.readFloat(),d=e.readFloat()*n,f=e.readFloat()*n;switch(e.readByte()){case kt:s.setStepped(l);break;case Mt:j(e,s,a++,l,0,i,h,r,d,n),j(e,s,a++,l,1,i,h,c,f,n)}i=h,r=d,c=f}t.push(s)}function Xn(e,t){const s=e.readInt(!0);if(s===0)return null;const n=new Array(t).fill(-1),i=new Array(t-s);let r=0,c=0;for(let l=0;l<s;l++){const a=e.readInt(!0);for(;r!==a;)i[c++]=r++;n[r+e.readInt(!0)]=r++}for(;r<t;)i[c++]=r++;for(let l=t-1;l>=0;l--)n[l]===-1&&(n[l]=i[--c]);return n}function j(e,t,s,n,i,r,c,l,a,o){t.setBezier(s,n,i,r,l,e.readFloat(),e.readFloat()*o,e.readFloat(),e.readFloat()*o,c,a)}var Ti=0,Si=1,Ci=2,Ai=3,Pi=4,Ii=5,ki=6,Mi=7,Fi=8,Yi=9,Ri=10,Ei=0,Bi=1,Xi=2,Li=3,Vi=4,_i=5,Oi=0,Di=1,Ni=2,Ui=3,qi=4,$i=0,zi=1,Wi=0,Gi=1,Hi=2,ji=0,Ji=1,Ki=2,Qi=4,Zi=5,tr=6,er=7,sr=8,nr=0,ir=1,kt=1,Mt=2,sn=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new te(()=>L.newFloatArray(16));update(e,t){if(!e)throw new Error("skeleton cannot be null.");const s=this.boundingBoxes,n=this.polygons,i=this.polygonPool,r=e.slots,c=r.length;s.length=0,i.freeAll(n),n.length=0;for(let l=0;l<c;l++){const a=r[l];if(!a.bone.active)continue;const o=a.appliedPose.attachment;if(o instanceof Us){s.push(o);let h=i.obtain();h.length!==o.worldVerticesLength&&(h=L.newFloatArray(o.worldVerticesLength)),n.push(h),o.computeWorldVertices(e,a,0,o.worldVerticesLength,h,0,2)}}t?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY;const i=this.polygons;for(let r=0,c=i.length;r<c;r++){const l=i[r],a=l;for(let o=0,h=l.length;o<h;o+=2){const d=a[o],f=a[o+1];e=Math.min(e,d),t=Math.min(t,f),s=Math.max(s,d),n=Math.max(n,f)}}this.minX=e,this.minY=t,this.maxX=s,this.maxY=n}aabbContainsPoint(e,t){return e>=this.minX&&e<=this.maxX&&t>=this.minY&&t<=this.maxY}aabbIntersectsSegment(e,t,s,n){const i=this.minX,r=this.minY,c=this.maxX,l=this.maxY;if(e<=i&&s<=i||t<=r&&n<=r||e>=c&&s>=c||t>=l&&n>=l)return!1;const a=(n-t)/(s-e);let o=a*(i-e)+t;if(o>r&&o<l||(o=a*(c-e)+t,o>r&&o<l))return!0;let h=(r-t)/a+e;return h>i&&h<c||(h=(l-t)/a+e,h>i&&h<c)}aabbIntersectsSkeleton(e){return this.minX<e.maxX&&this.maxX>e.minX&&this.minY<e.maxY&&this.maxY>e.minY}containsPoint(e,t){const s=this.polygons;for(let n=0,i=s.length;n<i;n++)if(this.containsPointPolygon(s[n],e,t))return this.boundingBoxes[n];return null}containsPointPolygon(e,t,s){const n=e,i=e.length;let r=i-2,c=!1;for(let l=0;l<i;l+=2){const a=n[l+1],o=n[r+1];if(a<s&&o>=s||o<s&&a>=s){const h=n[l];h+(s-a)/(o-a)*(n[r]-h)<t&&(c=!c)}r=l}return c}intersectsSegment(e,t,s,n){const i=this.polygons;for(let r=0,c=i.length;r<c;r++)if(this.intersectsSegmentPolygon(i[r],e,t,s,n))return this.boundingBoxes[r];return null}intersectsSegmentPolygon(e,t,s,n,i){const r=e,c=e.length,l=t-n,a=s-i,o=t*i-s*n;let h=r[c-2],d=r[c-1];for(let f=0;f<c;f+=2){const u=r[f],m=r[f+1],g=h*m-d*u,p=h-u,x=d-m,b=l*x-a*p,w=(o*p-l*g)/b;if((w>=h&&w<=u||w>=u&&w<=h)&&(w>=t&&w<=n||w>=n&&w<=t)){const T=(o*x-a*g)/b;if((T>=d&&T<=m||T>=m&&T<=d)&&(T>=s&&T<=i||T>=i&&T<=s))return!0}h=u,d=m}return!1}getPolygon(e){if(!e)throw new Error("boundingBox cannot be null.");const t=this.boundingBoxes.indexOf(e);return t===-1?null:this.polygons[t]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}},Ln=class xt{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new te(()=>[]);polygonIndicesPool=new te(()=>[]);triangulate(t){const s=t;let n=t.length>>1;const i=this.indicesArray;i.length=0;for(let l=0;l<n;l++)i[l]=l;const r=this.isConcaveArray;r.length=0;for(let l=0;l<n;l++)r[l]=xt.isConcave(l,n,s,i);const c=this.triangles;for(c.length=0;n>3;){let l=n-1,a=0,o=1;for(;;){t:if(!r[a]){const f=i[l]<<1,u=i[a]<<1,m=i[o]<<1,g=s[f],p=s[f+1],x=s[u],b=s[u+1],w=s[m],T=s[m+1];for(let y=o+1<n?o+1:0;y!==l;){if(r[y]){const v=i[y]<<1,S=s[v],C=s[v+1];if(xt.positiveArea(w,T,g,p,S,C)&&xt.positiveArea(g,p,x,b,S,C)&&xt.positiveArea(x,b,w,T,S,C))break t}++y===n&&(y=0)}break}if(o===0){do{if(!r[a])break;a--}while(a>0);l=a>0?a-1:n-1,o=a+1<n?a+1:0;break}l=a,a=o,++o===n&&(o=0)}c.push(i[l],i[a],i[o]),i.splice(a,1),r.splice(a,1),n--;const h=a>0?a-1:n-1,d=a<n?a:0;r[h]=xt.isConcave(h,n,s,i),r[d]=xt.isConcave(d,n,s,i)}return n===3&&c.push(i[2],i[0],i[1]),c}decompose(t,s){const n=t,i=this.convexPolygons;this.polygonPool.freeAll(i),i.length=0;const r=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(r),r.length=0;let c=this.polygonIndicesPool.obtain();c.length=0;let l=this.polygonPool.obtain();l.length=0;let a=-1,o=0;for(let h=0,d=s.length;h<d;h+=3){const f=s[h]<<1,u=s[h+1]<<1,m=s[h+2]<<1,g=n[f],p=n[f+1],x=n[u],b=n[u+1],w=n[m],T=n[m+1];if(a===f){const y=l.length-4;if(xt.winding(l[y],l[y+1],l[y+2],l[y+3],w,T)===o&&xt.winding(w,T,l[0],l[1],l[2],l[3])===o){l.push(w,T),c.push(m);continue}}l.length>0&&(i.push(l),r.push(c),l=this.polygonPool.obtain(),c=this.polygonIndicesPool.obtain()),l.length=0,l.push(g,p,x,b),l.push(w,T),c.length=0,c.push(f,u,m),o=xt.winding(g,p,x,b,w,T),a=f}l.length>0&&(i.push(l),r.push(c));for(let h=0,d=i.length;h<d;h++){if(c=r[h],c.length===0)continue;const f=c[0];let u=c[c.length-1];l=i[h];const m=l.length-4;let g=l[m],p=l[m+1],x=l[m+2],b=l[m+3];const w=l[0],T=l[1],y=l[2],v=l[3],S=xt.winding(g,p,x,b,w,T);for(let C=0;C<d;C++){if(C===h)continue;const A=r[C];if(A.length!==3)continue;const P=A[0],k=A[1],F=A[2],R=i[C],E=R[R.length-2],B=R[R.length-1];P!==f||k!==u||xt.winding(g,p,x,b,E,B)===S&&xt.winding(E,B,w,T,y,v)===S&&(R.length=0,A.length=0,l.push(E,B),c.push(F),u=F,g=x,p=b,x=E,b=B,C=-1)}}for(let h=i.length-1;h>=0;h--)l=i[h],l.length===0?(i.splice(h,1),this.polygonPool.free(l),c=r[h],r.splice(h,1),this.polygonIndicesPool.free(c)):l.push(l[0],l[1]);return i}static isConcave(t,s,n,i){const r=i[t>0?t-1:s-1]<<1,c=i[t]<<1,l=i[t+1<s?t+1:0]<<1;return!xt.positiveArea(n[r],n[r+1],n[c],n[c+1],n[l],n[l+1])}static positiveArea(t,s,n,i,r,c){return t*(c-i)+n*(s-c)+r*(i-s)>=0}static winding(t,s,n,i,r,c){return t*(c-i)+n*(s-c)+r*(i-s)>=0?1:-1}},Se=class{triangulator=null;clippingPolygon=[];clippingPolygons=[];clipOutput=[];clippedVertices=[];clippedUVs=[];clippedTriangles=[];inverseVertices=[];_clippedVerticesTyped=new Float32Array(1024);_clippedUVsTyped=new Float32Array(1024);_clippedTrianglesTyped=new Uint16Array(1024);clippedVerticesTyped=new Float32Array(0);clippedUVsTyped=new Float32Array(0);clippedTrianglesTyped=new Uint16Array(0);clippedVerticesLength=0;clippedUVsLength=0;clippedTrianglesLength=0;scratch=[];inverse=!1;clipAttachment=null;clipStart(e,t,s){if(this.clipAttachment)return;const n=s.worldVerticesLength;this.clipAttachment=s,this.inverse=s.inverse;const i=L.setArraySize(this.clippingPolygon,n);s.computeWorldVertices(e,t,0,n,i,0,2);const r=this.clippingPolygon,c=this.makeClockwise(r);c||this.inverse||s.convex?(c||this.makeConvex(r),this.clippingPolygon.push(r[0],r[1]),this.clippingPolygons.push(r)):(this.triangulator===null&&(this.triangulator=new Ln),this.clippingPolygons.push(...this.triangulator.decompose(r,this.triangulator.triangulate(r))))}clipEnd(e){this.clipAttachment&&(e&&this.clipAttachment.endSlot!==e.data||(this.clipAttachment=null,this.clippingPolygons.length=0))}isClipping(){return this.clipAttachment!=null}clipTriangles(e,t,s,n,i,r,c,l){return n&&i&&r&&typeof c=="boolean"&&typeof l=="number"?this.clipTrianglesRender(e,t,s,n,i,r,c,l):this.clipTrianglesNoRender(e,t,s)}clipTrianglesNoRender(e,t,s){const n=this.clippedVertices;n.length=0;const i=this.clippedTriangles;i.length=0;let r=0;if(this.inverse){const h=this.clippingPolygons[0];for(let d=0;d<s;d+=3){let f=t[d]<<1;const u=e[f],m=e[f+1];f=t[d+1]<<1;const g=e[f],p=e[f+1];f=t[d+2]<<1;const x=e[f],b=e[f+1];this.clipInverse(u,m,g,p,x,b,h);const w=this.inverseVertices;for(let T=0,y=this.inverseVertices.length;T<y;){const v=w[T++];let S=v>>1,C=n.length;const A=L.setArraySize(n,C+v);L.arrayCopy(w,T,A,C,v),C=i.length;const P=L.setArraySize(i,C+3*(S-2));for(let k=1;k<S-1;k++,C+=3)P[C]=r,P[C+1]=r+k,P[C+2]=r+k+1;r+=S,T+=v}}return!0}const c=this.clipOutput,l=this.clippingPolygons,a=l.length;let o=null;for(let h=0;h<s;h+=3){let d=t[h]<<1;const f=e[d],u=e[d+1];d=t[h+1]<<1;const m=e[d],g=e[d+1];d=t[h+2]<<1;const p=e[d],x=e[d+1];for(let b=0;b<a;b++){let w=n.length;if(this.clip(f,u,m,g,p,x,l[b])){o=this.clipOutput;const T=c.length;if(T===0)continue;let y=T>>1;const v=L.setArraySize(n,w+T);L.arrayCopy(o,0,v,w,T),w=i.length;const S=L.setArraySize(i,w+3*(y-2));y--;for(let C=1;C<y;C++,w+=3)S[w]=r,S[w+1]=r+C,S[w+2]=r+C+1;r+=y}else{const T=L.setArraySize(n,w+6);T[w]=f,T[w+1]=u,T[w+2]=m,T[w+3]=g,T[w+4]=p,T[w+5]=x,w=i.length;const y=L.setArraySize(i,w+3);y[w]=r,y[w+1]=r+1,y[w+2]=r+2,r+=3;break}}}return o!=null}clipTrianglesRender(e,t,s,n,i,r,c,l){const a=this.clippedVertices;a.length=0;const o=this.clippedTriangles;o.length=0;let h=0;if(this.inverse){const g=this.clippingPolygons[0];for(let p=0;p<s;p+=3){let x=t[p],b=t[p+1],w=t[p+2];const T=e[x*l],y=e[x*l+1],v=e[b*l],S=e[b*l+1],C=e[w*l],A=e[w*l+1];this.clipInverse(T,y,v,S,C,A,g);const P=this.inverseVertices.length;if(P===0)continue;const k=n[x<<=1],F=n[x+1],R=n[b<<=1],E=n[b+1],B=n[w<<=1],O=n[w+1],q=S-A,_=C-v,Y=T-C,M=A-y,N=1/(q*Y+_*(y-A)),D=this.inverseVertices;for(let G=0;G<P;){const V=D[G++],z=V>>1;let U=a.length;const Q=L.setArraySize(a,U+z*l);for(let Z=0;Z<V;Z+=2,U+=l){const at=D[G+Z],dt=D[G+Z+1];Q[U]=at,Q[U+1]=dt,Q[U+2]=i.r,Q[U+3]=i.g,Q[U+4]=i.b,Q[U+5]=i.a;const lt=at-C,Ct=dt-A,mt=(q*lt+_*Ct)*N,gt=(M*lt+Y*Ct)*N,At=1-mt-gt;Q[U+6]=k*mt+R*gt+B*At,Q[U+7]=F*mt+E*gt+O*At,c&&(Q[U+8]=r.r,Q[U+9]=r.g,Q[U+10]=r.b,Q[U+11]=r.a)}U=o.length;const rt=L.setArraySize(o,U+3*(z-2));for(let Z=1;Z<z-1;Z++,U+=3)rt[U]=h,rt[U+1]=h+Z,rt[U+2]=h+Z+1;h+=z,G+=V}}return!0}const d=this.clipOutput,f=this.clippingPolygons,u=this.clippingPolygons.length;let m=null;for(let g=0;g<s;g+=3){let p=t[g];const x=e[p*l],b=e[p*l+1],w=n[p<<1],T=n[(p<<1)+1];p=t[g+1];const y=e[p*l],v=e[p*l+1],S=n[p<<1],C=n[(p<<1)+1];p=t[g+2];const A=e[p*l],P=e[p*l+1],k=n[p<<1],F=n[(p<<1)+1],R=v-P,E=A-y,B=x-A,O=P-b,q=1/(R*B+E*(b-P));for(let _=0;_<u;_++){let Y=a.length;if(this.clip(x,b,y,v,A,P,f[_])){m=this.clipOutput;const M=d.length;if(M===0)continue;let N=M>>1;const D=L.setArraySize(a,Y+N*l);for(let V=0;V<M;V+=2,Y+=l){const z=m[V],U=m[V+1];D[Y]=z,D[Y+1]=U,D[Y+2]=i.r,D[Y+3]=i.g,D[Y+4]=i.b,D[Y+5]=i.a;const Q=z-A,rt=U-P,Z=(R*Q+E*rt)*q,at=(O*Q+B*rt)*q,dt=1-Z-at;D[Y+6]=w*Z+S*at+k*dt,D[Y+7]=T*Z+C*at+F*dt,c&&(D[Y+8]=r.r,D[Y+9]=r.g,D[Y+10]=r.b,D[Y+11]=r.a)}Y=o.length;const G=L.setArraySize(o,Y+3*(N-2));N--;for(let V=1;V<N;V++,Y+=3)G[Y]=h,G[Y+1]=h+V,G[Y+2]=h+V+1;h+=N+1}else{const M=L.setArraySize(a,Y+3*l);M[Y]=x,M[Y+1]=b,M[Y+2]=i.r,M[Y+3]=i.g,M[Y+4]=i.b,M[Y+5]=i.a,c?(M[Y+6]=w,M[Y+7]=T,M[Y+8]=r.r,M[Y+9]=r.g,M[Y+10]=r.b,M[Y+11]=r.a,M[Y+12]=y,M[Y+13]=v,M[Y+14]=i.r,M[Y+15]=i.g,M[Y+16]=i.b,M[Y+17]=i.a,M[Y+18]=S,M[Y+19]=C,M[Y+20]=r.r,M[Y+21]=r.g,M[Y+22]=r.b,M[Y+23]=r.a,M[Y+24]=A,M[Y+25]=P,M[Y+26]=i.r,M[Y+27]=i.g,M[Y+28]=i.b,M[Y+29]=i.a,M[Y+30]=k,M[Y+31]=F,M[Y+32]=r.r,M[Y+33]=r.g,M[Y+34]=r.b,M[Y+35]=r.a):(M[Y+6]=w,M[Y+7]=T,M[Y+8]=y,M[Y+9]=v,M[Y+10]=i.r,M[Y+11]=i.g,M[Y+12]=i.b,M[Y+13]=i.a,M[Y+14]=S,M[Y+15]=C,M[Y+16]=A,M[Y+17]=P,M[Y+18]=i.r,M[Y+19]=i.g,M[Y+20]=i.b,M[Y+21]=i.a,M[Y+22]=k,M[Y+23]=F),Y=o.length;const N=L.setArraySize(o,Y+3);N[Y]=h,N[Y+1]=h+1,N[Y+2]=h+2,h+=3;break}}}return m!=null}clipTrianglesUnpacked(e,t,s,n,i,r=2){let c=this._clippedVerticesTyped,l=this._clippedUVsTyped,a=this._clippedTrianglesTyped,o=0;if(this.clippedVerticesLength=0,this.clippedUVsLength=0,this.clippedTrianglesLength=0,this.inverse){const m=this.clippingPolygons[0];for(let g=0;g<n;g+=3){let p=s[g]*r;const x=e[t+p],b=e[t+p+1];let w=s[g]<<1;const T=i[w],y=i[w+1];p=s[g+1]*r;const v=e[t+p],S=e[t+p+1];w=s[g+1]<<1;const C=i[w],A=i[w+1];p=s[g+2]*r;const P=e[t+p],k=e[t+p+1];w=s[g+2]<<1;const F=i[w],R=i[w+1];this.clipInverse(x,b,v,S,P,k,m);const E=this.inverseVertices.length;if(E===0)continue;const B=S-k,O=P-v,q=x-P,_=k-b,Y=1/(B*q+O*(b-k)),M=this.inverseVertices;for(let N=0;N<E;){const D=M[N++],G=D>>1;let V=this.clippedVerticesLength;const z=V+G*r,U=this.clippedUVsLength+G*2;c.length<z&&(this._clippedVerticesTyped=new Float32Array(z*2),this._clippedVerticesTyped.set(c.subarray(0,V)),c=this._clippedVerticesTyped),l.length<U&&(this._clippedUVsTyped=new Float32Array(U*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),l=this._clippedUVsTyped),this.clippedVerticesLength=z,this.clippedUVsLength=U;const Q=this._clippedVerticesTyped,rt=this._clippedUVsTyped;let Z=U-G*2;for(let lt=0;lt<D;lt+=2,V+=r,Z+=2){const Ct=M[N+lt],mt=M[N+lt+1];Q[V]=Ct,Q[V+1]=mt;const gt=Ct-P,At=mt-k,Yt=(B*gt+O*At)*Y,Vt=(_*gt+q*At)*Y,Ce=1-Yt-Vt;rt[Z]=T*Yt+C*Vt+F*Ce,rt[Z+1]=y*Yt+A*Vt+R*Ce}V=this.clippedTrianglesLength;const at=V+3*(G-2);a.length<at&&(this._clippedTrianglesTyped=new Uint16Array(at*2),this._clippedTrianglesTyped.set(a.subarray(0,V)),a=this._clippedTrianglesTyped),this.clippedTrianglesLength=at;const dt=a;for(let lt=1;lt<G-1;lt++,V+=3)dt[V]=o,dt[V+1]=o+lt,dt[V+2]=o+lt+1;o+=G,N+=D}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),!0}const h=this.clipOutput,d=this.clippingPolygons,f=this.clippingPolygons.length;let u=null;for(let m=0;m<n;m+=3){let g=s[m],p=g*r;const x=e[t+p],b=e[t+p+1];let w=g<<1;const T=i[w],y=i[w+1];g=s[m+1],p=g*r;const v=e[t+p],S=e[t+p+1];w=g<<1;const C=i[w],A=i[w+1];g=s[m+2],p=g*r;const P=e[t+p],k=e[t+p+1];w=g<<1;const F=i[w],R=i[w+1],E=S-k,B=P-v,O=x-P,q=k-b,_=1/(E*O+B*(b-k));for(let Y=0;Y<f;Y++){let M=this.clippedVerticesLength;if(this.clip(x,b,v,S,P,k,d[Y])){u=h;const N=h.length;if(N===0)continue;let D=N>>1;const G=M+D*r;c.length<G&&(this._clippedVerticesTyped=new Float32Array(G*2),this._clippedVerticesTyped.set(c.subarray(0,M)),this._clippedUVsTyped=new Float32Array((this.clippedUVsLength+D*2)*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),c=this._clippedVerticesTyped,l=this._clippedUVsTyped);const V=c,z=l;this.clippedVerticesLength=G;let U=this.clippedUVsLength;this.clippedUVsLength=U+D*2;for(let Z=0;Z<N;Z+=2,M+=r,U+=2){const at=u[Z],dt=u[Z+1];V[M]=at,V[M+1]=dt;const lt=at-P,Ct=dt-k,mt=(E*lt+B*Ct)*_,gt=(q*lt+O*Ct)*_,At=1-mt-gt;z[U]=T*mt+C*gt+F*At,z[U+1]=y*mt+A*gt+R*At}M=this.clippedTrianglesLength;const Q=M+3*(D-2);a.length<Q&&(this._clippedTrianglesTyped=new Uint16Array(Q*2),this._clippedTrianglesTyped.set(a.subarray(0,M)),a=this._clippedTrianglesTyped),this.clippedTrianglesLength=Q;const rt=a;D--;for(let Z=1;Z<D;Z++,M+=3)rt[M]=o,rt[M+1]=o+Z,rt[M+2]=o+Z+1;o+=D+1}else{let N=M+3*r;c.length<N&&(this._clippedVerticesTyped=new Float32Array(N*2),this._clippedVerticesTyped.set(c.subarray(0,M)),c=this._clippedVerticesTyped),c[M]=x,c[M+1]=b,c[M+r]=v,c[M+r+1]=S,c[M+r*2]=P,c[M+r*2+1]=k;const D=this.clippedUVsLength+3*2;l.length<D&&(this._clippedUVsTyped=new Float32Array(D*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),l=this._clippedUVsTyped);const G=this.clippedUVsLength;l[G]=T,l[G+1]=y,l[G+2]=C,l[G+3]=A,l[G+4]=F,l[G+5]=R,this.clippedVerticesLength=N,this.clippedUVsLength=D,M=this.clippedTrianglesLength,N=M+3,a.length<N&&(this._clippedTrianglesTyped=new Uint16Array(N*2),this._clippedTrianglesTyped.set(a.subarray(0,M)),a=this._clippedTrianglesTyped);const V=a;V[M]=o,V[M+1]=o+1,V[M+2]=o+2,o+=3,this.clippedTrianglesLength=N;break}}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),u!==null}clip(e,t,s,n,i,r,c){const l=this.clipOutput;let a=!1,o,h;c.length%4>=2?(o=this.clipOutput,h=this.scratch):(o=this.scratch,h=this.clipOutput);const d=c;o.length=8;const f=o;f[0]=e,f[1]=t,f[2]=s,f[3]=n,f[4]=i,f[5]=r,f[6]=e,f[7]=t,h.length=0;const u=c.length-4;for(let m=0;;m+=2){const g=d[m],p=d[m+1],x=g-d[m+2],b=p-d[m+3],w=h.length,T=o;for(let v=0,S=o.length-2;v<S;){e=T[v],t=T[v+1],v+=2,s=T[v],n=T[v+1];const C=b*(g-s)>x*(p-n),A=b*(g-e)-x*(p-t);if(A>0)if(C)h.push(s,n);else{const P=s-e,k=n-t,F=A/(P*b-k*x);F>=0&&F<=1?(h.push(e+P*F,t+k*F),a=!0):h.push(s,n)}else if(C){const P=s-e,k=n-t,F=A/(P*b-k*x);F>=0&&F<=1?(h.push(e+P*F,t+k*F,s,n),a=!0):h.push(s,n)}else a=!0}if(w===h.length)return l.length=0,!0;if(h.push(h[0],h[1]),m===u)break;const y=h;h=o,h.length=0,o=y}if(l!==h){l.length=0;for(let m=0,g=h.length-2;m<g;m++)l[m]=h[m]}else l.length=l.length-2;return a}clipInverse(e,t,s,n,i,r,c){this.inverseVertices.length=0;const l=c.length-4;let a,o;c.length%4>=2?(a=this.clipOutput,o=this.scratch):(a=this.scratch,o=this.clipOutput),a.length=8;let h=c,d=a;d[0]=e,d[1]=t,d[2]=s,d[3]=n,d[4]=i,d[5]=r,d[6]=e,d[7]=t,o.length=0;for(let f=0;;f+=2){const u=h[f],m=h[f+1],g=u-h[f+2],p=m-h[f+3],x=o.length,b=this.inverseVertices.length;this.inverseVertices.push(0),d=a;for(let y=0,v=a.length-2;y<v;){e=d[y],t=d[y+1],y+=2,s=d[y],n=d[y+1];const S=p*(u-s)>g*(m-n),C=p*(u-e)-g*(m-t);if(C>0)if(S)o.push(s,n);else{const A=s-e,P=n-t,k=C/(A*p-P*g);if(k>=0&&k<=1){const F=e+A*k,R=t+P*k;o.push(F,R),this.inverseVertices.push(F,R,s,n)}else o.push(s,n)}else if(S){const A=s-e,P=n-t,k=C/(A*p-P*g);if(k>=0&&k<=1){const F=e+A*k,R=t+P*k;this.inverseVertices.push(F,R),o.push(F,R,s,n)}else o.push(s,n)}else this.inverseVertices.push(s,n)}const w=this.inverseVertices.length-b-1;if(w>=6?this.inverseVertices[b]=w:this.inverseVertices.length=b,x===o.length||(o.push(o[0],o[1]),f===l))break;const T=o;o=a,o.length=0,a=T}}makeClockwise(e){const t=e,s=e.length;let n=!0,i=!0,r=0,c=t[s-2],l=t[s-1],a=t[0],o=t[1];for(let d=2;d<s;d+=2){const f=t[d],u=t[d+1];r+=a*u-f*o;const m=(a-c)*(u-o)-(o-l)*(f-a);i=i&&m<=0,n=n&&m>=0,c=a,l=o,a=f,o=u}r+=a*t[1]-t[0]*o;const h=(a-c)*(t[1]-o)-(o-l)*(t[0]-a);if(i=i&&h<=0,n=n&&h>=0,r>=0){for(let d=0,f=s-2,u=s>>1;d<u;d+=2){const m=t[d],g=t[d+1],p=f-d;t[d]=t[p],t[d+1]=t[p+1],t[p]=m,t[p+1]=g}return n}return i}makeConvex(e){const t=e.length,s=e;this.clipOutput.length=t;const n=this.clipOutput;n[0]=s[0],n[1]=s[1];for(let c=2;c<t;c+=2){const l=s[c],a=s[c+1];let o=c-2;for(;o>=0&&(n[o]>l||n[o]===l&&n[o+1]>a);o-=2)n[o+2]=n[o],n[o+3]=n[o+1];n[o+2]=l,n[o+3]=a}s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3];let i=4;for(let c=4;c<t;c+=2,i+=2){const l=n[c],a=n[c+1];for(;(s[i-2]-s[i-4])*(a-s[i-3])-(s[i-1]-s[i-3])*(l-s[i-4])>=0&&(i-=2,i!==2););s[i]=l,s[i+1]=a}s[i]=n[t-4],s[i+1]=n[t-3];const r=i;i+=2;for(let c=t-6;c>=0;c-=2,i+=2){const l=n[c],a=n[c+1];for(;(s[i-2]-s[i-4])*(a-s[i-3])-(s[i-1]-s[i-3])*(l-s[i-4])>=0&&(i-=2,i!==r););s[i]=l,s[i+1]=a}e.length=i-2}},Vn=class{attachmentLoader;scale=1;linkedMeshes=[];constructor(e){this.attachmentLoader=e}readSkeletonData(e){const t=this.scale,s=new De,n=typeof e=="string"?JSON.parse(e):e,i=n.skeleton;if(i&&(s.hash=i.hash,s.version=i.spine,s.x=i.x,s.y=i.y,s.width=i.width,s.height=i.height,s.referenceScale=I(i,"referenceScale",100)*t,s.fps=i.fps,s.imagesPath=i.images??null,s.audioPath=i.audio??null),n.bones)for(let r=0;r<n.bones.length;r++){const c=n.bones[r];let l=null;const a=I(c,"parent",null);a&&(l=s.findBone(a));const o=new qs(s.bones.length,c.name,l);o.length=I(c,"length",0)*t;const h=o.setupPose;h.x=I(c,"x",0)*t,h.y=I(c,"y",0)*t,h.rotation=I(c,"rotation",0),h.scaleX=I(c,"scaleX",1),h.scaleY=I(c,"scaleY",1),h.shearX=I(c,"shearX",0),h.shearY=I(c,"shearY",0),h.inherit=L.enumValue(et,I(c,"inherit","Normal")),o.skinRequired=I(c,"skin",!1);const d=I(c,"color",null);d&&o.color.setFromString(d),o.icon=I(c,"icon",void 0),o.iconSize=I(c,"iconSize",1),o.iconRotation=I(c,"iconRotation",0),s.bones.push(o)}if(n.slots)for(let r=0;r<n.slots.length;r++){const c=n.slots[r],l=c.name,a=s.findBone(c.bone);if(!a)throw new Error(`Couldn't find bone ${c.bone} for slot ${l}`);const o=new js(s.slots.length,l,a),h=I(c,"color",null);h&&o.setupPose.color.setFromString(h);const d=I(c,"dark",null);d&&(o.setupPose.darkColor=$.fromString(d)),o.attachmentName=I(c,"attachment",null),o.blendMode=L.enumValue(It,I(c,"blend","normal")),o.visible=I(c,"visible",!0),s.slots.push(o)}if(n.constraints)for(const r of n.constraints){const c=r.name,l=I(r,"skin",!1);switch(I(r,"type",!1)){case"ik":{const a=new we(c);a.skinRequired=l;for(let u=0;u<r.bones.length;u++){const m=s.findBone(r.bones[u]);if(!m)throw new Error(`Couldn't find bone ${r.bones[u]} for IK constraint ${c}.`);a.bones.push(m)}const o=r.target,h=s.findBone(o);if(!h)throw new Error(`Couldn't find target bone ${o} for IK constraint ${c}.`);a.target=h;const d=I(r,"scaleY",null);d!=null&&(a.scaleYMode=L.enumValue(ct,d));const f=a.setupPose;f.mix=I(r,"mix",1),f.softness=I(r,"softness",0)*t,f.bendDirection=I(r,"bendPositive",!0)?1:-1,f.compress=I(r,"compress",!1),f.stretch=I(r,"stretch",!1),s.constraints.push(a);break}case"transform":{const a=new K(c);a.skinRequired=l;for(let w=0;w<r.bones.length;w++){const T=r.bones[w],y=s.findBone(T);if(!y)throw new Error(`Couldn't find bone ${T} for transform constraint ${r.name}.`);a.bones.push(y)}const o=r.source,h=s.findBone(o);if(!h)throw new Error(`Couldn't find source bone ${o} for transform constraint ${r.name}.`);a.source=h,a.localSource=I(r,"localSource",!1),a.localTarget=I(r,"localTarget",!1),a.additive=I(r,"additive",!1),a.clamp=I(r,"clamp",!1);let d=!1,f=!1,u=!1,m=!1,g=!1,p=!1;const x=Object.entries(I(r,"properties",{}));for(const[w,T]of x){const y=this.fromProperty(w),v=this.propertyScale(w,t);y.offset=I(T,"offset",0)*v;const S=Object.entries(I(T,"to",{}));for(const[C,A]of S){let P=1,k;switch(C){case"rotate":{d=!0,k=new Js;break}case"x":{f=!0,k=new Ks,P=t;break}case"y":{u=!0,k=new Qs,P=t;break}case"scaleX":{m=!0,k=new Zs;break}case"scaleY":{g=!0,k=new tn;break}case"shearY":{p=!0,k=new en;break}default:throw new Error(`Invalid transform constraint to property: ${C}`)}k.offset=I(A,"offset",0)*P,k.max=I(A,"max",1)*P,k.scale=I(A,"scale",1)*P/v,y.to.push(k)}y.to.length>0&&a.properties.push(y)}a.offsets[K.ROTATION]=I(r,"rotation",0),a.offsets[K.X]=I(r,"x",0)*t,a.offsets[K.Y]=I(r,"y",0)*t,a.offsets[K.SCALEX]=I(r,"scaleX",0),a.offsets[K.SCALEY]=I(r,"scaleY",0),a.offsets[K.SHEARY]=I(r,"shearY",0);const b=a.setupPose;d&&(b.mixRotate=I(r,"mixRotate",1)),f&&(b.mixX=I(r,"mixX",1)),u&&(b.mixY=I(r,"mixY",b.mixX)),m&&(b.mixScaleX=I(r,"mixScaleX",1)),g&&(b.mixScaleY=I(r,"mixScaleY",b.mixScaleX)),p&&(b.mixShearY=I(r,"mixShearY",1)),s.constraints.push(a);break}case"path":{const a=new ye(c);a.skinRequired=l;for(let f=0;f<r.bones.length;f++){const u=r.bones[f],m=s.findBone(u);if(!m)throw new Error(`Couldn't find bone ${u} for path constraint ${r.name}.`);a.bones.push(m)}const o=r.slot,h=s.findSlot(o);if(!h)throw new Error(`Couldn't find slot ${o} for path constraint ${r.name}.`);a.slot=h,a.positionMode=L.enumValue(Tt,I(r,"positionMode","Percent")),a.spacingMode=L.enumValue(nt,I(r,"spacingMode","Length")),a.rotateMode=L.enumValue(Ut,I(r,"rotateMode","Tangent")),a.offsetRotation=I(r,"rotation",0);const d=a.setupPose;d.position=I(r,"position",0),a.positionMode===Tt.Fixed&&(d.position*=t),d.spacing=I(r,"spacing",0),(a.spacingMode===nt.Length||a.spacingMode===nt.Fixed)&&(d.spacing*=t),d.mixRotate=I(r,"mixRotate",1),d.mixX=I(r,"mixX",1),d.mixY=I(r,"mixY",d.mixX),s.constraints.push(a);break}case"physics":{const a=new ve(c);a.skinRequired=l;const o=r.bone,h=s.findBone(o);if(h==null)throw new Error(`Physics bone not found: ${o}`);a.bone=h,a.x=I(r,"x",0),a.y=I(r,"y",0),a.rotate=I(r,"rotate",0),a.scaleX=I(r,"scaleX",0);const d=I(r,"scaleY",null);d!=null&&(a.scaleYMode=L.enumValue(ct,d)),a.shearX=I(r,"shearX",0),a.limit=I(r,"limit",5e3)*t,a.step=1/I(r,"fps",60);const f=a.setupPose;f.inertia=I(r,"inertia",.5),f.strength=I(r,"strength",100),f.damping=I(r,"damping",.85),f.massInverse=1/I(r,"mass",1),f.wind=I(r,"wind",0),f.gravity=I(r,"gravity",0),f.mix=I(r,"mix",1),a.inertiaGlobal=I(r,"inertiaGlobal",!1),a.strengthGlobal=I(r,"strengthGlobal",!1),a.dampingGlobal=I(r,"dampingGlobal",!1),a.massGlobal=I(r,"massGlobal",!1),a.windGlobal=I(r,"windGlobal",!1),a.gravityGlobal=I(r,"gravityGlobal",!1),a.mixGlobal=I(r,"mixGlobal",!1),s.constraints.push(a);break}case"slider":{const a=new qt(c);a.skinRequired=l,a.additive=I(r,"additive",!1),a.loop=I(r,"loop",!1),a.setupPose.mix=I(r,"mix",1);const o=r.bone;if(o){if(a.bone=s.findBone(o),!a.bone)throw new Error(`Slider bone not found: ${o}`);const h=r.property;a.property=this.fromProperty(h);const d=this.propertyScale(h,t);a.property.offset=I(r,"from",0)*d,a.offset=I(r,"to",0),a.scale=I(r,"scale",1)/d,a.max=I(r,"max",0),a.local=I(r,"local",!1)}else a.setupPose.time=I(r,"time",0);s.constraints.push(a);break}}}if(n.skins)for(let r=0;r<n.skins.length;r++){const c=n.skins[r],l=new Te(c.name);if(c.bones)for(let a=0;a<c.bones.length;a++){const o=c.bones[a],h=s.findBone(o);if(!h)throw new Error(`Couldn't find bone ${o} for skin ${c.name}.`);l.bones.push(h)}if(c.ik)for(let a=0;a<c.ik.length;a++){const o=c.ik[a],h=s.findConstraint(o,we);if(!h)throw new Error(`Couldn't find IK constraint ${o} for skin ${c.name}.`);l.constraints.push(h)}if(c.transform)for(let a=0;a<c.transform.length;a++){const o=c.transform[a],h=s.findConstraint(o,K);if(!h)throw new Error(`Couldn't find transform constraint ${o} for skin ${c.name}.`);l.constraints.push(h)}if(c.path)for(let a=0;a<c.path.length;a++){const o=c.path[a],h=s.findConstraint(o,ye);if(!h)throw new Error(`Couldn't find path constraint ${o} for skin ${c.name}.`);l.constraints.push(h)}if(c.physics)for(let a=0;a<c.physics.length;a++){const o=c.physics[a],h=s.findConstraint(o,ve);if(!h)throw new Error(`Couldn't find physics constraint ${o} for skin ${c.name}.`);l.constraints.push(h)}if(c.slider)for(let a=0;a<c.slider.length;a++){const o=c.slider[a],h=s.findConstraint(o,qt);if(!h)throw new Error(`Couldn't find slider constraint ${o} for skin ${c.name}.`);l.constraints.push(h)}for(const a in c.attachments){const o=s.findSlot(a);if(!o)throw new Error(`Couldn't find skin slot ${a} for skin ${c.name}.`);const h=c.attachments[a];for(const d in h){const f=this.readAttachment(h[d],l,o.index,d,s);f&&l.setAttachment(o.index,d,f)}}s.skins.push(l),l.name==="default"&&(s.defaultSkin=l)}for(let r=0,c=this.linkedMeshes.length;r<c;r++){const l=this.linkedMeshes[r],a=l.skin?s.findSkin(l.skin):s.defaultSkin;if(!a)throw new Error(`Skin not found: ${l.skin}`);const o=a.getAttachment(l.sourceIndex,l.source);if(!o)throw new Error(`Source mesh not found: ${l.source}`);l.mesh.timelineAttachment=l.inheritTimelines?o:l.mesh,l.mesh.setSourceMesh(o),l.mesh.updateSequence();t:if(l.inheritTimelines&&l.slotIndex!==l.sourceIndex){const h=o.timelineSlots;for(const f of h)if(f===l.slotIndex)break t;const d=[...h];d[h.length]=l.slotIndex,o.timelineSlots=d}}if(this.linkedMeshes.length=0,n.events)for(const r in n.events){const c=n.events[r],l=new Ws(r),a=l.setupPose;a.intValue=I(c,"int",0),a.floatValue=I(c,"float",0),a.stringValue=I(c,"string",""),l._audioPath=I(c,"audio",null),l.audioPath&&(a.volume=I(c,"volume",a.volume),a.balance=I(c,"balance",a.balance)),s.events.push(l)}if(n.animations)for(const r in n.animations){const c=n.animations[r];this.readAnimation(c,r,s)}if(n.constraints)for(const r in n.constraints){const c=n.constraints[r];if(c.type==="slider"){const l=s.findConstraint(c.name,qt),a=c.animation,o=s.findAnimation(a);if(!o)throw new Error(`Slider animation not found: ${a}`);l.animation=o}}return s}fromProperty(e){let t;switch(e){case"rotate":t=new Ue;break;case"x":t=new qe;break;case"y":t=new $e;break;case"scaleX":t=new ze;break;case"scaleY":t=new We;break;case"shearY":t=new Ge;break;default:throw new Error(`Invalid transform constraint from property: ${e}`)}return t}propertyScale(e,t){switch(e){case"x":case"y":return t;default:return 1}}readAttachment(e,t,s,n,i){const r=this.scale,c=I(e,"name",n);switch(I(e,"type","region")){case"region":{const l=I(e,"path",c),a=this.readSequence(I(e,"sequence",null)),o=this.attachmentLoader.newRegionAttachment(t,n,c,l,a);if(!o)return null;o.path=l,o.x=I(e,"x",0)*r,o.y=I(e,"y",0)*r,o.scaleX=I(e,"scaleX",1),o.scaleY=I(e,"scaleY",1),o.rotation=I(e,"rotation",0),o.width=e.width*r,o.height=e.height*r;const h=I(e,"color",null);return h&&o.color.setFromString(h),o.updateSequence(),o}case"boundingbox":{const l=this.attachmentLoader.newBoundingBoxAttachment(t,n,c);if(!l)return null;this.readVertices(e,l,e.vertexCount<<1);const a=I(e,"color",null);return a&&l.color.setFromString(a),l}case"mesh":case"linkedmesh":{const l=I(e,"path",c),a=this.readSequence(I(e,"sequence",null)),o=this.attachmentLoader.newMeshAttachment(t,n,c,l,a);if(!o)return null;o.path=l;const h=I(e,"color",null);h&&o.color.setFromString(h),o.width=I(e,"width",0)*r,o.height=I(e,"height",0)*r;const d=I(e,"source",null);if(d){let u=s;const m=I(e,"slot",null);if(m){const g=i.findSlot(m);if(!g)throw new Error(`Source mesh slot not found: ${m}`);u=g.index}return this.linkedMeshes.push(new rr(o,I(e,"skin",null),s,u,d,I(e,"timelines",!0))),o}const f=e.uvs;return this.readVertices(e,o,f.length),o.triangles=e.triangles,o.regionUVs=f,o.edges=I(e,"edges",null),o.hullLength=I(e,"hull",0)*2,o.updateSequence(),o}case"path":{const l=this.attachmentLoader.newPathAttachment(t,n,c);if(!l)return null;l.closed=I(e,"closed",!1),l.constantSpeed=I(e,"constantSpeed",!0);const a=e.vertexCount;this.readVertices(e,l,a<<1);const o=L.newArray(a/3,0);for(let d=0;d<e.lengths.length;d++)o[d]=e.lengths[d]*r;l.lengths=o;const h=I(e,"color",null);return h&&l.color.setFromString(h),l}case"point":{const l=this.attachmentLoader.newPointAttachment(t,n,c);if(!l)return null;l.x=I(e,"x",0)*r,l.y=I(e,"y",0)*r,l.rotation=I(e,"rotation",0);const a=I(e,"color",null);return a&&l.color.setFromString(a),l}case"clipping":{const l=this.attachmentLoader.newClippingAttachment(t,n,c);if(!l)return null;const a=I(e,"end",null);a&&(l.endSlot=i.findSlot(a)),l.convex=I(e,"convex",!1),l.inverse=I(e,"inverse",!1);const o=e.vertexCount;this.readVertices(e,l,o<<1);const h=I(e,"color",null);return h&&l.color.setFromString(h),l}}return null}readSequence(e){if(e==null)return new de(1,!1);const t=new de(I(e,"count",0),!0);return t.start=I(e,"start",1),t.digits=I(e,"digits",0),t.setupIndex=I(e,"setup",0),t}readVertices(e,t,s){const n=this.scale;t.worldVerticesLength=s;const i=e.vertices;if(s===i.length){const l=L.toFloatArray(i);if(n!==1)for(let a=0,o=i.length;a<o;a++)l[a]*=n;t.vertices=l;return}const r=[],c=[];for(let l=0,a=i.length;l<a;){const o=i[l++];c.push(o);for(let h=l+o*4;l<h;l+=4)c.push(i[l]),r.push(i[l+1]*n),r.push(i[l+2]*n),r.push(i[l+3])}t.bones=c,t.vertices=L.toFloatArray(r)}readAnimation(e,t,s){const n=this.scale,i=[];if(e.slots)for(const a in e.slots){const o=e.slots[a],h=s.findSlot(a);if(!h)throw new Error(`Slot not found: ${a}`);const d=h.index;for(const f in o){const u=o[f];if(!u)continue;const m=u.length;switch(f){case"attachment":{const g=new ee(m,d);for(let p=0;p<m;p++){const x=u[p];g.setFrame(p,I(x,"time",0),I(x,"name",null))}i.push(g);break}case"rgba":{const g=new xs(m,m<<2,d);let p=u[0],x=I(p,"time",0),b=$.fromString(p.color);for(let w=0,T=0;;w++){g.setFrame(w,x,b.r,b.g,b.b,b.a);const y=u[w+1];if(!y){g.shrink(T);break}const v=I(y,"time",0),S=$.fromString(y.color),C=p.curve;C&&(T=J(C,g,T,w,0,x,v,b.r,S.r,1),T=J(C,g,T,w,1,x,v,b.g,S.g,1),T=J(C,g,T,w,2,x,v,b.b,S.b,1),T=J(C,g,T,w,3,x,v,b.a,S.a,1)),x=v,b=S,p=y}i.push(g);break}case"rgb":{const g=new bs(m,m*3,d);let p=u[0],x=I(p,"time",0),b=$.fromString(p.color);for(let w=0,T=0;;w++){g.setFrame(w,x,b.r,b.g,b.b);const y=u[w+1];if(!y){g.shrink(T);break}const v=I(y,"time",0),S=$.fromString(y.color),C=p.curve;C&&(T=J(C,g,T,w,0,x,v,b.r,S.r,1),T=J(C,g,T,w,1,x,v,b.g,S.g,1),T=J(C,g,T,w,2,x,v,b.b,S.b,1)),x=v,b=S,p=y}i.push(g);break}case"alpha":{bt(i,u,new ws(m,m,d),0,1);break}case"rgba2":{const g=new ys(m,m*7,d);let p=u[0],x=I(p,"time",0),b=$.fromString(p.light),w=$.fromString(p.dark);for(let T=0,y=0;;T++){g.setFrame(T,x,b.r,b.g,b.b,b.a,w.r,w.g,w.b);const v=u[T+1];if(!v){g.shrink(y);break}const S=I(v,"time",0),C=$.fromString(v.light),A=$.fromString(v.dark),P=p.curve;P&&(y=J(P,g,y,T,0,x,S,b.r,C.r,1),y=J(P,g,y,T,1,x,S,b.g,C.g,1),y=J(P,g,y,T,2,x,S,b.b,C.b,1),y=J(P,g,y,T,3,x,S,b.a,C.a,1),y=J(P,g,y,T,4,x,S,w.r,A.r,1),y=J(P,g,y,T,5,x,S,w.g,A.g,1),y=J(P,g,y,T,6,x,S,w.b,A.b,1)),x=S,b=C,w=A,p=v}i.push(g);break}case"rgb2":{const g=new vs(m,m*6,d);let p=u[0],x=I(p,"time",0),b=$.fromString(p.light),w=$.fromString(p.dark);for(let T=0,y=0;;T++){g.setFrame(T,x,b.r,b.g,b.b,w.r,w.g,w.b);const v=u[T+1];if(!v){g.shrink(y);break}const S=I(v,"time",0),C=$.fromString(v.light),A=$.fromString(v.dark),P=p.curve;P&&(y=J(P,g,y,T,0,x,S,b.r,C.r,1),y=J(P,g,y,T,1,x,S,b.g,C.g,1),y=J(P,g,y,T,2,x,S,b.b,C.b,1),y=J(P,g,y,T,3,x,S,w.r,A.r,1),y=J(P,g,y,T,4,x,S,w.g,A.g,1),y=J(P,g,y,T,5,x,S,w.b,A.b,1)),x=S,b=C,w=A,p=v}i.push(g);break}default:throw new Error(`Invalid timeline type for a slot: ${u.name} (${o.name})`)}}}if(e.bones)for(const a in e.bones){const o=e.bones[a],h=s.findBone(a);if(!h)throw new Error(`Bone not found: ${a}`);const d=h.index;for(const f in o){const u=o[f],m=u.length;if(m!==0)switch(f){case"rotate":bt(i,u,new ue(m,m,d),0,1);break;case"translate":nn(i,u,new as(m,m<<1,d),"x","y",0,n);break;case"translatex":bt(i,u,new ls(m,m,d),0,n);break;case"translatey":bt(i,u,new cs(m,m,d),0,n);break;case"scale":nn(i,u,new hs(m,m<<1,d),"x","y",1,1);break;case"scalex":bt(i,u,new ds(m,m,d),1,1);break;case"scaley":bt(i,u,new fs(m,m,d),1,1);break;case"shear":nn(i,u,new us(m,m<<1,d),"x","y",0,1);break;case"shearx":bt(i,u,new ms(m,m,d),0,1);break;case"sheary":bt(i,u,new ps(m,m,d),0,1);break;case"inherit":{const g=new gs(m,h.index);for(let p=0;p<u.length;p++){const x=u[p];g.setFrame(p,I(x,"time",0),L.enumValue(et,I(x,"inherit","Normal")))}i.push(g);break}default:throw new Error(`Invalid timeline type for a bone: ${u.name} (${o.name})`)}}}if(e.ik)for(const a in e.ik){const o=e.ik[a];let h=o[0];if(!h)continue;const d=s.findConstraint(a,we);if(!d)throw new Error(`IK Constraint not found: ${a}`);const f=new Cs(o.length,o.length<<1,s.constraints.indexOf(d));let u=I(h,"time",0),m=I(h,"mix",1),g=I(h,"softness",0)*n;for(let p=0,x=0;;p++){f.setFrame(p,u,m,g,I(h,"bendPositive",!0)?1:-1,I(h,"compress",!1),I(h,"stretch",!1));const b=o[p+1];if(!b){f.shrink(x);break}const w=I(b,"time",0),T=I(b,"mix",1),y=I(b,"softness",0)*n,v=h.curve;v&&(x=J(v,f,x,p,0,u,w,m,T,1),x=J(v,f,x,p,1,u,w,g,y,n)),u=w,m=T,g=y,h=b}i.push(f)}if(e.transform)for(const a in e.transform){const o=e.transform[a];let h=o[0];if(!h)continue;const d=s.findConstraint(a,K);if(!d)throw new Error(`Transform constraint not found: ${a}`);const f=new As(o.length,o.length*6,s.constraints.indexOf(d));let u=I(h,"time",0),m=I(h,"mixRotate",1),g=I(h,"mixX",1),p=I(h,"mixY",g),x=I(h,"mixScaleX",1),b=I(h,"mixScaleY",1),w=I(h,"mixShearY",1);for(let T=0,y=0;;T++){f.setFrame(T,u,m,g,p,x,b,w);const v=o[T+1];if(!v){f.shrink(y);break}const S=I(v,"time",0),C=I(v,"mixRotate",1),A=I(v,"mixX",1),P=I(v,"mixY",A),k=I(v,"mixScaleX",1),F=I(v,"mixScaleY",1),R=I(v,"mixShearY",1),E=h.curve;E&&(y=J(E,f,y,T,0,u,S,m,C,1),y=J(E,f,y,T,1,u,S,g,A,1),y=J(E,f,y,T,2,u,S,p,P,1),y=J(E,f,y,T,3,u,S,x,k,1),y=J(E,f,y,T,4,u,S,b,F,1),y=J(E,f,y,T,5,u,S,w,R,1)),u=S,m=C,g=A,p=P,x=k,b=F,w=R,h=v}i.push(f)}if(e.path)for(const a in e.path){const o=e.path[a],h=s.findConstraint(a,ye);if(!h)throw new Error(`Path constraint not found: ${a}`);const d=s.constraints.indexOf(h);for(const f in o){const u=o[f];let m=u[0];if(!m)continue;const g=u.length;switch(f){case"position":{const p=new Ps(g,g,d);bt(i,u,p,0,h.positionMode===Tt.Fixed?n:1);break}case"spacing":{const p=new Is(g,g,d);bt(i,u,p,0,h.spacingMode===nt.Length||h.spacingMode===nt.Fixed?n:1);break}case"mix":{const p=new ks(g,g*3,d);let x=I(m,"time",0),b=I(m,"mixRotate",1),w=I(m,"mixX",1),T=I(m,"mixY",w);for(let y=0,v=0;;y++){p.setFrame(y,x,b,w,T);const S=u[y+1];if(!S){p.shrink(v);break}const C=I(S,"time",0),A=I(S,"mixRotate",1),P=I(S,"mixX",1),k=I(S,"mixY",P),F=m.curve;F&&(v=J(F,p,v,y,0,x,C,b,A,1),v=J(F,p,v,y,1,x,C,w,P,1),v=J(F,p,v,y,2,x,C,T,k,1)),x=C,b=A,w=P,T=k,m=S}i.push(p);break}}}}if(e.physics)for(const a in e.physics){const o=e.physics[a];let h=-1;if(a.length>0){const d=s.findConstraint(a,ve);if(!d)throw new Error(`Physics constraint not found: ${a}`);h=s.constraints.indexOf(d)}for(const d in o){const f=o[d];let u=f[0];if(!u)continue;const m=f.length;let g,p=0;if(d==="reset"){const x=new Ls(m,h);for(let b=0;u!=null;u=f[b+1],b++)x.setFrame(b,I(u,"time",0));i.push(x);continue}switch(d){case"inertia":g=new Ms(m,m,h);break;case"strength":g=new Fs(m,m,h);break;case"damping":g=new Ys(m,m,h);break;case"mass":g=new Rs(m,m,h);break;case"wind":g=new Es(m,m,h);break;case"gravity":g=new Bs(m,m,h);break;case"mix":{p=1,g=new Xs(m,m,h);break}default:continue}bt(i,f,g,p,1)}}if(e.slider)for(const a in e.slider){const o=e.slider[a],h=s.findConstraint(a,qt);if(!h)throw new Error(`Slider not found: ${a}`);const d=s.constraints.indexOf(h);for(const f in o){const u=o[f];if(!u[0])continue;const g=u.length;switch(f){case"time":bt(i,u,new Vs(g,g,d),1,1);break;case"mix":bt(i,u,new _s(g,g,d),1,1);break}}}if(e.attachments)for(const a in e.attachments){const o=e.attachments[a],h=s.findSkin(a);if(!h)throw new Error(`Skin not found: ${a}`);for(const d in o){const f=o[d],u=s.findSlot(d);if(!u)throw new Error(`Attachment slot not found: ${d}`);const m=u.index;for(const g in f){const p=f[g],x=h.getAttachment(m,g);if(!x)throw new Error(`Timeline attachment not found: ${g}`);for(const b in p){const w=p[b];let T=w[0];if(T){if(b==="deform"){const y=x.bones,v=x.vertices,S=y?v.length/3*2:v.length,C=new Ts(w.length,w.length,m,x);let A=I(T,"time",0);for(let P=0,k=0;;P++){let F;const R=I(T,"vertices",null);if(!R)F=y?L.newFloatArray(S):v;else{F=L.newFloatArray(S);const q=I(T,"offset",0);if(L.arrayCopy(R,0,F,q,R.length),n!==1)for(let _=q,Y=_+R.length;_<Y;_++)F[_]*=n;if(!y)for(let _=0;_<S;_++)F[_]+=v[_]}C.setFrame(P,A,F);const E=w[P+1];if(!E){C.shrink(k);break}const B=I(E,"time",0),O=T.curve;O&&(k=J(O,C,k,P,0,A,B,0,1,1)),A=B,T=E}i.push(C)}else if(b==="sequence"){const y=new Ss(w.length,m,x);let v=0;for(let S=0;S<w.length;S++){const C=I(T,"delay",v),A=I(T,"time",0),P=ot[I(T,"mode","hold")],k=I(T,"index",0);y.setFrame(S,A,P,k,C),v=C,T=w[S+1]}i.push(y)}}}}}}if(e.drawOrder){const a=new Wt(e.drawOrder.length),o=s.slots.length;let h=0;for(const d of e.drawOrder)a.setFrame(h++,I(d,"time",0),_n(s,d,o,null));i.push(a)}if(e.drawOrderFolder)for(const a of e.drawOrderFolder){const o=I(a,"slots",[]),h=new Array(o.length);let d=0;for(const g of o){const p=s.findSlot(g);if(!p)throw new Error(`Draw order folder slot not found: ${g}`);h[d++]=p.index}const f=I(a,"keys",[]),u=new pe(f.length,h,s.slots.length);let m=0;for(const g of f)u.setFrame(m++,I(g,"time",0),_n(s,g,h.length,h));i.push(u)}if(e.events){const a=new Me(e.events.length);let o=0;for(let h=0;h<e.events.length;h++,o++){const d=e.events[h],f=s.findEvent(d.name);if(!f)throw new Error(`Event not found: ${d.name}`);const u=f.setupPose,m=new Be(L.toSinglePrecision(I(d,"time",0)),f);m.intValue=I(d,"int",u.intValue),m.floatValue=I(d,"float",u.floatValue),m.stringValue=I(d,"string",u.stringValue),m.data.audioPath&&(m.volume=I(d,"volume",u.volume),m.balance=I(d,"balance",u.volume)),a.setFrame(o,m)}i.push(a)}let r=0;for(let a=0,o=i.length;a<o;a++)r=Math.max(r,i[a].getDuration());const c=new Ie(t,i,r),l=I(e,"color",null);l!==null&&c.color.setFromString(l),s.animations.push(c)}},rr=class{source;skin;slotIndex;sourceIndex;mesh;inheritTimelines;constructor(e,t,s,n,i,r){this.mesh=e,this.skin=t,this.slotIndex=s,this.sourceIndex=n,this.source=i,this.inheritTimelines=r}};function bt(e,t,s,n,i){let r=t[0],c=r.time??0,l=(r.value??n)*i,a=0;for(let o=0;;o++){s.setFrame(o,c,l);const h=t[o+1];if(!h){s.shrink(a),e.push(s);return}const d=h.time??0,f=(h.value??n)*i;r.curve&&(a=J(r.curve,s,a,o,0,c,d,l,f,i)),c=d,l=f,r=h}}function nn(e,t,s,n,i,r,c){let l=t[0],a=l.time??0,o=(l[n]??r)*c,h=(l[i]??r)*c,d=0;for(let f=0;;f++){s.setFrame(f,a,o,h);const u=t[f+1];if(!u){s.shrink(d),e.push(s);return}const m=u.time??0,g=(u[n]??r)*c,p=(u[i]??r)*c,x=l.curve;x&&(d=J(x,s,d,f,0,a,m,o,g,c),d=J(x,s,d,f,1,a,m,h,p,c)),a=m,o=g,h=p,l=u}}function _n(e,t,s,n){const i=t.offsets;if(!i)return null;const r=new Array(s).fill(-1),c=new Array(s-i.length);let l=0,a=0;for(const o of i){const h=e.findSlot(o.slot);if(h==null)throw new Error(`Draw order slot not found: ${o.slot}`);let d=0;if(!n)d=h.index;else{d=-1;for(let f=0;f<s;f++)if(n[f]===h.index){d=f;break}if(d===-1)throw new Error(`Slot not in folder: ${o.slot}`)}for(;l!==d;)c[a++]=l++;r[l+o.offset]=l++}for(;l<s;)c[a++]=l++;for(let o=s-1;o>=0;o--)r[o]===-1&&(r[o]=c[--a]);return r}function J(e,t,s,n,i,r,c,l,a,o){if(e==="stepped")return t.setStepped(n),s;const h=i<<2,d=e[h],f=e[h+1]*o,u=e[h+2],m=e[h+3]*o;return t.setBezier(s,n,i,r,l,d,f,u,m,c,a),s+1}function I(e,t,s){return e[t]!==void 0?e[t]:s}var or=class{commandPool=new ar;worldVertices=new Float32Array(12*1024);quadIndices=new Uint16Array([0,1,2,2,3,0]);clipping=new Se;renderCommands=[];render(e,t=!1,s,n=2){this.commandPool.reset(),this.renderCommands.length=0;const i=this.clipping,r=e.drawOrder.appliedPose;for(let c=0;c<e.slots.length;c++){const l=r[c],a=l.appliedPose.attachment;if(!a){i.clipEnd(l);continue}const o=l.appliedPose,h=o.color;if((h.a===0||!l.bone.active)&&!(a instanceof Bt)){i.clipEnd(l);continue}let f,u,m,g,p,x,b;if(a instanceof H){if(x=a.color,x.a===0){i.clipEnd(l);continue}const S=a.sequence,C=S.resolveIndex(o);a.computeWorldVertices(l,a.getOffsets(o),this.worldVertices,0,n),f=this.worldVertices,u=4,m=S.getUVs(C),g=this.quadIndices,p=6,b=S.regions[C]?.texture}else if(a instanceof pt){if(x=a.color,x.a===0){i.clipEnd(l);continue}this.worldVertices.length<a.worldVerticesLength&&(this.worldVertices=new Float32Array(a.worldVerticesLength)),a.computeWorldVertices(e,l,0,a.worldVerticesLength,this.worldVertices,0,n),f=this.worldVertices,u=a.worldVerticesLength>>1;const S=a.sequence,C=S.resolveIndex(o);m=S.getUVs(C),g=a.triangles,p=g.length,b=S.regions[C]?.texture}else if(a instanceof Bt){i.clipStart(e,l,a);continue}else continue;const w=e.color;let T,y;if(t){let S;if(s){S=Math.floor(s[3]*w.a*h.a*x.a*255);const C=Math.floor(S*s[0]*w.r*h.r*x.r),A=Math.floor(S*s[1]*w.g*h.g*x.g),P=Math.floor(S*s[2]*w.b*h.b*x.b);T=S<<24|C<<16|A<<8|P}else{S=Math.floor(w.a*h.a*x.a*255);const C=Math.floor(S*w.r*h.r*x.r),A=Math.floor(S*w.g*h.g*x.g),P=Math.floor(S*w.b*h.b*x.b);T=S<<24|C<<16|A<<8|P}if(y=4278190080,o.darkColor){const{r:C,g:A,b:P}=o.darkColor;y=4278190080|Math.floor(C*S)<<16|Math.floor(A*S)<<8|Math.floor(P*S)}}else{if(s){const S=Math.floor(s[3]*w.a*h.a*x.a*255),C=Math.floor(s[0]*w.r*h.r*x.r*255),A=Math.floor(s[1]*w.g*h.g*x.g*255),P=Math.floor(s[2]*w.b*h.b*x.b*255);T=S<<24|C<<16|A<<8|P}else{const S=Math.floor(w.a*h.a*x.a*255),C=Math.floor(w.r*h.r*x.r*255),A=Math.floor(w.g*h.g*x.g*255),P=Math.floor(w.b*h.b*x.b*255);T=S<<24|C<<16|A<<8|P}if(y=0,o.darkColor){const{r:S,g:C,b:A}=o.darkColor;y=Math.floor(S*255)<<16|Math.floor(C*255)<<8|Math.floor(A*255)}}i.isClipping()&&(i.clipTrianglesUnpacked(f,0,g,p,m,n),f=i.clippedVerticesTyped,u=i.clippedVerticesLength/n,m=i.clippedUVsTyped,g=i.clippedTrianglesTyped,p=i.clippedTrianglesLength);const v=this.commandPool.getCommand(u,p,n);v.blendMode=l.data.blendMode,v.texture=b,v.positions.set(f.subarray(0,u*n)),v.uvs.set(m.subarray(0,u<<1));for(let S=0;S<u;S++)v.colors[S]=T,v.darkColors[S]=y;g instanceof Uint16Array?v.indices.set(g.subarray(0,p)):v.indices.set(g.slice(0,p)),this.renderCommands.push(v),i.clipEnd(l)}return i.clipEnd(),this.batchCommands(n)}batchSubCommands(e,t,s,n,i,r){const c=e[t],l=this.commandPool.getCommand(n,i,r);l.blendMode=c.blendMode,l.texture=c.texture;let a=0,o=0,h=0,d=0,f=0;for(let u=t;u<=s;u++){const m=e[u];l.positions.set(m.positions,a),a+=m.numVertices*r,l.uvs.set(m.uvs,o),o+=m.numVertices<<1,l.colors.set(m.colors,h),l.darkColors.set(m.darkColors,h),h+=m.numVertices;for(let g=0;g<m.numIndices;g++)l.indices[d+g]=m.indices[g]+f;d+=m.numIndices,f+=m.numVertices}return l}batchCommands(e){if(this.renderCommands.length===0)return;let t,s,n=this.renderCommands[0],i=0,r=1,c=n.numVertices,l=n.numIndices;for(;r<=this.renderCommands.length;){const a=r<this.renderCommands.length?this.renderCommands[r]:null;if(a&&a.numVertices===0&&a.numIndices===0){r++;continue}if(a!==null&&a.texture===n.texture&&a.blendMode===n.blendMode&&a.colors[0]===n.colors[0]&&a.darkColors[0]===n.darkColors[0]&&l+a.numIndices<65535)c+=a.numVertices,l+=a.numIndices;else{const h=this.batchSubCommands(this.renderCommands,i,r-1,c,l,e);if(s?(s.next=h,s=h):t=s=h,r===this.renderCommands.length)break;n=this.renderCommands[r],i=r,c=n.numVertices,l=n.numIndices}r++}return t}},ar=class{pool=[];inUse=[];getCommand(e,t,s){let n;for(const i of this.pool)if(i._positions.length>=e*s&&i._indices.length>=t){n=i;break}if(n)this.pool.splice(this.pool.indexOf(n),1),n.next=void 0,n.numVertices=e,n.numIndices=t,n.positions=n._positions.subarray(0,e*s),n.uvs=n._uvs.subarray(0,e<<1),n.colors=n._colors.subarray(0,e),n.darkColors=n._darkColors.subarray(0,e),n.indices=n._indices.subarray(0,t);else{const i=new Float32Array(e*s),r=new Float32Array(e<<1),c=new Uint32Array(e),l=new Uint32Array(e),a=new Uint16Array(t);n={positions:i,uvs:r,colors:c,darkColors:l,indices:a,_positions:i,_uvs:r,_colors:c,_darkColors:l,_indices:a,numVertices:e,numIndices:t,blendMode:It.Normal,texture:null}}return this.inUse.push(n),n}reset(){this.pool.push(...this.inUse),this.inUse.length=0}},ht=Rt("pixi.js"),lr=Rt("pixi.js"),rn=class _t extends ns{static textureMap=new Map;static from(t){return _t.textureMap.has(t)?_t.textureMap.get(t):new _t(t)}texture;constructor(t){super(t.resource),this.texture=lr.Texture.from(t)}setFilters(t,s){const n=this.texture.source.style;n.minFilter=_t.toPixiTextureFilter(t),n.magFilter=_t.toPixiTextureFilter(s),this.texture.source.autoGenerateMipmaps=_t.toPixiMipMap(t),this.texture.source.updateMipmaps()}setWraps(t,s){const n=this.texture.source.style;n.addressModeU=_t.toPixiTextureWrap(t),n.addressModeV=_t.toPixiTextureWrap(s)}dispose(){this.texture.destroy()}static toPixiMipMap(t){switch(t){case it.Nearest:case it.Linear:return!1;case it.MipMapNearestLinear:case it.MipMapNearestNearest:case it.MipMapLinearLinear:case it.MipMapLinearNearest:return!0;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureFilter(t){switch(t){case it.Nearest:case it.MipMapNearestLinear:case it.MipMapNearestNearest:return"nearest";case it.Linear:case it.MipMapLinearLinear:case it.MipMapLinearNearest:return"linear";default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case Pt.ClampToEdge:return"clamp-to-edge";case Pt.MirroredRepeat:return"mirror-repeat";case Pt.Repeat:return"repeat";default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case It.Normal:return"normal";case It.Additive:return"add";case It.Multiply:return"multiply";case It.Screen:return"screen";default:throw new Error(`Unknown blendMode: ${String(t)}`)}}},oe="spineTextureAtlasLoader",cr={extension:ht.ExtensionType.Asset,resolver:{test:e=>(0,ht.checkExtension)(e,".atlas"),parse:e=>{const t=e.split(".");return{resolution:parseFloat(ht.Resolver.RETINA_PREFIX?.exec(e)?.[1]??"1"),format:t[t.length-2],src:e}}},loader:{id:oe,name:oe,extension:{type:ht.ExtensionType.LoadParser,priority:ht.LoaderParserPriority.Normal,name:oe},test(e){return(0,ht.checkExtension)(e,".atlas")},async load(e){const t=await ht.DOMAdapter.get().fetch(e);if(!t.ok)throw new Error(`[${oe}] Failed to fetch ${e}: ${t.status} ${t.statusText}`);return await t.text()},testParse(e,t){const s=(0,ht.checkExtension)(t.src,".atlas"),n=typeof e=="string",i=t.parser===oe||t.loadParser===oe;return Promise.resolve((s||i)&&n)},unload(e){e.dispose()},async parse(e,t,s){const n=t.data||{};let i=ht.path.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");const r=new Pe(e);if(n.images instanceof ht.TextureSource||typeof n.images=="string"){const l=n.images;n.images={},n.images[r.pages[0].name]=l}const c=[];for(const l of r.pages){const a=l.name,o=n?.images?n.images[a]:void 0;if(o instanceof ht.TextureSource)l.setTexture(rn.from(o));else{const h=o??ht.path.normalize([...i.split(ht.path.sep),a].join(ht.path.sep)),d={src:(0,ht.copySearchParams)(h,t.src),data:{...n.imageMetadata,alphaMode:l.pma?"premultiplied-alpha":"premultiply-alpha-on-upload"}},f=s.load(d).then(u=>{l.setTexture(rn.from(u.source))});c.push(f)}}return await Promise.all(c),r}}};ht.extensions.add(cr);var $t=Rt("pixi.js"),ae="spineSkeletonLoader";function hr(e){return Object.prototype.hasOwnProperty.call(e,"bones")}function dr(e){return e instanceof Uint8Array}var fr={extension:$t.ExtensionType.Asset,loader:{id:ae,name:ae,extension:{type:$t.ExtensionType.LoadParser,priority:$t.LoaderParserPriority.Normal,name:ae},test(e){return(0,$t.checkExtension)(e,".skel")},async load(e){const t=await $t.DOMAdapter.get().fetch(e);if(!t.ok)throw new Error(`[${ae}] Failed to fetch ${e}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())},testParse(e,t){const s=(0,$t.checkExtension)(t.src,".json")&&hr(e),n=(0,$t.checkExtension)(t.src,".skel")&&dr(e),i=t.parser===ae||t.loadParser===ae;return Promise.resolve(s||n||i)}}};$t.extensions.add(fr);var He=Rt("pixi.js"),jt=Rt("pixi.js"),ur=new Float32Array(1),mr=new Uint32Array(1),pr=class extends jt.Geometry{constructor(){const t=new jt.Buffer({data:ur,label:"attribute-batch-buffer",usage:jt.BufferUsage.VERTEX|jt.BufferUsage.COPY_DST,shrinkToFit:!1}),s=new jt.Buffer({data:mr,label:"index-batch-buffer",usage:jt.BufferUsage.INDEX|jt.BufferUsage.COPY_DST,shrinkToFit:!1}),n=7*4;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:n,offset:0},aUV:{buffer:t,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:t,format:"unorm8x4",stride:n,offset:4*4},aDarkColor:{buffer:t,format:"unorm8x4",stride:n,offset:5*4},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:n,offset:6*4}},indexBuffer:s})}},Ft=Rt("pixi.js"),gr={name:"color-bit",vertex:{header:`
            @in aDarkColor: vec4<f32>;
            @out vDarkColor: vec4<f32>;
        `,main:`
        vDarkColor = aDarkColor;
        `},fragment:{header:`
            @in vDarkColor: vec4<f32>;
        `,end:`

        let alpha = outColor.a * vColor.a;
        let rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;

        finalColor = vec4<f32>(rgb, alpha);

        `}},xr={name:"color-bit",vertex:{header:`
            in vec4 aDarkColor;
            out vec4 vDarkColor;
        `,main:`
            vDarkColor = aDarkColor;
        `},fragment:{header:`
            in vec4 vDarkColor;
        `,end:`

        finalColor.a = outColor.a * vColor.a;
        finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;
        `}},br=class extends Ft.Shader{constructor(e){const t=(0,Ft.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[Ft.colorBitGl,xr,(0,Ft.generateTextureBatchBitGl)(e),Ft.roundPixelsBitGl]}),s=(0,Ft.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[Ft.colorBit,gr,(0,Ft.generateTextureBatchBit)(e),Ft.roundPixelsBit]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:(0,Ft.getBatchSamplersUniformGroup)(e)}})}},On=null,wr=class ni extends He.Batcher{static extension={type:[He.ExtensionType.Batcher],name:"darkTint"};geometry=new pr;shader=On||(On=new br(this.maxTextures));name=ni.extension.name;vertexSize=7;packAttributes(t,s,n,i,r){const c=r<<16|t.roundPixels&65535,l=t.transform,a=l.a,o=l.b,h=l.c,d=l.d,f=l.tx,u=l.ty,{positions:m,uvs:g}=t,p=t.color,x=(p>>24&255)/255,b=He.Color.shared.setValue(t.darkColor).premultiply(x,!0).toPremultiplied(1,!1),w=t.attributeOffset,T=w+t.attributeSize;for(let y=w;y<T;y++){const v=y*2,S=m[v],C=m[v+1];s[i++]=a*S+h*C+f,s[i++]=d*C+o*S+u,s[i++]=g[v],s[i++]=g[v+1],n[i++]=p,n[i++]=b,n[i++]=c}}packQuadAttributes(t,s,n,i,r){const c=t.texture,l=t.transform,a=l.a,o=l.b,h=l.c,d=l.d,f=l.tx,u=l.ty,m=t.bounds,g=m.maxX,p=m.minX,x=m.maxY,b=m.minY,w=c.uvs,T=t.color,y=t.darkColor,v=r<<16|t.roundPixels&65535;s[i+0]=a*p+h*b+f,s[i+1]=d*b+o*p+u,s[i+2]=w.x0,s[i+3]=w.y0,n[i+4]=T,n[i+5]=y,n[i+6]=v,s[i+7]=a*g+h*b+f,s[i+8]=d*b+o*g+u,s[i+9]=w.x1,s[i+10]=w.y1,n[i+11]=T,n[i+12]=y,n[i+13]=v,s[i+14]=a*g+h*x+f,s[i+15]=d*x+o*g+u,s[i+16]=w.x2,s[i+17]=w.y2,n[i+18]=T,n[i+19]=y,n[i+20]=v,s[i+21]=a*p+h*x+f,s[i+22]=d*x+o*p+u,s[i+23]=w.x3,s[i+24]=w.y3,n[i+25]=T,n[i+26]=y,n[i+27]=v}};He.extensions.add(wr);var yr=L.newFloatArray(8),vr=class ts{static QUAD_TRIANGLES=[0,1,2,2,3,0];static VERTEX_SIZE=8;ctx;triangleRendering=!1;debugRendering=!1;vertices=L.newFloatArray(8*1024);tempColor=new $;constructor(t){this.ctx=t}draw(t){this.triangleRendering?this.drawTriangles(t):this.drawImages(t)}drawImages(t){const s=this.ctx,n=this.tempColor,i=t.color,r=t.drawOrder.appliedPose;this.debugRendering&&(s.strokeStyle="green");for(let c=0,l=r.length;c<l;c++){const a=r[c],o=a.bone;if(!o.active)continue;const h=a.appliedPose,d=h.attachment;if(!(d instanceof H))continue;const f=d.sequence,u=f.resolveIndex(h);d.computeWorldVertices(a,d.getOffsets(h),yr,0,2);const m=f.regions[u],g=m.texture.getImage(),p=h.color,x=d.color;n.set(i.r*p.r*x.r,i.g*p.g*x.g,i.b*p.b*x.b,i.a*p.a*x.a),s.save();const b=o.appliedPose;s.transform(b.a,b.c,b.b,b.d,b.worldX,b.worldY);const w=d.getOffsets(h);s.translate(w[0],w[1]),s.rotate(d.rotation*Math.PI/180);const T=d.width/m.originalWidth;s.scale(T*d.scaleX,T*d.scaleY);let y=m.width,v=m.height;if(s.translate(y/2,v/2),m.degrees===90){const S=y;y=v,v=S,s.rotate(-Math.PI/2)}s.scale(1,-1),s.translate(-y/2,-v/2),s.globalAlpha=n.a,s.drawImage(g,g.width*m.u,g.height*m.v,y,v,0,0,y,v),this.debugRendering&&s.strokeRect(0,0,y,v),s.restore()}}drawTriangles(t){const s=this.ctx,n=this.tempColor,i=t.color,r=t.drawOrder.appliedPose;let c=null,l=this.vertices,a=null;for(let o=0,h=r.length;o<h;o++){const d=r[o],f=d.appliedPose,u=f.attachment;let m;if(u instanceof H){const g=u.sequence,p=g.resolveIndex(f),x=g.getUVs(p),b=u.getOffsets(f);l=this.computeRegionVertices(d,u,b,x,!1),a=ts.QUAD_TRIANGLES,m=(g.regions[p]?.texture).getImage()}else if(u instanceof pt){const g=u.sequence,p=g.resolveIndex(f),x=g.getUVs(p);l=this.computeMeshVertices(d,u,x,!1),a=u.triangles,m=(g.regions[p]?.texture).getImage()}else continue;if(m){d.data.blendMode!==c&&(c=d.data.blendMode);const g=f.color,p=u.color;n.set(i.r*g.r*p.r,i.g*g.g*p.g,i.b*g.b*p.b,i.a*g.a*p.a),s.globalAlpha=n.a;for(let x=0;x<a.length;x+=3){const b=a[x]*8,w=a[x+1]*8,T=a[x+2]*8,y=l[b],v=l[b+1],S=l[b+6],C=l[b+7],A=l[w],P=l[w+1],k=l[w+6],F=l[w+7],R=l[T],E=l[T+1],B=l[T+6],O=l[T+7];this.drawTriangle(m,y,v,S,C,A,P,k,F,R,E,B,O),this.debugRendering&&(s.strokeStyle="green",s.beginPath(),s.moveTo(y,v),s.lineTo(A,P),s.lineTo(R,E),s.lineTo(y,v),s.stroke())}}}this.ctx.globalAlpha=1}drawTriangle(t,s,n,i,r,c,l,a,o,h,d,f,u){const m=this.ctx,g=t.width-1,p=t.height-1;i*=g,r*=p,a*=g,o*=p,f*=g,u*=p,m.beginPath(),m.moveTo(s,n),m.lineTo(c,l),m.lineTo(h,d),m.closePath(),c-=s,l-=n,h-=s,d-=n,a-=i,o-=r,f-=i,u-=r;let x=a*u-f*o;if(x===0)return;x=1/x;const b=(u*c-o*h)*x,w=(u*l-o*d)*x,T=(a*h-f*c)*x,y=(a*d-f*l)*x,v=s-b*i-T*r,S=n-w*i-y*r;m.save(),m.transform(b,w,T,y,v,S),m.clip(),m.drawImage(t,0,0),m.restore()}computeRegionVertices(t,s,n,i,r){const c=t.skeleton.color,l=t.appliedPose.color,a=s.color,o=c.a*l.a*a.a,h=r?o:1,d=this.tempColor;d.set(c.r*l.r*a.r*h,c.g*l.g*a.g*h,c.b*l.b*a.b*h,o),s.computeWorldVertices(t,n,this.vertices,0,ts.VERTEX_SIZE);const f=this.vertices;return f[H.C1R]=d.r,f[H.C1G]=d.g,f[H.C1B]=d.b,f[H.C1A]=d.a,f[H.U1]=i[0],f[H.V1]=i[1],f[H.C2R]=d.r,f[H.C2G]=d.g,f[H.C2B]=d.b,f[H.C2A]=d.a,f[H.U2]=i[2],f[H.V2]=i[3],f[H.C3R]=d.r,f[H.C3G]=d.g,f[H.C3B]=d.b,f[H.C3A]=d.a,f[H.U3]=i[4],f[H.V3]=i[5],f[H.C4R]=d.r,f[H.C4G]=d.g,f[H.C4B]=d.b,f[H.C4A]=d.a,f[H.U4]=i[6],f[H.V4]=i[7],f}computeMeshVertices(t,s,n,i){const r=t.skeleton,c=r.color,l=t.appliedPose.color,a=s.color,o=c.a*l.a*a.a,h=i?o:1,d=this.tempColor;d.set(c.r*l.r*a.r*h,c.g*l.g*a.g*h,c.b*l.b*a.b*h,o);const f=s.worldVerticesLength/2;let u=this.vertices;u.length<s.worldVerticesLength&&(this.vertices=u=L.newFloatArray(s.worldVerticesLength)),s.computeWorldVertices(r,t,0,s.worldVerticesLength,u,0,ts.VERTEX_SIZE);for(let m=0,g=0,p=2;m<f;m++)u[p++]=d.r,u[p++]=d.g,u[p++]=d.b,u[p++]=d.a,u[p++]=n[g++],u[p++]=n[g++],p+=2;return u}},Jt=Rt("pixi.js"),Tr=class{indexOffset=0;attributeOffset=0;indexSize;attributeSize;batcherName="darkTint";topology="triangle-list";packAsQuad=!1;renderable;positions;indices;uvs;roundPixels;data;blendMode;darkTint;texture;transform;_textureId;_attributeStart;_indexStart;_batcher;_batch;get color(){const e=this.data.color,t=this.renderable.groupColor,s=this.renderable.groupAlpha;let n;const i=e.a*s*255;if(t!==16777215){const r=t>>16&255,c=t>>8&255,l=t&255,a=e.r*l,o=e.g*c,h=e.b*r;n=i<<24|h<<16|o<<8|a}else n=i<<24|e.b*255<<16|e.g*255<<8|e.r*255;return n}get darkColor(){const e=this.data.darkColor;return e.b*255<<16|e.g*255<<8|e.r*255}get groupTransform(){return this.renderable.groupTransform}setData(e,t,s,n){if(this.renderable=e,this.transform=e.groupTransform,this.data=t,t.clipped){const i=t.clippedData;this.indexSize=i.indicesCount,this.attributeSize=i.vertexCount,this.positions=i.vertices,this.indices=i.indices,this.uvs=i.uvs}else this.indexSize=t.indices.length,this.attributeSize=t.vertices.length/2,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs;this.texture=t.texture,this.roundPixels=n,this.blendMode=s,this.batcherName=t.darkTint?"darkTint":"default"}},Sr={0:"normal",1:"add",2:"multiply",3:"screen"},Dn=class{static extension={type:[Jt.ExtensionType.WebGLPipes,Jt.ExtensionType.WebGPUPipes,Jt.ExtensionType.CanvasPipes],name:"spine"};renderer;canvasSkeletonRenderer;gpuSpineData={};_destroyRenderableBound=this.destroyRenderable.bind(this);constructor(e){this.renderer=e}validateRenderable(e){if(this.renderer.type===Jt.RendererType.CANVAS||(e._validateAndTransformAttachments(),e.spineAttachmentsDirty))return!0;if(e.spineTexturesDirty){const t=e.skeleton.drawOrder.appliedPose,s=this.gpuSpineData[e.uid];if(!s)return!1;for(let n=0,i=t.length;n<i;n++){const r=t[n],c=r.appliedPose.attachment;if(c instanceof H||c instanceof pt){const l=e._getCachedData(r,c),a=s.slotBatches[l.id],o=l.texture;if(o!==a?.texture&&!a?._batcher.checkAndUpdateTexture(a,o))return!0}}}return!1}execute(e){if(this.renderer.type===Jt.RendererType.CANVAS){const t=this.renderer,s=(e.groupColorAlpha>>>24&255)/255,n=t.canvasContext,i=n.activeContext;i.save(),this.canvasSkeletonRenderer||(this.canvasSkeletonRenderer=new vr(i),this.canvasSkeletonRenderer.triangleRendering=!0),n.setContextTransform(e.groupTransform,(t._roundPixels|e._roundPixels)===1);const r=e.skeleton.color.a;e.skeleton.color.a*=s,this.canvasSkeletonRenderer.draw(e.skeleton),e.skeleton.color.a=r,i.restore()}}addRenderable(e,t){if(this.renderer.type===Jt.RendererType.CANVAS){this.renderer.renderPipes.batch.break(t),t.add(e);return}const s=this._getSpineData(e),n=this.renderer.renderPipes.batch,i=e.skeleton.drawOrder.appliedPose,r=this.renderer._roundPixels|e._roundPixels;e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;for(let c=0,l=i.length;c<l;c++){const a=i[c],o=a.appliedPose.attachment,h=Sr[a.data.blendMode];let d=!1;if(o instanceof H||o instanceof pt){const u=e._getCachedData(a,o),m=s.slotBatches[u.id]||=new Tr;m.setData(e,u,h,r),d=u.skipRender,d||n.addToBatch(m,t)}const f=e._slotsObject[a.data.name];if(f){const u=f.container;u.includeInBuild=!0,u.collectRenderables(t,this.renderer,null),u.includeInBuild=!1}}}updateRenderable(e){const t=this.gpuSpineData[e.uid];if(!t)return;e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;const s=e.skeleton.drawOrder.appliedPose;for(let n=0,i=s.length;n<i;n++){const r=s[n],c=r.appliedPose.attachment;if(c instanceof H||c instanceof pt){const l=e._getCachedData(r,c);if(!l.skipRender){const a=t.slotBatches[l.id];a&&(a.uvs=l.clipped?l.clippedData.uvs:l.uvs,a._batcher?.updateElement(a))}}}}destroyRenderable(e){this.gpuSpineData[e.uid]=null,e.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null,this.canvasSkeletonRenderer=null}_getSpineData(e){return this.gpuSpineData[e.uid]||this._initMeshData(e)}_initMeshData(e){return this.gpuSpineData[e.uid]={slotBatches:{}},e.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[e.uid]}};Jt.extensions.add(Dn);var St=Rt("pixi.js"),je=new Ae;re.yDown=!0;var Lt=new Se,Cr=class{constructor(e,t,s,n){this.x=e,this.y=t,this.width=s,this.height=n}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},Ar=class{constructor(e=!1){this.clipping=e}calculateBounds(e){if(!e.skeleton)return{x:0,y:0,width:0,height:0};const t=new re(e.skeleton.data);t.setupPose(),t.updateWorldTransform(vt.update);const s=t.getBoundsRect(this.clipping?new Se:void 0);return s.width===Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},Pr=class{constructor(e,t=[],s=.05,n=!1){this.animation=e,this.skins=t,this.timeStep=s,this.clipping=n}calculateBounds(e){if(!e.skeleton||!e.state)return{x:0,y:0,width:0,height:0};const t=new Os(e.state.data),s=new re(e.skeleton.data),n=this.clipping?new Se:void 0,i=s.data;if(this.skins.length>0){const c=new Te("custom-skin");for(const l of this.skins){const a=i.findSkin(l);a!=null&&c.addSkin(a)}s.setSkin(c)}s.setupPose();const r=this.animation!=null?i.findAnimation(this.animation):null;if(r==null){s.updateWorldTransform(vt.update);const c=s.getBoundsRect(n);return c.width===Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:c}else{let c=Number.POSITIVE_INFINITY,l=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;t.clearTracks(),t.setAnimation(0,r,!1);const h=Math.max(r.duration/this.timeStep,1);for(let f=0;f<h;f++){const u=f>0?this.timeStep:0;t.update(u),t.apply(s),s.update(u),s.updateWorldTransform(vt.update);const m=s.getBoundsRect(n);c=Math.min(c,m.x),l=Math.min(l,m.y),a=Math.max(a,m.x+m.width),o=Math.max(o,m.y+m.height)}const d={x:c,y:l,width:a-c,height:o-l};return d.width===Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:d}}},Nn=new te(()=>new St.Graphics),Ir=class hn extends St.ViewContainer{batched=!0;buildId=0;renderPipeId="spine";_didSpineUpdate=!1;beforeUpdateWorldTransforms=()=>{};afterUpdateWorldTransforms=()=>{};skeleton;state;skeletonBounds;darkTint=!1;_debug=void 0;_slotsObject=Object.create(null);clippingSlotToPixiMasks=Object.create(null);getSlotFromRef(t){let s;if(typeof t=="number"?s=this.skeleton.slots[t]:typeof t=="string"?s=this.skeleton.findSlot(t):s=t,!s)throw new Error(`No slot found with the given slot reference: ${t}`);return s}spineAttachmentsDirty=!0;spineTexturesDirty=!0;_lastAttachments=[];_stateChanged=!0;attachmentCacheData=[];get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}_autoUpdate=!1;_ticker=St.Ticker.shared;get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t&&!this._autoUpdate?this._ticker.add(this.internalUpdate,this):!t&&this._autoUpdate&&this._ticker.remove(this.internalUpdate,this),this._autoUpdate=t}get ticker(){return this._ticker}set ticker(t){t=t??St.Ticker.shared,this._ticker!==t&&(this._autoUpdate&&(this._ticker.remove(this.internalUpdate,this),t.add(this.internalUpdate,this)),this._ticker=t)}_boundsProvider;get boundsProvider(){return this._boundsProvider}set boundsProvider(t){this._boundsProvider=t,t&&(this._boundsDirty=!1),this.updateBounds()}hasNeverUpdated=!0;_physicsPositionInheritanceFactorX=1;_physicsPositionInheritanceFactorY=1;_physicsRotationInheritanceFactor=1;hasLastPhysicsTransform=!1;lastPhysicsX=0;lastPhysicsY=0;lastPhysicsRotation=0;currentPhysicsPosition={x:0,y:0};lastPhysicsPosition={x:0,y:0};get physicsPositionInheritanceFactorX(){return this._physicsPositionInheritanceFactorX}get physicsPositionInheritanceFactorY(){return this._physicsPositionInheritanceFactorY}setPhysicsPositionInheritanceFactor(t,s){const n=this._physicsPositionInheritanceFactorX===0&&this._physicsPositionInheritanceFactorY===0,i=t!==0||s!==0;this._physicsPositionInheritanceFactorX=t,this._physicsPositionInheritanceFactorY=s,n&&i&&this.resetPhysicsPosition()}get physicsRotationInheritanceFactor(){return this._physicsRotationInheritanceFactor}set physicsRotationInheritanceFactor(t){const s=this._physicsRotationInheritanceFactor===0;this._physicsRotationInheritanceFactor=t,s&&t!==0&&this.resetPhysicsRotation()}constructor(t){super({}),t instanceof De?t={skeletonData:t}:"skeleton"in t&&(t=new.target.createOptions(t)),this.allowChildren=!0;const{autoUpdate:s,boundsProvider:n,darkTint:i,skeletonData:r,ticker:c}=t;this.skeleton=new re(r),this.state=new Os(new vn(r)),c&&(this._ticker=c),this.autoUpdate=s??!0,this._boundsProvider=n,this.darkTint=i===void 0?this.skeleton.slots.some(a=>!!a.data.setupPose.darkColor):i;const l=this.skeleton.slots;for(let a=0;a<l.length;a++)this.attachmentCacheData[a]=Object.create(null)}update(t){this.internalUpdate(void 0,t)}internalUpdate(t,s){this._updateAndApplyState(s??this._ticker.deltaMS/1e3)}resetPhysicsPosition(){const t=this.worldTransform;this.lastPhysicsX=t.tx,this.lastPhysicsY=t.ty,this.hasLastPhysicsTransform||(this.lastPhysicsRotation=this.getPhysicsRotation()),this.hasLastPhysicsTransform=!0}resetPhysicsRotation(){const t=this.worldTransform;this.lastPhysicsRotation=this.getPhysicsRotation(),this.hasLastPhysicsTransform||(this.lastPhysicsX=t.tx,this.lastPhysicsY=t.ty),this.hasLastPhysicsTransform=!0}resetPhysicsTransform(){this.resetPhysicsPosition(),this.resetPhysicsRotation()}applyTransformMovementToPhysics(){const{tx:t,ty:s}=this.worldTransform,n=this.getPhysicsRotation();this.hasLastPhysicsTransform&&(this.applyPositionMovementToPhysics(t,s),this.applyRotationMovementToPhysics(n)),this.setLastPhysicsTransform(t,s,n)}applyPositionMovementToPhysics(t,s){if(this._physicsPositionInheritanceFactorX===0&&this._physicsPositionInheritanceFactorY===0)return;const n=this.currentPhysicsPosition;n.x=t,n.y=s,this.pixiWorldCoordinatesToSkeleton(n);const i=this.lastPhysicsPosition;i.x=this.lastPhysicsX,i.y=this.lastPhysicsY,this.pixiWorldCoordinatesToSkeleton(i),this.skeleton.physicsTranslate((n.x-i.x)*this._physicsPositionInheritanceFactorX,(n.y-i.y)*this._physicsPositionInheritanceFactorY)}applyRotationMovementToPhysics(t){const s=this._physicsRotationInheritanceFactor;s!==0&&this.skeleton.physicsRotate(0,0,this.getRotationDelta(t,this.lastPhysicsRotation)*s)}setLastPhysicsTransform(t,s,n){this.lastPhysicsX=t,this.lastPhysicsY=s,this.lastPhysicsRotation=n,this.hasLastPhysicsTransform=!0}getPhysicsRotation(){const t=this.worldTransform;return Math.atan2(t.b,t.a)*180/Math.PI}getRotationDelta(t,s){let n=t-s;return n=(n+180)%360-180,n<-180?n+360:n}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,s){const n=t;if(typeof t=="string"&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(n)} not found`);je.set(s.x,s.y);const i=t.appliedPose;if(t.parent){const r=t.parent.appliedPose.worldToLocal(je);i.x=r.x,i.y=-r.y}else i.x=je.x,i.y=je.y}getBonePosition(t,s){const n=t;return typeof t=="string"&&(t=this.skeleton.findBone(t)),t?(s||(s={x:0,y:0}),s.x=t.appliedPose.worldX,s.y=t.appliedPose.worldY,s):(console.error(`Cant set bone position! Bone ${String(n)} not found`),s)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:s}=this;this.state.apply(s),this.applyTransformMovementToPhysics(),this.beforeUpdateWorldTransforms(this),s.updateWorldTransform(vt.update),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder.appliedPose,s=this._lastAttachments;let n=0,i=!1;for(let r=0;r<t.length;r++){const l=t[r].appliedPose.attachment;l&&(l!==s[n]&&(i=!0,s[n]=l),n++)}n!==s.length&&(i=!0,s.length=n),this.spineAttachmentsDirty||=i}currentClippingSlot;updateAndSetPixiMask(t,s){const i=t.appliedPose.attachment;if(i&&i instanceof Bt){const l=this.clippingSlotToPixiMasks[t.data.name]||={slot:t,vertices:[]};l.maskComputed=!1,this.currentClippingSlot=this.clippingSlotToPixiMasks[t.data.name];return}const r=this.currentClippingSlot,c=this._slotsObject[t.data.name];if(r&&c){const l=r.slot,a=l.pose.attachment;let o=r.mask;if(o||(o=Nn.obtain(),r.mask=o,this.addChild(o)),!r.maskComputed){r.maskComputed=!0;const h=a.worldVerticesLength,d=r.vertices;a.computeWorldVertices(this.skeleton,l,0,h,d,0,2),o.clear().poly(d).stroke({width:0}).fill({alpha:.25})}c.container.mask=o}else c?.container.mask&&(c.container.mask=null);if(r&&r.slot.appliedPose.attachment.endSlot===t.data&&(this.currentClippingSlot=void 0),s){for(const l in this.clippingSlotToPixiMasks){const a=this.clippingSlotToPixiMasks[l];(!(a.slot.appliedPose.attachment instanceof Bt)||!a.maskComputed)&&a.mask&&(this.removeChild(a.mask),Nn.free(a.mask),a.mask=void 0)}this.currentClippingSlot=void 0}}transformAttachments(){const t=this.skeleton.drawOrder.appliedPose,s=this.skeleton;for(let n=0;n<t.length;n++){const i=t[n];this.updateAndSetPixiMask(i,n===t.length-1);const r=i.appliedPose,c=r.attachment;if(c){if(c instanceof pt||c instanceof H){const l=this._getCachedData(i,c),a=c.sequence,o=a.resolveIndex(r);c instanceof H?c.computeWorldVertices(i,c.getOffsets(r),l.vertices,0,2):c.computeWorldVertices(s,i,0,c.worldVerticesLength,l.vertices,0,2),l.uvs=a.getUVs(o);const h=s.color,d=r.color,f=c.color,u=h.a*d.a*f.a;if(this.alpha===0||u===0)l.skipRender||(this.spineAttachmentsDirty=!0),l.skipRender=!0;else{l.skipRender&&(this.spineAttachmentsDirty=!0),l.skipRender=l.clipped=!1,l.color.set(h.r*d.r*f.r,h.g*d.g*f.g,h.b*d.b*f.b,u),r.darkColor&&l.darkColor.setFromColor(r.darkColor);const m=a.regions[o]?.texture?.texture||St.Texture.EMPTY;l.texture!==m&&(l.texture=m,this.spineTexturesDirty=!0),Lt.isClipping()&&this.updateClippingData(l)}}else if(c instanceof Bt){Lt.clipEnd(i),Lt.clipStart(s,i,c);continue}}Lt.clipEnd(i)}Lt.clipEnd()}updateClippingData(t){t.clipped=!0,Lt.clipTrianglesUnpacked(t.vertices,0,t.indices,t.indices.length,t.uvs);const{clippedVerticesTyped:s,clippedUVsTyped:n,clippedTrianglesTyped:i}=Lt,r=Lt.clippedVerticesLength/2,c=Lt.clippedTrianglesLength;t.clippedData||(t.clippedData={vertices:new Float32Array(r*2),uvs:new Float32Array(r*2),vertexCount:r,indices:new Uint16Array(c),indicesCount:c},this.spineAttachmentsDirty=!0);const l=t.clippedData,a=l.vertexCount!==r||c!==l.indicesCount;t.skipRender=r===0,a&&(this.spineAttachmentsDirty=!0,l.vertexCount<r&&(l.vertices=new Float32Array(r*2),l.uvs=new Float32Array(r*2)),l.indices.length<c&&(l.indices=new Uint16Array(c)));const{vertices:o,uvs:h,indices:d}=l;o.set(s),h.set(n);for(let f=0;f<c;f++){const u=i[f];d[f]!==u&&(this.spineAttachmentsDirty=!0),d[f]=u}l.vertexCount=r,l.indicesCount=c}updateSlotObjects(){for(const t in this._slotsObject){const s=this._slotsObject[t];s&&this.updateSlotObject(s)}}updateSlotObject(t){const{slot:s,container:n}=t,i=s.appliedPose,r=t.followAttachmentTimeline?!!i.attachment:!0,c=this.skeleton.color.a*i.color.a;if(n.visible=this.skeleton.drawOrder.appliedPose.includes(s)&&r&&this.alpha>0&&c>0,n.visible){const l=s.bone.appliedPose,a=n.localTransform;a.a=l.a,a.b=l.c,a.c=-l.b,a.d=-l.d,a.tx=l.worldX,a.ty=l.worldY,n.setFromMatrix(a),n.alpha=c,t.followSlotColor&&(n.tint=255*this.skeleton.color.r*i.color.r<<16|255*this.skeleton.color.g*i.color.g<<8|255*this.skeleton.color.b*i.color.b)}}_getCachedData(t,s){return this.attachmentCacheData[t.data.index][s.name]||this.initCachedData(t,s)}initCachedData(t,s){let n;if(s instanceof H){n=new Float32Array(8);const i=s.sequence;this.attachmentCacheData[t.data.index][s.name]={id:`${t.data.index}-${s.name}`,vertices:n,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(i.getUVs(0).length),color:new $(1,1,1,1),darkColor:new $(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:i.regions[0]?.texture?.texture}}else{n=new Float32Array(s.worldVerticesLength);const i=s.sequence;this.attachmentCacheData[t.data.index][s.name]={id:`${t.data.index}-${s.name}`,vertices:n,clipped:!1,indices:s.triangles,uvs:new Float32Array(i.getUVs(0).length),color:new $(1,1,1,1),darkColor:new $(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:i.regions[0]?.texture?.texture}}return this.attachmentCacheData[t.data.index][s.name]}onViewUpdate(){if(this._didViewChangeTick++,this._boundsProvider||(this._boundsDirty=!0),this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this),this.debug?.renderDebug(this)}addSlotObject(t,s,n){t=this.getSlotFromRef(t);for(const r in this._slotsObject)this._slotsObject[r]?.container===s&&this.removeSlotObject(this._slotsObject[r].slot);this.removeSlotObject(t),s.includeInBuild=!1,this.addChild(s);const i={container:s,slot:t,followAttachmentTimeline:n?.followAttachmentTimeline||!1,followSlotColor:n?.followSlotColor||!1};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){let s;if(t instanceof St.Container){for(const n in this._slotsObject)if(this._slotsObject[n]?.container===t){this._slotsObject[n]=null,s=t;break}}else{const n=this.getSlotFromRef(t);s=this._slotsObject[n.data.name]?.container,this._slotsObject[n.data.name]=null}s&&(this.removeChild(s),s.includeInBuild=!0)}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([t,s])=>{s&&s.container.removeFromParent(),delete this._slotsObject[t]})}getSlotObject(t){return t=this.getSlotFromRef(t),this._slotsObject[t.data.name]?.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||=new sn;const t=this.skeletonBounds;if(t.update(this.skeleton,!0),this._boundsProvider){const s=this._boundsProvider.calculateBounds(this),n=this._bounds;n.clear(),n.x=s.x,n.y=s.y,n.width=s.width,n.height=s.height}else if(t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const s=this.skeleton.drawOrder.appliedPose,n=this._bounds;n.clear();for(let i=0;i<s.length;i++){const r=s[i],c=r.appliedPose.attachment;if(c&&(c instanceof H||c instanceof pt)){const l=this._getCachedData(r,c);n.addVertexData(l.vertices,0,l.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),this._ticker.remove(this.internalUpdate,this),this._ticker=null,this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this.attachmentCacheData=null,this._lastAttachments.length=0}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,s){this.pixiWorldCoordinatesToSkeleton(t),s.parent?s.parent.appliedPose.worldToLocal(t):s.appliedPose.worldToLocal(t)}static createOptions({skeleton:t,atlas:s,scale:n=1,darkTint:i,autoUpdate:r=!0,boundsProvider:c,allowMissingRegions:l=!1,ticker:a}){const o=`${t}-${s}-${n}`;if(St.Cache.has(o))return{skeletonData:St.Cache.get(o),darkTint:i,autoUpdate:r,boundsProvider:c,ticker:a};const h=St.Assets.get(s),d=new An(h,l),f=St.Assets.get(t),u=f instanceof Uint8Array?new Rn(d):new Vn(d);u.scale=n;const m=u.readSkeletonData(f);return St.Cache.set(o,m),{skeletonData:m,darkTint:i,autoUpdate:r,boundsProvider:c,ticker:a}}static from(t){return new hn(hn.createOptions(t))}},ut=Rt("pixi.js"),kr=class{registeredSpines=new Map;drawMeshHull=!0;drawMeshTriangles=!0;drawBones=!0;drawPaths=!0;drawBoundingBoxes=!0;drawClipping=!0;drawRegionAttachments=!0;drawEvents=!0;lineWidth=1;regionAttachmentsColor=30975;meshHullColor=30975;meshTrianglesColor=16763904;clippingPolygonColor=16711935;boundingBoxesRectColor=65280;boundingBoxesPolygonColor=65280;boundingBoxesCircleColor=65280;pathsCurveColor=16711680;pathsLineColor=16711935;skeletonXYColor=16711680;bonesColor=61132;eventFontSize=24;eventFontColor=0;registerSpine(e){if(this.registeredSpines.has(e)){console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",e);return}const t={parentDebugContainer:new ut.Container,bones:new ut.Container,skeletonXY:new ut.Graphics,regionAttachmentsShape:new ut.Graphics,meshTrianglesLine:new ut.Graphics,meshHullLine:new ut.Graphics,clippingPolygon:new ut.Graphics,boundingBoxesRect:new ut.Graphics,boundingBoxesCircle:new ut.Graphics,boundingBoxesPolygon:new ut.Graphics,pathsCurve:new ut.Graphics,pathsLine:new ut.Graphics,eventText:new ut.Container,eventCallback:{event:(s,n)=>{if(this.drawEvents){const i=Math.abs(e.scale.x||e.scale.y||1),r=new ut.Text({text:n.data.name,style:{fontSize:this.eventFontSize/i,fill:this.eventFontColor,fontFamily:"monospace"}});r.scale.x=Math.sign(e.scale.x),r.anchor.set(.5),t.eventText.addChild(r),setTimeout(()=>{r.destroyed||r.destroy()},250)}}}};t.parentDebugContainer.addChild(t.bones),t.parentDebugContainer.addChild(t.skeletonXY),t.parentDebugContainer.addChild(t.regionAttachmentsShape),t.parentDebugContainer.addChild(t.meshTrianglesLine),t.parentDebugContainer.addChild(t.meshHullLine),t.parentDebugContainer.addChild(t.clippingPolygon),t.parentDebugContainer.addChild(t.boundingBoxesRect),t.parentDebugContainer.addChild(t.boundingBoxesCircle),t.parentDebugContainer.addChild(t.boundingBoxesPolygon),t.parentDebugContainer.addChild(t.pathsCurve),t.parentDebugContainer.addChild(t.pathsLine),t.parentDebugContainer.addChild(t.eventText),t.parentDebugContainer.zIndex=9999999,t.parentDebugContainer.accessibleChildren=!1,t.parentDebugContainer.eventMode="none",t.parentDebugContainer.interactiveChildren=!1,e.addChild(t.parentDebugContainer),e.state.addListener(t.eventCallback),this.registeredSpines.set(e,t)}renderDebug(e){this.registeredSpines.has(e)||this.registerSpine(e);const t=this.registeredSpines.get(e);if(!t)return;e.addChild(t.parentDebugContainer),t.skeletonXY.clear(),t.regionAttachmentsShape.clear(),t.meshTrianglesLine.clear(),t.meshHullLine.clear(),t.clippingPolygon.clear(),t.boundingBoxesRect.clear(),t.boundingBoxesCircle.clear(),t.boundingBoxesPolygon.clear(),t.pathsCurve.clear(),t.pathsLine.clear();for(let i=t.bones.children.length;i>0;i--)t.bones.children[i-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(e.scale.x||e.scale.y||1),n=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(e,t,n,s),this.drawPaths&&this.drawPathsFunc(e,t,n),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(e,t,n),this.drawClipping&&this.drawClippingFunc(e,t,n),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(e,t,n),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(e,t,n),this.drawEvents)for(const i of t.eventText.children)i.alpha-=.05,i.y-=2}drawBonesFunc(e,t,s,n){const i=e.skeleton,r=i.x,c=i.y,l=i.bones;t.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let o=0,h=l.length;o<h;o++){const d=l[o],f=d.data.length,u=d.appliedPose,m=r+u.worldX,g=c+u.worldY,p=r+f*u.a+u.worldX,x=c+f*u.b+u.worldY;if(d.data.name==="root"||d.data.parent===null)continue;const b=Math.abs(m-p),w=Math.abs(g-x),T=Math.pow(b,2),y=w,v=Math.pow(w,2),S=Math.sqrt(T+v),C=Math.pow(S,2),A=Math.PI/180,P=Math.acos((C+v-T)/(2*y*S))||0;if(S===0)continue;const k=new ut.Graphics;t.bones.addChild(k);const F=S/50/n;k.context.poly([0,0,0-F,S-F*3,0,S-F,0+F,S-F*3]).fill(this.bonesColor),k.x=m,k.y=g,k.pivot.y=S;let R=0;m<p&&g<x?R=-P+180*A:m>p&&g<x?R=180*A+P:m>p&&g>x?R=-P:m<p&&g>x?R=P:g===x&&m<p?R=90*A:g===x&&m>p?R=-90*A:m===p&&g<x?R=180*A:m===p&&g>x&&(R=0),k.rotation=R,k.circle(0,S,F*1.2).fill({color:0,alpha:.6}).stroke({width:s+F/2.4,color:this.bonesColor})}const a=s*3;t.skeletonXY.context.moveTo(r-a,c-a).lineTo(r+a,c+a).moveTo(r+a,c-a).lineTo(r-a,c+a).stroke()}drawRegionAttachmentsFunc(e,t,s){const i=e.skeleton.slots;for(let r=0,c=i.length;r<c;r++){const l=i[r],a=l.appliedPose.attachment;if(a===null||!(a instanceof H))continue;const o=new Float32Array(8);a.computeWorldVertices(l,a.getOffsets(l.appliedPose),o,0,2),t.regionAttachmentsShape.poly(Array.from(o.slice(0,8)))}t.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(e,t,s){const n=e.skeleton,i=n.slots;for(let r=0,c=i.length;r<c;r++){const l=i[r];if(!l.bone.active)continue;const a=l.appliedPose.attachment;if(a===null||!(a instanceof pt))continue;const o=a,h=new Float32Array(o.worldVerticesLength),d=o.triangles;let f=o.hullLength;if(o.computeWorldVertices(n,l,0,o.worldVerticesLength,h,0,2),this.drawMeshTriangles)for(let u=0,m=d.length;u<m;u+=3){const g=d[u]*2,p=d[u+1]*2,x=d[u+2]*2;t.meshTrianglesLine.context.moveTo(h[g],h[g+1]).lineTo(h[p],h[p+1]).lineTo(h[x],h[x+1])}if(this.drawMeshHull&&f>0){f=(f>>1)*2;let u=h[f-2],m=h[f-1];for(let g=0,p=f;g<p;g+=2){const x=h[g],b=h[g+1];t.meshHullLine.context.moveTo(x,b).lineTo(u,m),u=x,m=b}}}t.meshHullLine.stroke({width:s,color:this.meshHullColor}),t.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(e,t,s){const n=e.skeleton,i=n.slots;for(let r=0,c=i.length;r<c;r++){const l=i[r];if(!l.bone.active)continue;const a=l.appliedPose.attachment;if(a===null||!(a instanceof Bt))continue;const o=a,h=o.worldVerticesLength,d=new Float32Array(h);o.computeWorldVertices(n,l,0,h,d,0,2),t.clippingPolygon.poly(Array.from(d))}t.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(e,t,s){const n=new sn;n.update(e.skeleton,!0),n.minX!==1/0&&t.boundingBoxesRect.rect(n.minX,n.minY,n.getWidth(),n.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const i=n.polygons,r=(c,l,a)=>{if(a<3)throw new Error("Polygon must contain at least 3 vertices");const o=[],h=s*2;for(let d=0,f=c.length;d<f;d+=2){const u=c[d],m=c[d+1];t.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),t.boundingBoxesCircle.drawCircle(u,m,h),t.boundingBoxesCircle.fill(0),t.boundingBoxesCircle.circle(u,m,h).fill({color:this.boundingBoxesCircleColor}),o.push(u,m)}t.boundingBoxesPolygon.poly(o).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let c=0,l=i.length;c<l;c++){const a=i[c];r(a,0,a.length)}}drawPathsFunc(e,t,s){const n=e.skeleton,i=n.slots;for(let r=0,c=i.length;r<c;r++){const l=i[r];if(!l.bone.active)continue;const a=l.appliedPose.attachment;if(a===null||!(a instanceof be))continue;const o=a;let h=o.worldVerticesLength;const d=new Float32Array(h);o.computeWorldVertices(n,l,0,h,d,0,2);let f=d[2],u=d[3],m=0,g=0;if(o.closed){const p=d[0],x=d[1],b=d[h-2],w=d[h-1];m=d[h-4],g=d[h-3],t.pathsCurve.moveTo(f,u),t.pathsCurve.bezierCurveTo(p,x,b,w,m,g),t.pathsLine.moveTo(f,u),t.pathsLine.lineTo(p,x),t.pathsLine.moveTo(m,g),t.pathsLine.lineTo(b,w)}h-=4;for(let p=4;p<h;p+=6){const x=d[p],b=d[p+1],w=d[p+2],T=d[p+3];m=d[p+4],g=d[p+5],t.pathsCurve.moveTo(f,u),t.pathsCurve.bezierCurveTo(x,b,w,T,m,g),t.pathsLine.moveTo(f,u),t.pathsLine.lineTo(x,b),t.pathsLine.moveTo(m,g),t.pathsLine.lineTo(w,T),f=m,u=g}}t.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),t.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(e){this.registeredSpines.has(e)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",e);const t=this.registeredSpines.get(e);t&&(e.state.removeListener(t.eventCallback),t.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(e))}};return ci(dn)})();