"use strict";if(typeof window<"u"&&window.PIXI){const e=window.require;window.require=t=>{if(e)return e(t);if(t.startsWith("@pixi/"))return window.PIXI}}var vi=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}},on=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;s1&&(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 Yt){return s.setFromString(t)}},L=class ht{static epsilon=1e-5;static epsilon2=ht.epsilon*ht.epsilon;static PI=3.1415927;static PI2=ht.PI*2;static invPI2=1/ht.PI2;static radiansToDegrees=180/ht.PI;static radDeg=ht.radiansToDegrees;static degreesToRadians=ht.PI/180;static degRad=ht.degreesToRadians;static clamp(t,s,n){return tn?n:t}static cosDeg(t){return Math.cos(t*ht.degRad)}static sinDeg(t){return Math.sin(t*ht.degRad)}static atan2Deg(t,s){return Math.atan2(t,s)*ht.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 ht.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}},qt=class _t{static linear=new class extends _t{applyInternal(t){return t}};static smooth=new class extends _t{applyInternal(t){return t*t*(3-2*t)}};static slowFast=new class extends _t{applyInternal(t){return t*t}};static fastSlow=new class extends _t{applyInternal(t){return(t-1)*(t-1)*-1+1}};static circle=new class extends _t{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)}},an=class extends qt{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}},Ti=class extends an{constructor(e){super(e)}applyInternal(e){return Math.pow(e-1,this.power)*(this.power%2===0?-1:1)+1}},V=class Ut{static SUPPORTS_TYPED_ARRAYS=typeof Float32Array<"u";static arrayCopy(t,s,n,i,r){for(let a=s,c=i;a=s?t:Ut.setArraySize(t,s,n)}static newArray(t,s){const n=[];for(let i=0;i0?this.items.pop():this.instantiator()}free(e){e.reset?.(),this.items.push(e)}freeAll(e){for(let t=0;tthis.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)}},Ai=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.addedValuesthis.values.length-1&&(this.lastValue=0),this.dirty=!0}getMean(){if(this.hasEnoughData()){if(this.dirty){let e=0;for(let t=0;t(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",e))(ce||{}),ln=(e=>(e[e.MirroredRepeat=33648]="MirroredRepeat",e[e.ClampToEdge=33071]="ClampToEdge",e[e.Repeat=10497]="Repeat",e))(ln||{}),cn=class{texture;u=0;v=0;u2=0;v2=0;width=0;height=0;degrees=0;offsetX=0;offsetY=0;originalWidth=0;originalHeight=0},Ii=class extends _e{setFilters(e,t){}setWraps(e,t){}dispose(){}},he=class{pages=[];regions=[];constructor(e){const t=new ki(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=V.enumValue(ce,s[1]),o.magFilter=V.enumValue(ce,s[2])},n.repeat=o=>{s[1].indexOf("x")!==-1&&(o.uWrap=10497),s[1].indexOf("y")!==-1&&(o.vWrap=10497)},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 a=null,c=null,l=null;for(;r!==null;)if(r.trim().length===0)a=null,r=t.readLine();else if(a){const o=new Ue(a,r);for(;;){const h=t.readEntry(s,r=t.readLine());if(h===0)break;const d=i[s[0]];if(d)d(o);else{c||(c=[]),l||(l=[]),c.push(s[0]);const m=[];for(let f=0;f0&&l&&l.length>0&&(o.names=c,o.values=l,c=null,l=null),o.u=o.x/a.width,o.v=o.y/a.height,o.degrees===90?(o.u2=(o.x+o.height)/a.width,o.v2=(o.y+o.width)/a.height):(o.u2=(o.x+o.width)/a.width,o.v2=(o.y+o.height)/a.height),this.regions.push(o)}else{for(a=new hn(r.trim());t.readEntry(s,r=t.readLine())!==0;){const o=n[s[0]];o&&o(a)}this.pages.push(a)}}findRegion(e){for(let t=0;t=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}}},hn=class{name;minFilter=9728;magFilter=9728;uWrap=33071;vWrap=33071;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}},Ue=class extends cn{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)}},$e=class ai{static empty=[];name;timelineAttachment;timelineSlots=ai.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,a=this.timelineSlots.length;r>1)*c;const l=s.appliedPose.deform;let o=this.vertices;const h=this.bones;if(!h){l.length>0&&(o=l);const u=s.bone.appliedPose,p=u.worldX,g=u.worldY,x=u.a,b=u.b,w=u.c,v=u.d;for(let y=n,T=a;T=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 Ne._nextID++}},qe=(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",e))(qe||{}),ze=[0,1,2,3,4,5,6],de=class{name;timelines=[];timelineIds;bones;color=new z(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 on,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;i0&&(t%=this.duration));const h=this.timelines;for(let d=0,m=h.length;d(e[e.current=0]="current",e[e.setup=1]="setup",e[e.first=2]="first",e))(dn||{}),un=(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.drawOrderFolder=15]="drawOrderFolder",e[e.ikConstraint=16]="ikConstraint",e[e.transformConstraint=17]="transformConstraint",e[e.pathConstraintPosition=18]="pathConstraintPosition",e[e.pathConstraintSpacing=19]="pathConstraintSpacing",e[e.pathConstraintMix=20]="pathConstraintMix",e[e.physicsConstraintInertia=21]="physicsConstraintInertia",e[e.physicsConstraintStrength=22]="physicsConstraintStrength",e[e.physicsConstraintDamping=23]="physicsConstraintDamping",e[e.physicsConstraintMass=24]="physicsConstraintMass",e[e.physicsConstraintWind=25]="physicsConstraintWind",e[e.physicsConstraintGravity=26]="physicsConstraintGravity",e[e.physicsConstraintMix=27]="physicsConstraintMix",e[e.physicsConstraintReset=28]="physicsConstraintReset",e[e.sequence=29]="sequence",e[e.sliderTime=30]="sliderTime",e[e.sliderMix=31]="sliderMix",e))(un||{}),Q=class{propertyIds;frames;additive=!1;instant=!1;constructor(e,...t){this.propertyIds=t,this.frames=V.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;it)return i-s;return n-s}};function fn(e){return typeof e=="object"&&e!==null&&typeof e.slotIndex=="number"}var Ct=class extends Q{curves;constructor(e,t,...s){super(e,...s),this.curves=V.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=V.newFloatArray(t);V.arrayCopy(this.curves,0,s,0,t),this.curves=s}}setBezier(e,t,s,n,i,r,a,c,l,o,h){const d=this.curves;let m=this.getFrameCount()+e*18;s===0&&(d[t]=2+m);const f=(n-r*2+c)*.03,u=(i-a*2+l)*.03,p=((r-c)*3-n+o)*.006,g=((a-l)*3-i+h)*.006;let x=f*2+p,b=u*2+g,w=(r-n)*.3+f+p*.16666667,v=(a-i)*.3+u+g*.16666667,y=n+w,T=i+v;for(let C=m+18;me){const l=this.frames[t],o=this.frames[t+s];return o+(e-l)/(i[n]-l)*(i[n+1]-o)}const r=n+18;for(n+=2;n=e){const l=i[n-2],o=i[n-1];return o+(e-l)/(i[n]-l)*(i[n+1]-o)}t+=this.getFrameEntries();const a=i[r-2],c=i[r-1];return c+(e-a)/(this.frames[t]-a)*(this.frames[t+s]-c)}},Gt=class oe extends Ct{constructor(t,s,n){super(t,s,n)}getFrameEntries(){return 2}setFrame(t,s,n){t<<=1,this.frames[t]=s,this.frames[t+1]=n}getCurveValue(t){const s=this.frames;let n=s.length-2;for(let r=2;r<=n;r+=2)if(s[r]>t){n=r-2;break}const i=this.curves[n>>1];switch(i){case 0:{const r=s[n],a=s[n+1];return a+(t-r)/(s[n+2]-r)*(s[n+2+1]-a)}case 1:return s[n+1]}return this.getBezierValue(t,n,1,i-2)}getRelativeValue(t,s,n,i,r,a){if(t>2];switch(m){case 0:{const f=h[d];c=h[d+1],l=h[d+2],o=h[d+3];const u=(s-f)/(h[d+4]-f);c+=(h[d+4+1]-c)*u,l+=(h[d+4+2]-l)*u,o+=(h[d+4+3]-o)*u;break}case 1:c=h[d+1],l=h[d+2],o=h[d+3];break;default:c=this.getBezierValue(s,d,1,m-2),l=this.getBezierValue(s,d,2,m+18-2),o=this.getBezierValue(s,d,3,m+36-2)}if(n!==1)if(i===1){const f=e.data.setupPose.color;c=f.r+(c-f.r)*n,l=f.g+(l-f.g)*n,o=f.b+(o-f.b)*n}else c=a.r+(c-a.r)*n,l=a.g+(l-a.g)*n,o=a.b+(o-a.b)*n;a.r=c<0?0:c>1?1:c,a.g=l<0?0:l>1?1:l,a.b=o<0?0:o>1?1:o}},is=class extends Gt{slotIndex=0;constructor(e,t,s){super(e,t,`9|${s}`),this.slotIndex=s}apply(e,t,s,n,i,r,a,c,l){const o=e.slots[this.slotIndex];if(!o.bone.active)return;const h=(l?o.appliedPose:o.pose).color;let d=0;const m=this.frames;if(s1?1:d}},rs=class extends Kt{constructor(e,t,s){super(e,t,s,`8|${s}`,`9|${s}`,`10|${s}`)}getFrameEntries(){return 8}setFrame(e,t,s,n,i,r,a,c,l){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]=a,this.frames[e+6]=c,this.frames[e+7]=l}apply1(e,t,s,n,i,r){const a=t.color,c=t.darkColor;let l=0,o=0,h=0;const d=this.frames;if(s>3];switch(x){case 0:{const b=d[g];m=d[g+1],f=d[g+2],u=d[g+3],p=d[g+4],l=d[g+5],o=d[g+6],h=d[g+7];const w=(s-b)/(d[g+8]-b);m+=(d[g+8+1]-m)*w,f+=(d[g+8+2]-f)*w,u+=(d[g+8+3]-u)*w,p+=(d[g+8+4]-p)*w,l+=(d[g+8+5]-l)*w,o+=(d[g+8+6]-o)*w,h+=(d[g+8+7]-h)*w;break}case 1:m=d[g+1],f=d[g+2],u=d[g+3],p=d[g+4],l=d[g+5],o=d[g+6],h=d[g+7];break;default:m=this.getBezierValue(s,g,1,x-2),f=this.getBezierValue(s,g,2,x+18-2),u=this.getBezierValue(s,g,3,x+36-2),p=this.getBezierValue(s,g,4,x+54-2),l=this.getBezierValue(s,g,5,x+72-2),o=this.getBezierValue(s,g,6,x+90-2),h=this.getBezierValue(s,g,7,x+108-2)}if(n===1)a.set(m,f,u,p);else if(i===1){const b=e.data.setupPose;let w=b.color;a.set(w.r+(m-w.r)*n,w.g+(f-w.g)*n,w.b+(u-w.b)*n,w.a+(p-w.a)*n),w=b.darkColor,l=w.r+(l-w.r)*n,o=w.g+(o-w.g)*n,h=w.b+(h-w.b)*n}else a.add((m-a.r)*n,(f-a.g)*n,(u-a.b)*n,(p-a.a)*n),l=c.r+(l-c.r)*n,o=c.g+(o-c.g)*n,h=c.b+(h-c.b)*n;c.r=l<0?0:l>1?1:l,c.g=o<0?0:o>1?1:o,c.b=h<0?0:h>1?1:h}},os=class extends Kt{constructor(e,t,s){super(e,t,s,`8|${s}`,`10|${s}`)}getFrameEntries(){return 7}setFrame(e,t,s,n,i,r,a,c){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]=a,this.frames[e+6]=c}apply1(e,t,s,n,i,r){const a=t.color,c=t.darkColor;let l=0,o=0,h=0,d=0,m=0,f=0;const u=this.frames;if(s1?1:l,a.g=o<0?0:o>1?1:o,a.b=h<0?0:h>1?1:h,c.r=d<0?0:d>1?1:d,c.g=m<0?0:m>1?1:m,c.b=f<0?0:f>1?1:f}},Rt=class extends Q{slotIndex=0;attachmentNames;constructor(e,t){super(e,`11|${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,a,c,l){const o=e.slots[this.slotIndex];if(!o.bone.active)return;const h=l?o.appliedPose:o.pose;c||se){const c=this.frames[t];return s[n+1]*(e-c)/(s[n]-c)}const i=n+18;for(n+=2;n=e){const c=s[n-2],l=s[n-1];return l+(e-c)/(s[n]-c)*(s[n+1]-l)}const r=s[i-2],a=s[i-1];return a+(1-a)*(e-r)/(this.frames[t+this.getFrameEntries()]-r)}apply(e,t,s,n,i,r,a,c,l){const o=e.slots;if(!this.attachment.isTimelineActive(o,this.slotIndex,l))return;const h=this.attachment.timelineSlots,d=this.frames;if(s=d[d.length-1])u=0,m=this.vertices[d.length-1],f=null;else{const g=Q.search(d,s);u=this.getCurvePercent(s,g),m=this.vertices[g],f=this.vertices[g+1]}const p=this.vertices[0].length;this.applyToSlot(o[this.slotIndex],l,m,f,u,p,i,r,a);for(const g of h)this.applyToSlot(o[g],l,m,f,u,p,i,r,a)}applyBeforeFirst(e,t,s,n){if(!e.bone.active)return;const i=t?e.appliedPose:e.pose;if(i.attachment==null||i.attachment.timelineAttachment!==this.attachment)return;const r=i.deform;switch(r.length===0&&(n=1),n){case 1:r.length=0;break;case 2:{if(s===1){r.length=0;return}const a=this.vertices[0].length;r.length=a;const c=r,l=i.attachment;if(l.bones===null){const o=l.vertices;for(let h=0;h>4,o=c.attachment.sequence.regions.length;const h=ze[r&15];if(h!==0)switch(l+=(n-i)/a+1e-5|0,h){case 1:l=Math.min(o-1,l);break;case 2:l%=o;break;case 3:{const d=(o<<1)-2;l=d===0?0:l%d,l>=o&&(l=d-l);break}case 4:l=Math.max(o-1-l,0);break;case 5:l=o-1-l%o;break;case 6:{const d=(o<<1)-2;l=d===0?0:(l+o-1)%d,l>=o&&(l=d-l)}}c.sequenceIndex=l}},fe=class hi extends Q{static propertyIds=["13"];events;constructor(t){super(t,...hi.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,a,c,l,o){if(!i)return;const h=this.frames,d=this.frames.length;if(s>n)this.apply(null,s,Number.MAX_VALUE,i,0,a,!1,!1,!1),s=-1;else if(s>=h[d-1])return;if(n0&&h[m-1]===f;)m--}for(;m=h[m];m++)i.push(this.events[m])}},kt=class en extends Q{static propertyID="14";static propertyIds=[en.propertyID];drawOrders;constructor(t){super(t,...en.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,a,c,l,o){const h=o?t.drawOrder.appliedPose:t.drawOrder.pose,d=t.slots;if(l||n>2];switch(g){case 0:{const b=d[p];m=d[p+1],f=d[p+2],u=d[p+3];const w=(s-b)/(d[p+4]-b);m+=(d[p+4+1]-m)*w,f+=(d[p+4+2]-f)*w,u+=(d[p+4+3]-u)*w;break}case 1:m=d[p+1],f=d[p+2],u=d[p+3];break;default:m=this.getBezierValue(s,p,1,g-2),f=this.getBezierValue(s,p,2,g+18-2),u=this.getBezierValue(s,p,3,g+36-2)}const x=r===1?o.data.setupPose:h;a?(h.mixRotate=x.mixRotate+m*i,h.mixX=x.mixX+f*i,h.mixY=x.mixY+u*i):(h.mixRotate=x.mixRotate+(m-x.mixRotate)*i,h.mixX=x.mixX+(f-x.mixX)*i,h.mixY=x.mixY+(u-x.mixY)*i)}},yt=class extends Vt{constructor(e,t,s,n){super(e,t,s,n)}apply(e,t,s,n,i,r,a,c,l){if(a&&!this.additive&&(a=!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 m=l?d.appliedPose:d.pose;this.set(m,this.getAbsoluteValue(s,i,r,a,this.get(m),this.get(d.data.setupPose),o))}}else{const o=e.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;this.set(h,this.getAbsoluteValue(s,i,r,a,this.get(h),this.get(o.data.setupPose)))}}}},ms=class extends yt{constructor(e,t,s){super(e,t,s,21)}get(e){return e.inertia}set(e,t){e.inertia=t}global(e){return e.inertiaGlobal}},gs=class extends yt{constructor(e,t,s){super(e,t,s,22)}get(e){return e.strength}set(e,t){e.strength=t}global(e){return e.strengthGlobal}},ps=class extends yt{constructor(e,t,s){super(e,t,s,23)}get(e){return e.damping}set(e,t){e.damping=t}global(e){return e.dampingGlobal}},xs=class extends yt{constructor(e,t,s){super(e,t,s,24)}get(e){return 1/e.massInverse}set(e,t){e.massInverse=1/t}global(e){return e.massGlobal}},bs=class extends yt{constructor(e,t,s){super(e,t,s,25),this.additive=!0}get(e){return e.wind}set(e,t){e.wind=t}global(e){return e.windGlobal}},ws=class extends yt{constructor(e,t,s){super(e,t,s,26),this.additive=!0}get(e){return e.gravity}set(e,t){e.gravity=t}global(e){return e.gravityGlobal}},ys=class extends yt{constructor(e,t,s){super(e,t,s,27)}get(e){return e.mix}set(e,t){e.mix=t}global(e){return e.mixGlobal}},vs=class di extends Q{static propertyIds=["28"];constraintIndex;constructor(t,s){super(t,...di.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,a,c,l,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,a,!1,!1,!1),s=-1;else if(s>=d[d.length-1])return;if(!(n=d[Q.search(d,s)+1]))if(h!=null)h.reset(t);else for(const m of t.physics)m.active&&m.reset(t)}},Ts=class extends Vt{constructor(e,t,s){super(e,t,s,30)}apply(e,t,s,n,i,r,a,c,l){const o=e.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.time=this.getAbsoluteValue(s,i,r,a,h.time,o.data.setupPose.time)}}},Cs=class extends Vt{constructor(e,t,s){super(e,t,s,31),this.additive=!0}apply(e,t,s,n,i,r,a,c,l){const o=e.constraints[this.constraintIndex];if(o.active){const h=l?o.appliedPose:o.pose;h.mix=this.getAbsoluteValue(s,i,r,a,h.mix,o.data.setupPose.mix)}}},Ss=class nn{static emptyAnimation=new de("",[],0);data;tracks=[];timeScale=1;unkeyedState=0;events=[];listeners=[];queue=new xn(this);propertyIds=new Map;animationsChanged=!1;trackEntryPool=new zt(()=>new pn);constructor(t){this.data=t}update(t){t*=this.timeScale;const s=this.tracks;for(let n=0,i=s.length;n0){if(r.delay-=a,r.delay>0)continue;a=-r.delay,r.delay=0}let c=r.next;if(c){const l=r.trackLast-c.delay;if(l>=0){for(c.delay=0,c.trackTime+=r.timeScale===0?0:(l/r.timeScale+t)*c.timeScale,r.trackTime+=a,this.setTrack(n,c,!0);c.mixingFrom;)c.mixTime+=t,c=c.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 l=r.mixingFrom;for(r.mixingFrom=null,l&&(l.mixingTo=null);l;)this.queue.end(l),l=l.mixingFrom}r.trackTime+=a}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 c=0,l=n.length;c0)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,m=o.getAnimationTime(),f=m,u=s;o.reverse&&(f=o.animation.duration-f,u=null);const p=o.animation.timelines,g=p.length;if(c===0&&h===1)for(let x=0;x=o.alphaAttachmentThreshold,w=o.additive,v=w||o.shortestRotation,y=!v&&o.timelinesRotation.length!==g<<1;y&&(o.timelinesRotation.length=g<<1);for(let T=0;T0?l/c:a,h=n.animation.timelines,d=h.length,m=n.timelineMode,f=n.timelineHoldMix,u=r=n.alphaAttachmentThreshold);else{const F=!p||!(k instanceof kt)||I===0;k.apply(s,v,T,C,P,I,g,F,!1)}}return n.reverse&&r0&&this.queueEvents(n,y),this.events.length=0,n.nextAnimationLast=y,n.nextTrackLast=n.trackTime,r}applyAttachmentTimeline(t,s,n,i,r){const a=s.slots[t.slotIndex];if(!a.bone.active||!r&&a.attachmentState===this.unkeyedState+Ps)return;let c=n=0,y=x>=0;Math.abs(b)<=90&&L.signum(b)!==L.signum(g)&&(Math.abs(x-w)>180?(p+=360*L.signum(x),y=v):w!==0?p-=360*L.signum(x):y=v),y!==v&&(p+=360*L.signum(x)),a[c]=p}a[c+1]=g,h.rotation=f+p*i}queueEvents(t,s){const n=t.animationStart,i=t.animationEnd,r=i-n,a=t.reverse;let c=t.trackLast%r;a&&(c=r-c);const l=this.events;let o=0,h=l.length;for(;o=n&&m.time<=i&&this.queue.event(t,m)}let d=!1;if(t.loop)if(r===0)d=!0;else{const m=Math.floor(t.trackTime/r);d=m>0&&m>Math.floor(t.trackLast/r)}else d=s>=i&&t.animationLast=n&&m.time<=i&&this.queue.event(t,m)}}eventsReverse(t,s,n){const i=t.animation.duration,r=i-s,a=i-n,c=t.animation.timelines;for(let l=0,o=t.animation.timelines.length;l=a){for(let u=0;u=r)break;this.events.push(d[u])}}else{for(let p=0;p=r);p++)this.events.push(d[p]);let u=0;for(;u=a);u++);for(;u= 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 a=this.trackEntry(t,s,n,r);return this.setTrack(t,a,i),this.queue.drain(),a}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 a=this.trackEntry(t,s,n,r);return r?(r.next=a,a.previous=r,i<=0&&(i=Math.max(i+r.getTrackComplete()-a.mixDuration,0))):(this.setTrack(t,a,!0),this.queue.drain(),i<0&&(i=0)),a.delay=i,a}setEmptyAnimation(t,s=0){const n=this.setAnimation(t,nn.emptyAnimation,!1);return n.mixDuration=s,n.trackEnd=s,n}addEmptyAnimation(t,s=0,n=0){const i=this.addAnimation(t,nn.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;n0&&(a[h]=p);break}}l&&(u=u&~Zt|r[h]&Zt),r[h]=u}}from(t,s,n){const i=this.propertyIds;let r=wn;for(let a=0,c=n.length;a= 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()}},pn=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=qt.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===qt.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=qt.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=0}},xn=class{objects=[];drainDisabled=!1;animState;constructor(e){this.animState=e}start(e){this.objects.push(0),this.objects.push(e),this.animState.animationsChanged=!0}interrupt(e){this.objects.push(1),this.objects.push(e)}end(e){this.objects.push(2),this.objects.push(e),this.animState.animationsChanged=!0}dispose(e){this.objects.push(3),this.objects.push(e)}complete(e){this.objects.push(4),this.objects.push(e)}event(e,t){this.objects.push(5),this.objects.push(e),this.objects.push(t)}drain(){if(!this.drainDisabled){this.drainDisabled=!0;for(let e=0;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",e))(bn||{}),Mi=class{start(e){}interrupt(e){}end(e){}dispose(e){}complete(e){}event(e,t){}},As=0,wn=1,Is=2,ks=3,Zt=4,Ms=1,Ps=2,yn=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}},Pi=class{constructor(e,t="",s=new Tn,n=new vn){this.textureLoader=e,this.pathPrefix=t,this.downloader=s,this.cache=n}errors={};toLoad=0;loaded=0;texturePmaInfo={};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,a)=>{const c=`Couldn't load binary ${e}: status ${r}, ${a}`;this.error(s,e,c),i(c)})}))}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,a)=>{const c=`Couldn't load JSON ${e}: status ${r}, ${a}`;this.error(s,e,c),i(c)})}))}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(l=>{if(l.ok)return l.blob();const o=`Couldn't load image: ${e}`;this.error(s,e,`Couldn't load image: ${e}`),r(o)}).then(l=>l?createImageBitmap(l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(l=>{if(l){const o=this.createTexture(e,n,l);this.success(t,e,o),i(o)}});else{const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{const o=this.createTexture(e,n,l);this.success(t,e,o),i(o)},l.onerror=()=>{const o=`Couldn't load image: ${e}`;this.error(s,e,o),r(o)},this.downloader.rawDataUris[e]&&(e=this.downloader.rawDataUris[e]),l.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((a,c)=>{this.downloader.downloadText(e,l=>{try{const o=this.createTextureAtlas(l,r,e,n);let h=o.pages.length,d=!1;if(h===0){this.success(t,e,o),a(o);return}for(const m of o.pages)this.loadTexture(this.texturePath(r,m.name,n),(f,u)=>{d||(m.setTexture(u),--h===0&&(this.success(t,e,o),a(o)))},(f,u)=>{if(!d){const p=`Couldn't load texture ${e} page image: ${f}`;this.error(s,e,p),c(p)}d=!0})}catch(o){const h=`Couldn't parse texture atlas ${e}: ${o.message}`;this.error(s,e,h),c(h)}},(l,o)=>{const h=`Couldn't load texture atlas ${e}: status ${l}, ${o}`;this.error(s,e,h),c(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,a)=>{this.downloader.downloadText(e,c=>{try{const l=this.createTextureAtlas(c,i,e);this.success(t,e,l),r(l)}catch(l){const o=`Couldn't parse texture atlas ${e}: ${l.message}`;this.error(s,e,o),a(o)}},(c,l)=>{const o=`Couldn't load texture atlas ${e}: status ${c}, ${l}`;this.error(s,e,o),a(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 he){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 he(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 a=this.texturePath(t,r.name,n);this.texturePmaInfo[this.pathPrefix+a]=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}},vn=class De{assets={};assetsRefCount={};assetsLoaded={};static AVAILABLE_CACHES=new Map;static getCache(t){const s=De.AVAILABLE_CACHES.get(t);if(s)return s;const n=new De;return De.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]}},Tn=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{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(a){this.finish(e,400,JSON.stringify(a))}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= 0.");if(!s)throw new Error("name cannot be null.");this.index=t,this.parent=n}copy(t){const s=new pi(this.index,this.name,t);return s.length=this.length,s.setupPose.set(this.setupPose),s}},ge=(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",e))(ge||{}),pe=class{bone;x=0;y=0;rotation=0;scaleX=0;scaleY=0;shearX=0;shearY=0;inherit=0;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,m=e.scaleY,f=(t+i)*L.degRad,u=(t+90+r)*L.degRad;this.a=Math.cos(f)*s*d,this.b=Math.cos(u)*n*d,this.c=Math.sin(f)*s*m,this.d=Math.sin(u)*n*m,this.worldX=this.x*d+e.x,this.worldY=this.y*m+e.y;return}const a=this.bone.parent.appliedPose;let c=a.a,l=a.b,o=a.c,h=a.d;switch(this.worldX=c*this.x+l*this.y+a.worldX,this.worldY=o*this.x+h*this.y+a.worldY,this.inherit){case 0:{const d=(t+i)*L.degRad,m=(t+90+r)*L.degRad,f=Math.cos(d)*s,u=Math.cos(m)*n,p=Math.sin(d)*s,g=Math.sin(m)*n;this.a=c*f+l*p,this.b=c*u+l*g,this.c=o*f+h*p,this.d=o*u+h*g;return}case 1:{const d=e.scaleX,m=e.scaleY,f=(t+i)*L.degRad,u=(t+90+r)*L.degRad;this.a=Math.cos(f)*s*d,this.b=Math.cos(u)*n*d,this.c=Math.sin(f)*s*m,this.d=Math.sin(u)*n*m;break}case 2:{const d=e.scaleX,m=e.scaleY,f=1/d,u=1/m;c*=f,o*=u;let p=c*c+o*o,g=0;p>L.epsilon2?(p=Math.abs(c*h*u-l*f*o)/p,l=o*p,h=c*p,g=t-L.atan2Deg(o,c)):(c=0,o=0,g=t-90+L.atan2Deg(h,l));const x=(g+i)*L.degRad,b=(g+r+90)*L.degRad,w=Math.cos(x)*s,v=Math.cos(b)*n,y=Math.sin(x)*s,T=Math.sin(b)*n;this.a=(c*w-l*y)*d,this.b=(c*v-l*T)*d,this.c=(o*w+h*y)*m,this.d=(o*v+h*T)*m;break}case 3:case 4:{const d=e.scaleX,m=e.scaleY,f=1/d,u=1/m,p=t*L.degRad,g=Math.cos(p),x=Math.sin(p);let b=(c*g+l*x)*f,w=(o*g+h*x)*u;const v=1/Math.sqrt(b*b+w*w);b*=v,w*=v;let y=-w,T=b;this.inherit===3&&c*h-l*o<0!=(d<0!=m<0)&&(y=-y,T=-T);const C=i*L.degRad,A=(90+r)*L.degRad,k=Math.cos(C)*s,S=Math.cos(A)*n,I=Math.sin(C)*s,P=Math.sin(A)*n;this.a=(b*k+y*I)*d,this.b=(b*S+y*P)*d,this.c=(w*k+T*I)*m,this.d=(w*S+T*P)*m;break}}}updateLocalTransform(e){this.local=0,this.world=e._update;const t=e.scaleX,s=e.scaleY;if(!this.bone.parent){const g=1/t,x=1/s;this.x=(this.worldX-e.x)*g,this.y=(this.worldY-e.y)*x,this.set5(this.a*g,this.b*g,this.c*x,this.d*x,0);return}const n=this.bone.parent.appliedPose;let i=n.a,r=n.b,a=n.c,c=n.d;const l=i*c-r*a,o=1/(i*c-r*a),h=c*o,d=r*o,m=a*o,f=i*o,u=this.worldX-n.worldX,p=this.worldY-n.worldY;switch(this.x=u*h-p*d,this.y=p*f-u*m,this.inherit){case 0:this.set5(h*this.a-d*this.c,h*this.b-d*this.d,f*this.c-m*this.a,f*this.d-m*this.b,0);break;case 1:{const g=1/t,x=1/s;this.set5(this.a*g,this.b*g,this.c*x,this.d*x,0);break}case 2:{const g=1/t,x=1/s;i*=g,a*=x;const b=this.a*g,w=this.b*g,v=this.c*x,y=this.d*x,T=1/(i*i+a*a),C=1/Math.abs(l*g*x);this.set5((i*b+a*v)*T,(i*w+a*y)*T,(i*v-a*b)*C,(i*y-a*w)*C,L.atan2Deg(a,i));break}case 3:case 4:{const g=1/t,x=1/s,b=this.a*g,w=this.b*g,v=this.c*x,y=this.d*x;let T=c*this.a-r*this.c,C=i*this.c-a*this.a;l<0&&(T=-T,C=-C);let A=L.atan2Deg(C,T);this.rotation=A,A*=L.degRad;const k=Math.cos(A),S=Math.sin(A);let I=(i*k+r*S)*g,P=(a*k+c*S)*x;const F=1/Math.sqrt(I*I+P*P);I*=F,P*=F;const B=this.inherit===3&&l<0!=(t<0!=s<0)?-1:1;this.set4(I*b+P*v,I*w+P*y,(I*v-P*b)*B,(I*y-P*w)*B)}}}set4(e,t,s,n){const i=e*e+s*s,r=t*t+n*n;i>L.epsilon2?(this.shearX=L.atan2Deg(s,e),this.scaleX=Math.sqrt(i)):(this.shearX=0,this.scaleX=0),this.scaleY=Math.sqrt(r),r>L.epsilon2?(this.shearY=L.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,a=t*t+n*n;if(r>L.epsilon2){const c=L.atan2Deg(s,e);this.rotation=c+i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(a),a>L.epsilon2?(this.shearY=L.atan2Deg(n,t),e*n-t*s<0?(this.scaleY=-this.scaleY,this.shearY+=90-c):this.shearY-=90+c,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0}else this.scaleX=0,this.scaleY=Math.sqrt(a),this.shearY=0,this.rotation=a>L.epsilon2?L.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,e._update)}modifyWorld(e){const t=e._update;this.local=t,this.world=t,this.resetWorld(e,t)}resetWorld(e,t){const s=this.bone.children;for(let n=0,i=s.length;n(e[e.None=0]="None",e[e.Uniform=1]="Uniform",e[e.Volume=2]="Volume",e))(be||{}),we=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}},Xs=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 we(-1,this);constructor(e){this.name=e}},ye=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 Et extends Nt{bones;target;constructor(t,s){if(super(t,new ye,new ye),!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 Et(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:Et.apply(t,r[0],i.worldX,i.worldY,n.compress,n.stretch,this.data.scaleYMode,n.mix);break;case 2:Et.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,a,c,l,o,h){typeof n=="number"?Et.apply1(t,s,n,i,r,a,c,l):Et.apply2(t,s,n,i,r,a,c,l,o,h)}static apply1(t,s,n,i,r,a,c,l){s.modifyLocal(t);const o=s.bone.parent.appliedPose;let h=o.a,d=o.b,m=o.c,f=o.d,u=-s.shearX-s.rotation,p=0,g=0;switch(s.inherit){case 1:p=(n-s.worldX)*L.signum(t.scaleX),g=(i-s.worldY)*L.signum(t.scaleY);break;case 2:{const x=Math.abs(h*f-d*m)/Math.max(L.epsilon,h*h+m*m),b=h/t.scaleX,w=m/t.scaleY;d=-w*x*t.scaleX,f=b*x*t.scaleY,u+=L.atan2Deg(w,b)}default:{const x=n-o.worldX,b=i-o.worldY,w=h*f-d*m;Math.abs(w)<=L.epsilon?(p=0,g=0):(p=(x*f-b*d)/w-s.x,g=(b*h-x*m)/w-s.y)}}if(u+=L.atan2Deg(g,p),s.scaleX<0&&(u+=180),u>180?u-=360:u<=-180&&(u+=360),s.rotation+=u*l,r||a){switch(s.inherit){case 3:case 4:p=n-s.worldX,g=i-s.worldY}const x=s.bone.data.length*s.scaleX;if(x>L.epsilon){const b=p*p+g*g;if(r&&bx*x){const w=(Math.sqrt(b)/x-1)*l+1;switch(s.scaleX*=w,c){case 1:s.scaleY*=w;break;case 2:s.scaleY/=w<.7?.25+.642857*w:w}}}}}static apply2(t,s,n,i,r,a,c,l,o,h){if(s.inherit!==0||n.inherit!==0)return;s.modifyLocal(t),n.modifyLocal(t);let d=s.x,m=s.y,f=s.scaleX,u=s.scaleY,p=n.scaleX,g=0,x=0,b=0;f<0?(f=-f,g=180,b=-1):(g=0,b=1),u<0&&(u=-u,b=-b),p<0?(p=-p,x=180):x=0;let w=0,v=0,y=s.a,T=s.b,C=s.c,A=s.d;const k=Math.abs(f-u)<=L.epsilon;!k||c?(n.y=0,w=y*n.x+s.worldX,v=C*n.x+s.worldY):(w=y*n.x+T*n.y+s.worldX,v=C*n.x+A*n.y+s.worldY);const S=s.bone.parent.appliedPose;y=S.a,T=S.b,C=S.c,A=S.d;let I=y*A-T*C,P=w-S.worldX,F=v-S.worldY;I=Math.abs(I)<=L.epsilon?0:1/I;const B=(P*A-F*T)*I-d,X=(F*y-P*C)*I-m;let R=Math.sqrt(B*B+X*X),_=n.bone.data.length*p,D,Y;if(R0){let $=Math.min(1,q/(o*2))-1;$=(q-o*(1-$*$))/N,E-=$*E,U-=$*U,O=E*E+U*U}}t:if(k){_*=f;let N=(O-R*R-_*_)/(2*R*_);if(N<-1)N=-1,Y=Math.PI*a;else if(N>1){if(N=1,Y=0,c)switch(y=(Math.sqrt(O)/(R+_)-1)*h+1,s.scaleX*=y,l){case 1:s.scaleY*=y;break;case 2:s.scaleY/=y<.7?.25+.642857*y:y}}else Y=Math.acos(N)*a;y=R+_*N,T=_*Math.sin(Y),D=Math.atan2(U*y-E*T,E*y+U*T)}else{y=f*_,T=u*_;const N=y*y,q=T*T,$=Math.atan2(U,E);C=q*R*R+N*O-N*q;const J=-2*q*R,et=q-N;if(A=J*J-4*et*C,A>=0){let gt=Math.sqrt(A);J<0&&(gt=-gt),gt=-(J+gt)*.5;let bt=gt/et,$t=C/gt;const ae=Math.abs(bt)=0){F=Math.sqrt(bt)*a,D=$-Math.atan2(F,ae),Y=Math.atan2(F/u,(ae-R)/f);break t}}let Z=L.PI,st=R-y,rt=st*st,nt=0,ut=0,ot=R+y,at=ot*ot,ft=0;C=-y*R/(N-q),C>=-1&&C<=1&&(C=Math.acos(C),P=y*Math.cos(C)+R,F=T*Math.sin(C),A=P*P+F*F,Aat&&(ut=C,at=A,ot=P,ft=F)),O<=(rt+at)*.5?(D=$-Math.atan2(nt*a,st),Y=Z*a):(D=$-Math.atan2(ft*a,ot),Y=ut*a)}const W=Math.atan2(n.y,n.x)*b;D=(D-W)*L.radDeg+g-s.rotation,D>180?D-=360:D<=-180&&(D+=360),s.rotation+=D*h,Y=((Y+W)*L.radDeg-n.shearX)*b+x-n.rotation,Y>180?Y-=360:Y<=-180&&(Y+=360),n.rotation+=Y*h}},Qt=class extends Dt{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=0;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 ye)}create(e){return new In(this,e)}},ve=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}},te=class extends Dt{bones=[];set slot(e){this._slot=e}get slot(){if(this._slot)return this._slot;throw new Error("SlotData not set.")}_slot=null;positionMode=0;spacingMode=1;rotateMode=1;offsetRotation=0;constructor(e){super(e,new ve)}create(e){return new kn(this,e)}},Ls=(e=>(e[e.Fixed=0]="Fixed",e[e.Percent=1]="Percent",e))(Ls||{}),Rs=(e=>(e[e.Length=0]="Length",e[e.Fixed=1]="Fixed",e[e.Percent=2]="Percent",e[e.Proportional=3]="Proportional",e))(Rs||{}),Vs=(e=>(e[e.Tangent=0]="Tangent",e[e.Chain=1]="Chain",e[e.ChainScale=2]="ChainScale",e))(Vs||{}),kn=class Bt extends Nt{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 ve,new ve),!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 Bt(this.data,t);return s.pose.set(this.pose),s}update(t,s){const n=this.slot.appliedPose.attachment;if(!(n instanceof jt))return;const i=this.appliedPose,r=i.mixRotate,a=i.mixX,c=i.mixY;if(r===0&&a===0&&c===0)return;const l=this.data,o=l.rotateMode===0,h=l.rotateMode===2,d=this.bones,m=d.length,f=o?m:m+1,u=V.setArraySize(this.spaces,f),p=h?this.lengths=V.setArraySize(this.lengths,m):[],g=i.spacing;switch(l.spacingMode){case 2:if(h)for(let T=0,C=f-1;T0){T=f/T*g;for(let C=1;C0?L.degRad:-L.degRad}for(let T=0,C=3;T0){let F=A.a,B=A.b,X=A.c,R=A.d,_=0,D=0,Y=0;if(o?_=x[C-1]:u[T+1]===0?_=x[C+2]:_=Math.atan2(P,I),_-=Math.atan2(X,F),y){D=Math.cos(_),Y=Math.sin(_);const E=A.bone.data.length;b+=(E*(D*F-Y*X)-I)*r,w+=(E*(Y*F+D*X)-P)*r}else _+=v;_>L.PI?_-=L.PI2:_<-L.PI&&(_+=L.PI2),_*=r,D=Math.cos(_),Y=Math.sin(_),A.a=D*F-Y*X,A.b=D*B-Y*R,A.c=Y*F+D*X,A.d=Y*B+D*R}}}computeWorldPositions(t,s,n,i){const r=this.slot;let a=this.appliedPose.position,c=this.spaces,l=V.setArraySize(this.positions,n*3+2),o=this.world;const h=s.closed;let d=s.worldVerticesLength,m=d/6,f=Bt.NONE;if(!s.constantSpeed){const Y=s.lengths;m-=h?1:2;const E=Y[m];this.data.positionMode===1&&(a*=E);let U;switch(this.data.spacingMode){case 2:U=E;break;case 3:U=E/n;break;default:U=1}o=V.setArraySize(this.world,8);for(let O=0,W=0,N=0;OE){f!==Bt.AFTER&&(f=Bt.AFTER,s.computeWorldVertices(t,r,d-6,4,o,0,2)),this.addAfterPosition($-E,o,0,l,W);continue}for(;;N++){const J=Y[N];if(!($>J)){if(N===0)$/=J;else{const et=Y[N-1];$=($-et)/(J-et)}break}}N!==f&&(f=N,h&&N===m?(s.computeWorldVertices(t,r,d-4,4,o,0,2),s.computeWorldVertices(t,r,0,4,o,4,2)):s.computeWorldVertices(t,r,N*6+2,8,o,0,2)),this.addCurvePosition($,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],l,W,i||O>0&&q===0)}return l}h?(d+=2,o=V.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]):(m--,d-=4,o=V.setArraySize(this.world,d),s.computeWorldVertices(t,r,2,d,o,0,2));const u=V.setArraySize(this.curves,m);let p=0,g=o[0],x=o[1],b=0,w=0,v=0,y=0,T=0,C=0,A=0,k=0,S=0,I=0,P=0,F=0,B=0,X=0;for(let Y=0,E=2;Yp){this.addAfterPosition(N-p,o,d-4,l,E);continue}for(;;U++){const q=u[U];if(!(N>q)){if(U===0)N/=q;else{const $=u[U-1];N=(N-$)/(q-$)}break}}if(U!==f){f=U;let q=U*6;for(g=o[q],x=o[q+1],b=o[q+2],w=o[q+3],v=o[q+4],y=o[q+5],T=o[q+6],C=o[q+7],A=(g-b*2+v)*.03,k=(x-w*2+y)*.03,S=((b-v)*3-g+T)*.006,I=((w-y)*3-x+C)*.006,P=A*2+S,F=k*2+I,B=(b-g)*.3+A+S*.16666667,X=(w-x)*.3+k+I*.16666667,D=Math.sqrt(B*B+X*X),_[0]=D,q=1;q<8;q++)B+=P,X+=F,P+=S,F+=I,D+=Math.sqrt(B*B+X*X),_[q]=D;B+=P,X+=F,D+=Math.sqrt(B*B+X*X),_[8]=D,B+=P+S,X+=F+I,D+=Math.sqrt(B*B+X*X),_[9]=D,O=0}for(N*=D;;O++){const q=_[O];if(!(N>q)){if(O===0)N/=q;else{const $=_[O-1];N=O+(N-$)/(q-$)}break}}this.addCurvePosition(N*.1,g,x,b,w,v,y,T,C,l,E,i||Y>0&&W===0)}return l}addBeforePosition(t,s,n,i,r){const a=s[n],c=s[n+1],l=s[n+2]-a,o=s[n+3]-c,h=Math.atan2(o,l);i[r]=a+t*Math.cos(h),i[r+1]=c+t*Math.sin(h),i[r+2]=h}addAfterPosition(t,s,n,i,r){const a=s[n+2],c=s[n+3],l=a-s[n],o=c-s[n+1],h=Math.atan2(o,l);i[r]=a+t*Math.cos(h),i[r+1]=c+t*Math.sin(h),i[r+2]=h}addCurvePosition(t,s,n,i,r,a,c,l,o,h,d,m){if(t===0||Number.isNaN(t)){h[d]=s,h[d+1]=n,h[d+2]=Math.atan2(r-n,i-s);return}const f=t*t,u=f*t,p=1-t,g=p*p,x=g*p,b=p*t,w=b*3,v=p*w,y=w*t,T=s*x+i*v+a*y+l*u,C=n*x+r*v+c*y+o*u;h[d]=T,h[d+1]=C,m&&(t<.001?h[d+2]=Math.atan2(r-n,i-s):h[d+2]=Math.atan2(C-(n*g+r*b*2+c*f),T-(s*g+i*b*2+a*f)))}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 a=0;a(e[e.none=0]="none",e[e.reset=1]="reset",e[e.update=2]="update",e[e.pose=3]="pose",e))(Mn||{}),Te=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}},Ce=class{color=new z(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 vt)||!(this.attachment instanceof vt)||e.timelineAttachment!==this.attachment.timelineAttachment)&&(this.deform.length=0),this.attachment=e,this.sequenceIndex=-1)}},Pn=class bi extends Es{skeleton;bone;attachmentState=0;constructor(t,s){if(super(t,new Ce,new Ce),!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 z,this.constrainedPose.darkColor=new z),this.setupPose()}copy(t,s,n){const i=new bi(t.data,this.skeleton);return this.data.setupPose.darkColor!=null&&(i.pose.darkColor=new z,i.constrainedPose.darkColor=new z),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)}},Ot=class Oe{static quadTriangles=[0,1,2,2,3,0];static yDown=!1;static get yDir(){return Oe.yDown?-1:1}data;bones;slots;drawOrder;constraints;physics;_updateCache=[];resetCache=[];skin=null;color;scaleX=1;_scaleY=1;get scaleY(){return this._scaleY*Oe.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;s0,a=this.data.y>0,c=this.data.rotate>0||this.data.shearX>0,l=this.data.scaleX>0,o=this.bone;let h=o.bone.data.length,d=this.data.step,m=0;if(s!==0){switch(o.modifyWorld(t),s){case 1:this.reset(t);case 2:{const f=Math.max(t.time-this.lastTime,0),u=this.remaining;this.remaining+=f,this.lastTime=t.time;const p=o.worldX,g=o.worldY;if(this._reset)this._reset=!1,this.ux=p,this.uy=g;else{let x=this.remaining,b=n.inertia,w=t.data.referenceScale,v=-1,y=0,T=0,C=this.data.limit*f,A=C*Math.abs(t.scaleY);if(C*=Math.abs(t.scaleX),r||a){if(r){const k=(this.ux-p)*b;this.xOffset+=k>C?C:k<-C?-C:k,this.ux=p}if(a){const k=(this.uy-g)*b;this.yOffset+=k>A?A:k<-A?-A:k,this.uy=g}if(x>=d){const k=this.xOffset,S=this.yOffset;v=n.damping**(60*d),y=d*n.massInverse,T=n.strength;const I=w*n.wind,P=w*n.gravity,F=(I*t.windX+P*t.gravityX)*t.scaleX,B=(I*t.windY+P*t.gravityY)*t.scaleY;do r&&(this.xVelocity+=(F-this.xOffset*T)*y,this.xOffset+=this.xVelocity*d,this.xVelocity*=v),a&&(this.yVelocity-=(B+this.yOffset*T)*y,this.yOffset+=this.yVelocity*d,this.yVelocity*=v),x-=d;while(x>=d);this.xLag=this.xOffset-k,this.yLag=this.yOffset-S}m=Math.max(0,1-x/d),r&&(o.worldX+=(this.xOffset-this.xLag*m)*i*this.data.x),a&&(o.worldY+=(this.yOffset-this.yLag*m)*i*this.data.y)}if(c||l){let k=Math.atan2(o.c,o.a),S=0,I=0,P=0,F=this.cx-o.worldX,B=this.cy-o.worldY;if(F>C?F=C:F<-C&&(F=-C),B>A?B=A:B<-A&&(B=-A),x=this.remaining,c){P=(this.data.rotate+this.data.shearX)*i,m=this.rotateLag*Math.max(0,1-u/d);let X=Math.atan2(B+this.ty,F+this.tx)-k-(this.rotateOffset-m)*P;this.rotateOffset+=(X-Math.ceil(X*L.invPI2-.5)*L.PI2)*b,X=(this.rotateOffset-m)*P+k,S=Math.cos(X),I=Math.sin(X),l&&(X=h*o.getWorldScaleX(),X>0&&(this.scaleOffset+=(F*S+B*I)*b/X))}else{S=Math.cos(k),I=Math.sin(k);const X=h*o.getWorldScaleX()-this.scaleLag*Math.max(0,1-u/d);X>0&&(this.scaleOffset+=(F*S+B*I)*b/X)}if(x>=d){v===-1&&(v=n.damping**(60*d),y=d*n.massInverse,T=n.strength);const X=n.wind*t.windX+n.gravity*t.gravityX,R=(n.wind*t.windY+n.gravity*t.gravityY)*Ot.yDir,_=this.rotateOffset,D=this.scaleOffset,Y=h/w;for(;;)if(x-=d,l&&(this.scaleVelocity+=(X*S-R*I-this.scaleOffset*T)*y,this.scaleOffset+=this.scaleVelocity*d,this.scaleVelocity*=v),c){if(this.rotateVelocity-=((X*I+R*S)*Y+this.rotateOffset*T)*y,this.rotateOffset+=this.rotateVelocity*d,this.rotateVelocity*=v,x0){let x=0;this.data.rotate>0&&(x=f*this.data.rotate,u=Math.sin(x),p=Math.cos(x),g=o.b,o.b=p*g-u*o.d,o.d=u*g+p*o.d),x+=f*this.data.shearX,u=Math.sin(x),p=Math.cos(x),g=o.a,o.a=p*g-u*o.c,o.c=u*g+p*o.c}else f*=this.data.rotate,u=Math.sin(f),p=Math.cos(f),g=o.a,o.a=p*g-u*o.c,o.c=u*g+p*o.c,g=o.b,o.b=p*g-u*o.d,o.d=u*g+p*o.d}if(l){let f=1+(this.scaleOffset-this.scaleLag*m)*i*this.data.scaleX;switch(o.a*=f,o.c*=f,this.data.scaleYMode){case 1:o.b*=f,o.d*=f;break;case 2:f=Math.abs(f),f=f>=.7?1/f:4-3.67347*f,o.b*=f,o.d*=f}}s!==3&&(this.tx=h*o.a,this.ty=h*o.c)}}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}},ee=class extends Dt{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=0;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 Te)}create(e){return new Ns(this,e)}};typeof Math.fround>"u"&&(Math.fround=(e=>t=>(e[0]=t,e[0]))(new Float32Array(1)));var Se=class{time=0;mix=0;set(e){this.time=e.time,this.mix=e.mix}},Fn=class rn extends Nt{static offsets=[0,0,0,0,0,0];bone=null;constructor(t,s){if(super(t,new Se,new Se),!s)throw new Error("skeleton cannot be null.");t.bone!=null&&(this.bone=s.bones[t.bone.index])}copy(t){var s=new rn(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,a=this.bone;if(a!==null){if(!a.active)return;i.local&&a.appliedPose.validateLocalTransform(t),n.time=i.offset+(i.property.value(t,a.appliedPose,i.local,rn.offsets)-i.property.offset)*i.scale,i.loop?n.time=r.duration+n.time%r.duration:n.time=Math.max(0,n.time)}const c=t.bones,l=r.bones;for(let o=0,h=r.bones.length;o=n.length&&(n.length=e+1),n[e]||(n[e]={}),n[e][t]=s}addSkin(e){for(let s=0;s= 0.");if(!s)throw new Error("boneData cannot be null.");this.index=e,this.boneData=s}},_s=(e=>(e[e.Normal=0]="Normal",e[e.Additive=1]="Additive",e[e.Multiply=2]="Multiply",e[e.Screen=3]="Screen",e))(_s||{}),Ie=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 yi extends Nt{bones;source;constructor(t,s){if(super(t,new Ie,new Ie),!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 yi(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,a=i.localTarget,c=i.additive,l=i.clamp,o=i.offsets,h=this.source.appliedPose;r&&h.validateLocalTransform(t);const d=i.properties,m=i.properties.length,f=this.bones;for(let u=0,p=this.bones.length;u0?n[K.ROTATION]:-n[K.ROTATION]);return a<0&&(a+=360),a}},Us=class extends Ft{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 a=e.scaleX,c=e.scaleY,l=1/a,o=1/c,h=s.a*l,d=s.b*l,m=s.c*o,f=s.d*o;n*=L.degRad,r||(n-=Math.atan2(m,h)),n>L.PI?n-=L.PI2:n<-L.PI&&(n+=L.PI2),n*=t.mixRotate;const u=Math.cos(n),p=Math.sin(n);s.a=(u*h-p*m)*a,s.b=(u*d-p*f)*a,s.c=(p*h+u*m)*c,s.d=(p*d+u*f)*c}}},Me=class extends Pt{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}},$s=class extends Ft{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)}},Pe=class extends Pt{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 Ft{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)}},Fe=class extends Pt{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 Ft{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 a=1+(n-1)*t.mixScaleX;s.a*=a,s.c*=a}else{let a=s.a/e.scaleX,c=s.c/e.scaleY,l=Math.sqrt(a*a+c*c);l!==0&&(l=1+(n-l)*t.mixScaleX/l,s.a*=l,s.c*=l)}}},Ye=class extends Pt{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]}},Ws=class extends Ft{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 a=1+(n-1)*t.mixScaleY;s.b*=a,s.d*=a}else{let a=s.b/e.scaleX,c=s.d/e.scaleY,l=Math.sqrt(a*a+c*c);l!==0&&(l=1+(n-l)*t.mixScaleY/l,s.b*=l,s.d*=l)}}},Ee=class extends Pt{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))*L.radDeg-90+n[K.SHEARY]}},Gs=class extends Ft{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 a=e.scaleX,c=e.scaleY,l=s.b/a,o=s.d/c,h=Math.atan2(o,l);n=(n+90)*L.degRad,r?n-=L.PI/2:(n-=h-Math.atan2(s.c/c,s.a/a),n>L.PI?n-=L.PI2:n<-L.PI&&(n+=L.PI2)),n=h+n*t.mixShearY;const d=Math.sqrt(l*l+o*o);s.b=Math.cos(n)*d*a,s.d=Math.sin(n)*d*c}}},En=class{scale=1;attachmentLoader;linkedMeshes=[];constructor(e){this.attachmentLoader=e}readSkeletonData(e){const t=this.scale,s=new Ae;s.name="";const n=new Bn(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 a=n.readBoolean();a&&(s.fps=n.readFloat(),s.imagesPath=n.readString(),s.audioPath=n.readString());let c=0;c=n.readInt(!0);for(let f=0;f>5;for(let w=0,v;w>1&1,g.spacingMode=x>>2&3,g.rotateMode=x>>4&3,(x&128)!==0&&(g.offsetRotation=n.readFloat());const b=g.setupPose;b.position=n.readFloat(),g.positionMode===0&&(b.position*=t),b.spacing=n.readFloat(),(g.spacingMode===0||g.spacingMode===1)&&(b.spacing*=t),b.mixRotate=n.readFloat(),b.mixX=n.readFloat(),b.mixY=n.readFloat(),o.push(g);break}case Qi:{const g=new ee(u);g.bone=l[n.readInt(!0)];let x=n.readByte();if(g.skinRequired=(x&1)!==0,(x&2)!==0&&(g.x=n.readFloat()),(x&4)!==0&&(g.y=n.readFloat()),(x&8)!==0&&(g.rotate=n.readFloat()),(x&16)!==0){let w=n.readFloat();w<-2?(g.scaleYMode=2,w=-2-w):w<0&&(g.scaleYMode=1,w=-1-w),g.scaleX=w}(x&32)!==0&&(g.shearX=n.readFloat()),g.limit=((x&64)!==0?n.readFloat():5e3)*t,g.step=1/n.readUnsignedByte();const b=g.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&&(g.inertiaGlobal=!0),(x&2)!==0&&(g.strengthGlobal=!0),(x&4)!==0&&(g.dampingGlobal=!0),(x&8)!==0&&(g.massGlobal=!0),(x&16)!==0&&(g.windGlobal=!0),(x&32)!==0&&(g.gravityGlobal=!0),(x&64)!==0&&(g.mixGlobal=!0),b.mix=(x&128)!==0?n.readFloat():1,o.push(g);break}case tr:{const g=new At(u),x=n.readByte();if(g.skinRequired=(x&1)!==0,g.loop=(x&2)!==0,g.additive=(x&4)!==0,(x&8)!==0){const b=n.readFloat();a&&(x&64)!==0?g.max=b:g.setupPose.time=b}if((x&16)!==0&&(g.setupPose.mix=(x&32)!==0?n.readFloat():1),(x&64)!==0){g.local=(x&128)!==0,g.bone=l[n.readInt(!0)];const b=n.readFloat();let w=1;switch(n.readByte()){case 0:g.property=new ke;break;case 1:{w=t,g.property=new Me;break}case 2:{w=t,g.property=new Pe;break}case 3:g.property=new Fe;break;case 4:g.property=new Ye;break;case 5:g.property=new Ee;break;default:continue}g.property.offset=b*w,g.offset=n.readFloat(),g.scale=n.readFloat()/w}o.push(g);break}}}const d=this.readSkin(n,s,!0,a);d&&(s.defaultSkin=d,s.skins.push(d));{let f=s.skins.length;for(V.setArraySize(s.skins,c=f+n.readInt(!0));f0){x=[];for(let T=0;T>4,e.readFloat())}i.push(k);break}}}}}const a=s.slots.length,c=e.readInt(!0);if(c>0){const m=new kt(c);for(let f=0;f0){const m=new fe(o);for(let f=0;f>>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>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}},Fi=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}},Xn=class{constructor(e=null,t,s=0){this.bones=e,this.vertices=t,this.length=s}};function tt(e,t,s,n){s instanceof Gt?Yi(e,t,s,n):Ei(e,t,s,n)}function Yi(e,t,s,n){let i=e.readFloat(),r=e.readFloat()*n;for(let a=0,c=0,l=s.getFrameCount()-1;s.setFrame(a,i,r),a!==l;a++){const o=e.readFloat(),h=e.readFloat()*n;switch(e.readByte()){case pt:s.setStepped(a);break;case xt:G(e,s,c++,a,0,i,o,r,h,n)}i=o,r=h}t.push(s)}function Ei(e,t,s,n){let i=e.readFloat(),r=e.readFloat()*n,a=e.readFloat()*n;for(let c=0,l=0,o=s.getFrameCount()-1;s.setFrame(c,i,r,a),c!==o;c++){const h=e.readFloat(),d=e.readFloat()*n,m=e.readFloat()*n;switch(e.readByte()){case pt:s.setStepped(c);break;case xt:G(e,s,l++,c,0,i,h,r,d,n),G(e,s,l++,c,1,i,h,a,m,n)}i=h,r=d,a=m}t.push(s)}function Ln(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,a=0;for(let c=0;c=0;c--)n[c]===-1&&(n[c]=i[--a]);return n}function G(e,t,s,n,i,r,a,c,l,o){t.setBezier(s,n,i,r,c,e.readFloat(),e.readFloat()*o,e.readFloat(),e.readFloat()*o,a,l)}var Bi=0,Xi=1,Li=2,Ri=3,Vi=4,Ni=5,Di=6,Oi=7,_i=8,Ui=9,$i=10,qi=0,zi=1,Wi=2,Gi=3,Hi=4,Ki=5,Ji=0,Zi=1,ji=2,Qi=3,tr=4,er=0,sr=1,nr=0,ir=1,rr=2,or=0,ar=1,lr=2,cr=4,hr=5,dr=6,ur=7,fr=8,mr=0,gr=1,pt=1,xt=2,Rn=class{minX=0;minY=0;maxX=0;maxY=0;boundingBoxes=[];polygons=[];polygonPool=new zt(()=>V.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,a=r.length;s.length=0,i.freeAll(n),n.length=0;for(let c=0;c=this.minX&&e<=this.maxX&&t>=this.minY&&t<=this.maxY}aabbIntersectsSegment(e,t,s,n){const i=this.minX,r=this.minY,a=this.maxX,c=this.maxY;if(e<=i&&s<=i||t<=r&&n<=r||e>=a&&s>=a||t>=c&&n>=c)return!1;const l=(n-t)/(s-e);let o=l*(i-e)+t;if(o>r&&or&&oi&&hi&&he.minX&&this.minYe.minY}containsPoint(e,t){const s=this.polygons;for(let n=0,i=s.length;n=s||o=s){const h=n[c];h+(s-l)/(o-l)*(n[r]-h)=h&&w<=f||w>=f&&w<=h)&&(w>=t&&w<=n||w>=n&&w<=t)){const v=(o*x-l*p)/b;if((v>=d&&v<=u||v>=u&&v<=d)&&(v>=s&&v<=i||v>=i&&v<=s))return!0}h=f,d=u}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}},Vn=class lt{convexPolygons=[];convexPolygonsIndices=[];indicesArray=[];isConcaveArray=[];triangles=[];polygonPool=new zt(()=>[]);polygonIndicesPool=new zt(()=>[]);triangulate(t){const s=t;let n=t.length>>1;const i=this.indicesArray;i.length=0;for(let c=0;c3;){let c=n-1,l=0,o=1;for(;;){t:if(!r[l]){const m=i[c]<<1,f=i[l]<<1,u=i[o]<<1,p=s[m],g=s[m+1],x=s[f],b=s[f+1],w=s[u],v=s[u+1];for(let y=o+10);c=l>0?l-1:n-1,o=l+10?l-1:n-1,d=l0&&(i.push(c),r.push(a),c=this.polygonPool.obtain(),a=this.polygonIndicesPool.obtain()),c.length=0,c.push(p,g,x,b),c.push(w,v),a.length=0,a.push(m,f,u),o=lt.winding(p,g,x,b,w,v),l=m}c.length>0&&(i.push(c),r.push(a));for(let h=0,d=i.length;h=0;h--)c=i[h],c.length===0?(i.splice(h,1),this.polygonPool.free(c),a=r[h],r.splice(h,1),this.polygonIndicesPool.free(a)):c.push(c[0],c[1]);return i}static isConcave(t,s,n,i){const r=i[t>0?t-1:s-1]<<1,a=i[t]<<1,c=i[t+1=0}static winding(t,s,n,i,r,a){return t*(a-i)+n*(s-a)+r*(i-s)>=0?1:-1}},ne=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=V.setArraySize(this.clippingPolygon,n);s.computeWorldVertices(e,t,0,n,i,0,2);const r=this.clippingPolygon,a=this.makeClockwise(r);a||this.inverse||s.convex?(a||this.makeConvex(r),this.clippingPolygon.push(r[0],r[1]),this.clippingPolygons.push(r)):(this.triangulator===null&&(this.triangulator=new Vn),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,a,c){return n&&i&&r&&typeof a=="boolean"&&typeof c=="number"?this.clipTrianglesRender(e,t,s,n,i,r,a,c):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>1,A=n.length;const k=V.setArraySize(n,A+T);V.arrayCopy(w,v,k,A,T),A=i.length;const S=V.setArraySize(i,A+3*(C-2));for(let I=1;I>1;const T=V.setArraySize(n,w+v);V.arrayCopy(o,0,T,w,v),w=i.length;const C=V.setArraySize(i,w+3*(y-2));y--;for(let A=1;A>1;let $=l.length;const J=V.setArraySize(l,$+q*c);for(let Z=0;Z>1;_===0&&(F=T-S,B=k-y,X=x-k,R=S-b,_=1/(F*X-B*R));const O=V.setArraySize(l,Y+U*c);for(let N=0;N>1;let N=this.clippedVerticesLength;const q=N+W*r,$=this.clippedUVsLength+W*2;a.length>1;D===0&&(B=C-I,X=S-T,R=x-S,_=I-b,D=1/(B*R-X*_));const W=E+O*r;a.length=2?(o=this.clipOutput,h=this.scratch):(o=this.scratch,h=this.clipOutput);const d=a;o.length=8;const m=o;m[0]=e,m[1]=t,m[2]=s,m[3]=n,m[4]=i,m[5]=r,m[6]=e,m[7]=t,h.length=0;const f=a.length-4;for(let u=0;;u+=2){const p=d[u],g=d[u+1],x=p-d[u+2],b=g-d[u+3],w=h.length,v=o;e=v[0],t=v[1];let y=b*(p-e)-x*(g-t);for(let C=2,A=o.length-2;C<=A;C+=2){s=v[C],n=v[C+1];const k=b*(p-s)-x*(g-n);if(y>0)if(k>0)h.push(s,n);else{const S=s-e,I=n-t,P=y/(S*b-I*x);P>=0&&P<=1?(h.push(e+S*P,t+I*P),l=!0):h.push(s,n)}else if(k>0){const S=s-e,I=n-t,P=y/(S*b-I*x);P>=0&&P<=1?(h.push(e+S*P,t+I*P,s,n),l=!0):h.push(s,n)}else l=!0;e=s,t=n,y=k}if(w===h.length)return c.length=0,!0;if(h.push(h[0],h[1]),u===f)break;const T=h;h=o,h.length=0,o=T}if(c!==h){c.length=0;for(let u=0,p=h.length-2;u=2?(l=this.clipOutput,o=this.scratch):(l=this.scratch,o=this.clipOutput),l.length=8;let h=a,d=l;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 m=0;;m+=2){const f=h[m],u=h[m+1],p=f-h[m+2],g=u-h[m+3],x=o.length,b=this.inverseVertices.length;this.inverseVertices.push(0),d=l,e=d[0],t=d[1];let w=g*(f-e)-p*(u-t);for(let T=2,C=l.length-2;T<=C;T+=2){s=d[T],n=d[T+1];const A=g*(f-s)-p*(u-n);if(w>0)if(A>0)o.push(s,n);else{const k=s-e,S=n-t,I=w/(k*g-S*p);if(I>=0&&I<=1){const P=e+k*I,F=t+S*I;o.push(P,F),this.inverseVertices.push(P,F,s,n)}else o.push(s,n)}else if(A>0){const k=s-e,S=n-t,I=w/(k*g-S*p);if(I>=0&&I<=1){const P=e+k*I,F=t+S*I;this.inverseVertices.push(P,F),o.push(P,F,s,n)}else o.push(s,n)}else this.inverseVertices.push(s,n);e=s,t=n,w=A}const v=this.inverseVertices.length-b-1;if(v>=6?this.inverseVertices[b]=v:this.inverseVertices.length=b,x===o.length||(o.push(o[0],o[1]),m===c))break;const y=o;o=l,o.length=0,l=y}}makeClockwise(e){const t=e,s=e.length;let n=!0,i=!0,r=0,a=t[s-2],c=t[s-1],l=t[0],o=t[1];for(let d=2;d=0,a=l,c=o,l=m,o=f}r+=l*t[1]-t[0]*o;const h=(l-a)*(t[1]-o)-(o-c)*(t[0]-l);if(i=i&&h<=0,n=n&&h>=0,r>=0){for(let d=0,m=s-2,f=s>>1;d=0&&(n[o]>c||n[o]===c&&n[o+1]>l);o-=2)n[o+2]=n[o],n[o+3]=n[o+1];n[o+2]=c,n[o+3]=l}s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=n[3];let i=4;for(let a=4;a=0&&(i-=2,i!==2););s[i]=c,s[i+1]=l}s[i]=n[t-4],s[i+1]=n[t-3];const r=i;i+=2;for(let a=t-6;a>=0;a-=2,i+=2){const c=n[a],l=n[a+1];for(;(s[i-2]-s[i-4])*(l-s[i-3])-(s[i-1]-s[i-3])*(c-s[i-4])>=0&&(i-=2,i!==r););s[i]=c,s[i+1]=l}e.length=i-2}},Nn=class{attachmentLoader;scale=1;linkedMeshes=[];constructor(e){this.attachmentLoader=e}readSkeletonData(e){const t=this.scale,s=new Ae,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=M(i,"referenceScale",100)*t,s.fps=i.fps,s.imagesPath=i.images??null,s.audioPath=i.audio??null),n.bones)for(let r=0;r0&&l.properties.push(y)}l.offsets[K.ROTATION]=M(r,"rotation",0),l.offsets[K.X]=M(r,"x",0)*t,l.offsets[K.Y]=M(r,"y",0)*t,l.offsets[K.SCALEX]=M(r,"scaleX",0),l.offsets[K.SCALEY]=M(r,"scaleY",0),l.offsets[K.SHEARY]=M(r,"shearY",0);const b=l.setupPose;d&&(b.mixRotate=M(r,"mixRotate",1)),m&&(b.mixX=M(r,"mixX",1)),f&&(b.mixY=M(r,"mixY",b.mixX)),u&&(b.mixScaleX=M(r,"mixScaleX",1)),p&&(b.mixScaleY=M(r,"mixScaleY",b.mixScaleX)),g&&(b.mixShearY=M(r,"mixShearY",1)),s.constraints.push(l);break}case"path":{const l=new te(a);l.skinRequired=c;for(let m=0;m0){const d=s.findConstraint(l,ee);if(!d)throw new Error(`Physics constraint not found: ${l}`);h=s.constraints.indexOf(d)}for(const d in o){const m=o[d];let f=m[0];if(!f)continue;const u=m.length;let p,g=0;if(d==="reset"){const x=new vs(u,h);for(let b=0;f!=null;f=m[b+1],b++)x.setFrame(b,M(f,"time",0));i.push(x);continue}switch(d){case"inertia":p=new ms(u,u,h);break;case"strength":p=new gs(u,u,h);break;case"damping":p=new ps(u,u,h);break;case"mass":p=new xs(u,u,h);break;case"wind":p=new bs(u,u,h);break;case"gravity":p=new ws(u,u,h);break;case"mix":{g=1,p=new ys(u,u,h);break}default:continue}ct(i,m,p,g,1)}}if(e.slider)for(const l in e.slider){const o=e.slider[l],h=s.findConstraint(l,At);if(!h)throw new Error(`Slider not found: ${l}`);const d=s.constraints.indexOf(h);for(const m in o){const f=o[m];if(!f[0])continue;const p=f.length;switch(m){case"time":ct(i,f,new Ts(p,p,d),1,1);break;case"mix":ct(i,f,new Cs(p,p,d),1,1);break}}}if(e.attachments)for(const l in e.attachments){const o=e.attachments[l],h=s.findSkin(l);if(!h)throw new Error(`Skin not found: ${l}`);for(const d in o){const m=o[d],f=s.findSlot(d);if(!f)throw new Error(`Attachment slot not found: ${d}`);const u=f.index;for(const p in m){const g=m[p],x=h.getAttachment(u,p);if(!x)throw new Error(`Timeline attachment not found: ${p}`);for(const b in g){const w=g[b];let v=w[0];if(v){if(b==="deform"){const y=x.bones,T=x.vertices,C=y?T.length/3*2:T.length,A=new as(w.length,w.length,u,x);let k=M(v,"time",0);for(let S=0,I=0;;S++){let P;const F=M(v,"vertices",null);if(!F)P=y?V.newFloatArray(C):T;else{P=V.newFloatArray(C);const _=M(v,"offset",0);if(V.arrayCopy(F,0,P,_,F.length),n!==1)for(let D=_,Y=D+F.length;D=0;o--)r[o]===-1&&(r[o]=a[--l]);return r}function H(e,t,s,n,i,r,a,c,l,o){if(e==="stepped")return t.setStepped(n),s;const h=i<<2,d=e[h],m=e[h+1]*o,f=e[h+2],u=e[h+3]*o;return t.setBezier(s,n,i,r,c,d,m,f,u,a,l),s+1}function M(e,t,s){return e[t]!==void 0?e[t]:s}var On=class{constructor(e,t,s={}){this.skeleton=e,this.adapter=t,this.positionInheritanceFactorX=s.positionInheritanceX??0,this.positionInheritanceFactorY=s.positionInheritanceY??0,this.rotationInheritanceFactor=s.rotationInheritance??0}positionInheritanceFactorX=0;positionInheritanceFactorY=0;rotationInheritanceFactor=0;hasLastTransform=!1;lastX=0;lastY=0;lastZ=0;lastRotation=0;currentTransform={x:0,y:0,z:0,rotation:0};currentPosition={x:0,y:0,z:0};lastPosition={x:0,y:0,z:0};get positionInheritanceX(){return this.positionInheritanceFactorX}get positionInheritanceY(){return this.positionInheritanceFactorY}setPositionInheritance(e,t){const s=this.positionInheritanceFactorX===0&&this.positionInheritanceFactorY===0,n=e!==0||t!==0;this.positionInheritanceFactorX=e,this.positionInheritanceFactorY=t,s&&n&&this.resetPosition()}get rotationInheritance(){return this.rotationInheritanceFactor}set rotationInheritance(e){const t=this.rotationInheritanceFactor===0;this.rotationInheritanceFactor=e,t&&e!==0&&this.resetRotation()}resetPosition(){const e=this.currentTransform,t=!this.hasLastTransform&&this.rotationInheritanceFactor!==0;this.adapter.readTransform(e,t),this.lastX=e.x,this.lastY=e.y,this.lastZ=e.z,t&&(this.lastRotation=e.rotation),this.hasLastTransform=!0}resetRotation(){const e=this.currentTransform;this.adapter.readTransform(e,!0),this.lastRotation=e.rotation,this.hasLastTransform||(this.lastX=e.x,this.lastY=e.y,this.lastZ=e.z),this.hasLastTransform=!0}resetTransform(){const e=this.currentTransform;this.adapter.readTransform(e,!0),this.setLastTransform(e.x,e.y,e.z,e.rotation)}applyTransformMovement(){const e=this.positionInheritanceFactorX!==0||this.positionInheritanceFactorY!==0,t=this.rotationInheritanceFactor!==0;if(!e&&!t)return;const s=this.currentTransform;this.adapter.readTransform(s,t);const{x:n,y:i,z:r}=s,a=t?s.rotation:this.lastRotation,c=n!==this.lastX||i!==this.lastY||r!==this.lastZ;if(this.hasLastTransform){if(!c&&a===this.lastRotation)return;e&&c&&this.applyPositionMovement(n,i,r),t&&a!==this.lastRotation&&this.applyRotationMovement(a)}this.setLastTransform(n,i,r,a)}applyPositionMovement(e,t,s){const n=this.currentPosition;n.x=e,n.y=t,n.z=s,this.adapter.worldToSkeleton(n);const i=this.lastPosition;i.x=this.lastX,i.y=this.lastY,i.z=this.lastZ,this.adapter.worldToSkeleton(i),this.skeleton.physicsTranslate((n.x-i.x)*this.positionInheritanceFactorX,(n.y-i.y)*this.positionInheritanceFactorY)}applyRotationMovement(e){const t=this.rotationInheritanceFactor;t!==0&&this.skeleton.physicsRotate(0,0,this.getRotationDelta(e,this.lastRotation)*t)}setLastTransform(e,t,s,n){this.lastX=e,this.lastY=t,this.lastZ=s,this.lastRotation=n,this.hasLastTransform=!0}getRotationDelta(e,t){let s=e-t;return s=(s+180)%360-180,s<-180?s+360:s}},xr=class{commandPool=new br;worldVertices=new Float32Array(12*1024);quadIndices=new Uint16Array([0,1,2,2,3,0]);clipping=new ne;renderCommands=[];render(e,t=!1,s,n=2,i=0){this.commandPool.reset(),this.renderCommands.length=0;const r=this.clipping;let a=0;const c=e.drawOrder.appliedPose;for(let l=0,o=c.length;l>1;const S=m.sequence,I=S.resolveIndex(d);x=S.getUVs(I),b=m.triangles,w=b.length,y=S.regions[I]?.texture}else if(m instanceof Mt){r.clipEnd(h),r.clipStart(e,h,m);continue}else{r.clipEnd(h);continue}if(!y){r.clipEnd(h);continue}const T=e.color;let C,A;if(t){let S;if(s){S=Math.floor(s[3]*T.a*f.a*v.a*255);const I=Math.floor(S*s[0]*T.r*f.r*v.r),P=Math.floor(S*s[1]*T.g*f.g*v.g),F=Math.floor(S*s[2]*T.b*f.b*v.b);C=S<<24|I<<16|P<<8|F}else{S=Math.floor(T.a*f.a*v.a*255);const I=Math.floor(S*T.r*f.r*v.r),P=Math.floor(S*T.g*f.g*v.g),F=Math.floor(S*T.b*f.b*v.b);C=S<<24|I<<16|P<<8|F}if(A=4278190080,d.darkColor){const{r:I,g:P,b:F}=d.darkColor;A=4278190080|Math.floor(I*S)<<16|Math.floor(P*S)<<8|Math.floor(F*S)}}else{if(s){const S=Math.floor(s[3]*T.a*f.a*v.a*255),I=Math.floor(s[0]*T.r*f.r*v.r*255),P=Math.floor(s[1]*T.g*f.g*v.g*255),F=Math.floor(s[2]*T.b*f.b*v.b*255);C=S<<24|I<<16|P<<8|F}else{const S=Math.floor(T.a*f.a*v.a*255),I=Math.floor(T.r*f.r*v.r*255),P=Math.floor(T.g*f.g*v.g*255),F=Math.floor(T.b*f.b*v.b*255);C=S<<24|I<<16|P<<8|F}if(A=0,d.darkColor){const{r:S,g:I,b:P}=d.darkColor;A=Math.floor(S*255)<<16|Math.floor(I*255)<<8|Math.floor(P*255)}}r.isClipping()&&(r.clipTrianglesUnpacked(p,0,b,w,x,n),p=r.clippedVerticesTyped,g=r.clippedVerticesLength/n,x=r.clippedUVsTyped,b=r.clippedTrianglesTyped,w=r.clippedTrianglesLength);const k=this.commandPool.getCommand(g,w,n);if(k.blendMode=h.data.blendMode,k.texture=y,k.positions.set(p.subarray(0,g*n)),n>=3)for(let S=2,I=g*n;S=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),a=new Uint32Array(e),c=new Uint32Array(e),l=new Uint16Array(t);n={positions:i,uvs:r,colors:a,darkColors:c,indices:l,_positions:i,_uvs:r,_colors:a,_darkColors:c,_indices:l,numVertices:e,numIndices:t,blendMode:0,texture:null}}return this.inUse.push(n),n}reset(){this.pool.push(...this.inUse),this.inUse.length=0}};import{Assets as _n,checkExtension as Ks,copySearchParams as wr,LoaderParserPriority as yr}from"@pixi/assets";import{ALPHA_MODES as Un,BaseTexture as $n,ExtensionType as qn,extensions as vr,settings as zn,utils as Be}from"@pixi/core";import{BLEND_MODES as Xe,MIPMAP_MODES as Wn,Texture as Tr,SCALE_MODES as Gn,WRAP_MODES as Js}from"@pixi/core";var ie=class Xt extends _e{static textureMap=new Map;static from(t){return Xt.textureMap.has(t)?Xt.textureMap.get(t):new Xt(t)}texture;constructor(t){super(t.resource.source),this.texture=Tr.from(t)}setFilters(t,s){this.texture.baseTexture.scaleMode=Xt.toPixiTextureFilter(t),this.texture.baseTexture.mipmap=Xt.toPixiMipMap(t)}setWraps(t,s){this.texture.baseTexture.wrapMode=Xt.toPixiTextureWrap(t)}dispose(){this.texture.destroy()}static toPixiTextureFilter(t){switch(t){case 9728:case 9986:case 9984:return Gn.NEAREST;case 9729:case 9987:case 9985:return Gn.LINEAR;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiMipMap(t){switch(t){case 9728:case 9729:return Wn.OFF;case 9986:case 9984:case 9987:case 9985:return Wn.ON;default:throw new Error(`Unknown texture filter: ${String(t)}`)}}static toPixiTextureWrap(t){switch(t){case 33071:return Js.CLAMP;case 33648:return Js.MIRRORED_REPEAT;case 10497:return Js.REPEAT;default:throw new Error(`Unknown texture wrap: ${String(t)}`)}}static toPixiBlending(t){switch(t){case 0:return Xe.NORMAL;case 1:return Xe.ADD;case 2:return Xe.MULTIPLY;case 3:return Xe.SCREEN;default:throw new Error(`Unknown blendMode: ${String(t)}`)}}},Le="spineTextureAtlasLoader",Cr={extension:qn.Asset,resolver:{test:e=>Ks(e,".atlas"),parse:e=>{const t=e.split(".");return{resolution:parseFloat(zn.RETINA_PREFIX?.exec(e)?.[1]??"1"),format:t[t.length-2],src:e}}},loader:{name:Le,extension:{type:qn.LoadParser,priority:yr.Normal,name:Le},test(e){return Ks(e,".atlas")},async load(e){const t=await zn.ADAPTER.fetch(e);if(!t.ok)throw new Error(`[${Le}] Failed to fetch ${e}: ${t.status} ${t.statusText}`);return await t.text()},testParse(e,t){const s=Ks(t.src,".atlas"),n=typeof e=="string",i=t.loadParser===Le;return Promise.resolve((s||i)&&n)},unload(e){e.dispose()},async parse(e,t,s){const n=t.data||{};let i=Be.path.dirname(t.src);i&&i.lastIndexOf("/")!==i.length-1&&(i+="/");const r=new he(e);if(n.images instanceof $n||typeof n.images=="string"){const l=n.images;n.images={},n.images[r.pages[0].name]=l}const a=[];let c=!0;for(const l of s.parsers)if(l.name==="loadTextures"){c=l.config?.preferCreateImageBitmap;break}_n.setPreferences({preferCreateImageBitmap:!1});for(const l of r.pages){const o=l.name,h=n?.images?n.images[o]:void 0;if(h instanceof $n)l.setTexture(ie.from(h));else{const d=h??Be.path.normalize([...i.split(Be.path.sep),o].join(Be.path.sep)),m={src:wr(d,t.src),data:{...n.imageMetadata,alphaMode:l.pma?Un.PMA:Un.UNPACK}},f=s.load(m).then(u=>{l.setTexture(ie.from(u.baseTexture))});a.push(f)}}return await Promise.all(a),_n.setPreferences({preferCreateImageBitmap:c}),r}}};vr.add(Cr);import{checkExtension as Zs,LoaderParserPriority as Sr}from"@pixi/assets";import{ExtensionType as Hn,extensions as Ar,settings as Ir}from"@pixi/core";var Re="spineSkeletonLoader";function kr(e){return e.hasOwnProperty("bones")}function Mr(e){return e instanceof Uint8Array}var Pr={extension:Hn.Asset,loader:{name:Re,extension:{type:Hn.LoadParser,priority:Sr.Normal,name:Re},test(e){return Zs(e,".skel")},async load(e){const t=await Ir.ADAPTER.fetch(e);if(!t.ok)throw new Error(`[${Re}] Failed to fetch ${e}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())},testParse(e,t){const s=Zs(t.src,".json")&&kr(e),n=Zs(t.src,".skel")&&Mr(e),i=t.loadParser===Re;return Promise.resolve(s||n||i)}}};Ar.add(Pr);import{Mesh as Fr}from"@pixi/mesh";import{Buffer as js,Geometry as Yr,TYPES as Kn}from"@pixi/core";var Jn=class extends Yr{constructor(e=!1){super();const t=new js(void 0),s=new js(void 0,!0),n=new js(void 0,!0,!0);this.addAttribute("aVertexPosition",t,2,!1,Kn.FLOAT),this.addAttribute("aTextureCoord",s,2,!1,Kn.FLOAT),this.addIndex(n)}};import{Color as Ve,Matrix as Er,Program as Br,Shader as Xr,Texture as Lr,TextureMatrix as Rr}from"@pixi/core";var Vr=` attribute vec2 aVertexPosition; attribute vec2 aTextureCoord; uniform mat3 projectionMatrix; uniform mat3 translationMatrix; uniform mat3 uTextureMatrix; varying vec2 vTextureCoord; void main(void) { gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; } `,Nr=` varying vec2 vTextureCoord; uniform vec4 uColor; uniform vec4 uDarkColor; uniform sampler2D uSampler; void main(void) { vec4 texColor = texture2D(uSampler, vTextureCoord); gl_FragColor.a = texColor.a * uColor.a; gl_FragColor.rgb = ((texColor.a - 1.0) * uDarkColor.a + 1.0 - texColor.rgb) * uDarkColor.rgb + texColor.rgb * uColor.rgb; } `,Zn=class extends Xr{uvMatrix;batchable;pluginName;_tintRGB;_darkTintRGB;_colorDirty;_alpha;_tintColor;_darkTintColor;constructor(e){const t={uSampler:e??Lr.EMPTY,alpha:1,uTextureMatrix:Er.IDENTITY,uColor:new Float32Array([1,1,1,1]),uDarkColor:new Float32Array([0,0,0,0])},s={tint:16777215,darkTint:0,alpha:1,pluginName:"darkTintBatch"};super(Br.from(Vr,Nr),t),this._colorDirty=!1,this.uvMatrix=new Rr(t.uSampler),this.batchable=!0,this.pluginName=s.pluginName,this._tintColor=new Ve(s.tint),this._darkTintColor=new Ve(s.darkTint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._darkTintRGB=this._darkTintColor.toLittleEndianNumber(),this._alpha=s.alpha,this._colorDirty=!0}get texture(){return this.uniforms.uSampler}set texture(e){this.uniforms.uSampler!==e&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!e.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=e,this.uvMatrix.texture=e)}set alpha(e){e!==this._alpha&&(this._alpha=e,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(e){e!==this.tint&&(this._tintColor.setValue(e),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}set darkTint(e){e!==this.darkTint&&(this._darkTintColor.setValue(e),this._darkTintRGB=this._darkTintColor.toLittleEndianNumber(),this._colorDirty=!0)}get darkTint(){return this._darkTintColor.value}get tintValue(){return this._tintColor.toNumber()}get darkTintValue(){return this._darkTintColor.toNumber()}update(){this._colorDirty&&(this._colorDirty=!1,Ve.shared.setValue(this._tintColor).premultiply(this._alpha,!0).toArray(this.uniforms.uColor),Ve.shared.setValue(this._darkTintColor).premultiply(this._alpha,!0).premultiply(1,!1).toArray(this.uniforms.uDarkColor)),this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}},jn=class extends Fr{_darkTintRGB=0;constructor(e){super(new Jn,new Zn(e),void 0,void 0)}get darkTint(){return"darkTint"in this.shader?this.shader.darkTint:null}set darkTint(e){this.shader.darkTint=e}get darkTintValue(){return this.shader.darkTintValue}_renderToBatch(e){const t=this.geometry,s=this.shader;s.uvMatrix&&(s.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=t.indexBuffer.data,this._tintRGB=s._tintRGB,this._darkTintRGB=s._darkTintRGB,this._texture=s.texture;const n=this.material.pluginName;e.batch.setObjectRenderer(e.plugins[n]),e.plugins[n].render(this)}},Qn=class it extends jn{name="";static auxColor=[0,0,0,0];constructor(){super()}updateFromSpineData(t,s,n,i,r,a,c,l){this.texture=t.texture;const o=r/(l?12:8)*2,h=this.geometry.getBuffer("aTextureCoord");h.data?.length!==o&&(h.data=new Float32Array(o));const d=this.geometry.getBuffer("aVertexPosition");d.data?.length!==o&&(d.data=new Float32Array(o));let m=0;const f=h.data,u=d.data;for(let g=0;g0){const a=new se("custom-skin");for(const c of this.skins){const l=i.findSkin(c);l!=null&&a.addSkin(l)}s.setSkin(a)}s.setupPose();const r=this.animation!=null?i.findAnimation(this.animation):null;if(r==null){s.updateWorldTransform(2);const a=s.getBoundsRect(n);return a.width===Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:a}else{let a=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY,l=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 m=0;m0?this.timeStep:0;t.update(f),t.apply(s),s.update(f),s.updateWorldTransform(2);const u=s.getBoundsRect(n);a=Math.min(a,u.x),c=Math.min(c,u.y),l=Math.max(l,u.x+u.width),o=Math.max(o,u.y+u.height)}const d={x:a,y:c,width:l-a,height:o-c};return d.width===Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:d}}},no=class j extends jr{skeleton;state;skeletonPhysics;darkTint=!1;hasNeverUpdated=!0;_debug=void 0;get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}slotMeshFactory=()=>new ii;beforeUpdateWorldTransforms=()=>{};afterUpdateWorldTransforms=()=>{};_autoUpdate=!1;_ticker=oi.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??oi.shared,this._ticker!==t&&(this._autoUpdate&&(this._ticker.remove(this.internalUpdate,this),t.add(this.internalUpdate,this)),this._ticker=t)}meshesCache=new Map;static vectorAux=new le;static clipper=new ne;static QUAD_TRIANGLES=[0,1,2,2,3,0];static VERTEX_SIZE=8;static DARK_VERTEX_SIZE=12;lightColor=new z;darkColor=new z;clippingVertAux=new Float32Array(6);_boundsProvider;get boundsProvider(){return this._boundsProvider}set boundsProvider(t){this._boundsProvider=t,t?(this._boundsSpineID=-1,this._boundsSpineDirty=!0,this.interactiveChildren=!1):(this.interactiveChildren=!0,this.hitArea=null),this.hasNeverUpdated||this.calculateBounds()}_boundsPoint=new Jr;_boundsSpineID=-1;_boundsSpineDirty=!0;constructor(t){super(),t instanceof Ae?t={skeletonData:t}:"skeleton"in t&&(t=new.target.createOptions(t));const{autoUpdate:s=!0,boundsProvider:n,darkTint:i,skeletonData:r,ticker:a}=t;this.skeleton=new Ot(r),this.skeletonPhysics=new On(this.skeleton,{readTransform:(c,l)=>this.readPhysicsTransform(c,l),worldToSkeleton:c=>this.pixiWorldCoordinatesToSkeleton(c)}),this.state=new Ss(new yn(r)),a&&(this._ticker=a),this.autoUpdate=s,this.boundsProvider=n,this.darkTint=i===void 0?this.skeleton.slots.some(c=>!!c.data.setupPose.darkColor):i,this.darkTint&&(this.slotMeshFactory=()=>new Qn)}update(t){this.internalUpdate(0,t)}internalUpdate(t,s){this.hasNeverUpdated=!1;const n=s??this._ticker.deltaMS/1e3;this.state.update(n),this.state.apply(this.skeleton),this.skeletonPhysics.applyTransformMovement(),this.beforeUpdateWorldTransforms(this),this.skeleton.update(n),this.skeleton.updateWorldTransform(2),this.afterUpdateWorldTransforms(this)}readPhysicsTransform(t,s){const n=this.worldTransform;if(t.x=n.tx,t.y=n.ty,t.z=0,!s)return;let i=0;for(let r=this;r;r=r.parent)i+=r.rotation+(r.skew.y-r.skew.x)/2;t.rotation=i*180/Math.PI}updateTransform(){this.renderMeshes(),this.sortChildren(),this.debug?.renderDebug(this),super.updateTransform()}destroy(t){this.autoUpdate&&(this.autoUpdate=!1),this._ticker=null;for(const[,s]of this.meshesCache)s?.destroy();this.state.clearListeners(),this.debug=void 0,this.meshesCache.clear(),this.slotsObject.clear();for(const s in this.clippingSlotToPixiMasks)this.clippingSlotToPixiMasks[s].destroy(),delete this.clippingSlotToPixiMasks[s];super.destroy(t)}unloadFromCache(){const t=this.skeleton?.data;if(!t)return!1;const s=j.skeletonDataCacheKeys.get(t);return!s||j.skeletonCache[s]!==t?!1:(delete j.skeletonCache[s],j.skeletonDataCacheKeys.delete(t),!0)}resetMeshes(){for(const[,t]of this.meshesCache)t.zIndex=-1,t.visible=!1}_calculateBounds(){this.hasNeverUpdated&&(this.internalUpdate(0,0),this.renderMeshes())}hasMeshForSlot(t){return this.meshesCache.has(t)}getMeshForSlot(t){let s=this.hasMeshForSlot(t)?this.meshesCache.get(t):null;return s?s.visible=!0:(s=this.slotMeshFactory(),this.addChild(s),this.meshesCache.set(t,s)),s}slotsObject=new Map;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}addSlotObject(t,s,n){const i=this.getSlotFromRef(t),r=this.slotsObject.get(i)?.container;if(!(r&&r===s)){for(const[a,{container:c}]of this.slotsObject)if(a!==i&&c===s){this.removeSlotObject(a,s);break}r&&this.removeChild(r),this.slotsObject.set(i,{container:s,followAttachmentTimeline:n?.followAttachmentTimeline||!1,followSlotColor:n?.followSlotColor||!1}),this.addChild(s)}}getSlotObject(t){const s=this.slotsObject.get(this.getSlotFromRef(t));return s?s.container:void 0}removeSlotObject(t,s){const n=this.getSlotFromRef(t),i=this.slotsObject.get(n)?.container;i&&(s&&s!==i||(this.removeChild(i),this.slotsObject.delete(n)))}removeSlotObjects(){for(const[,t]of this.slotsObject)t.container.removeFromParent();this.slotsObject.clear()}verticesCache=V.newFloatArray(1024);clippingSlotToPixiMasks={};pixiMaskCleanup(t){const s=this.clippingSlotToPixiMasks[t.data.name];s&&(delete this.clippingSlotToPixiMasks[t.data.name],s.destroy())}updateSlotObject(t,s,n){const{container:i,followAttachmentTimeline:r}=t,a=s.appliedPose,c=r?!!a.attachment:!0,l=this.skeleton.drawOrder.appliedPose;if(i.visible=l.includes(s)&&c,i.visible){const o=s.bone.appliedPose,h=i.localTransform;h.a=o.a,h.b=o.c,h.c=-o.b,h.d=-o.d,h.tx=o.worldX,h.ty=o.worldY,i.transform.setFromMatrix(h),i.zIndex=n+1,i.alpha=this.skeleton.color.a*a.color.a,t.followSlotColor&&this.setSlotObjectTint(i,255*this.skeleton.color.r*a.color.r<<16|255*this.skeleton.color.g*a.color.g<<8|255*this.skeleton.color.b*a.color.b)}}setSlotObjectTint(t,s){const n=t;"tint"in n&&(n.tint=s);for(const i of n.children??[])this.setSlotObjectTint(i,s)}updateAndSetPixiMask(t,s){if(j.clipper.isClipping()&&t){let n=this.clippingSlotToPixiMasks[t.slot.data.name];if(n||(n=new Qr,this.clippingSlotToPixiMasks[t.slot.data.name]=n,this.addChild(n)),!t.computed){t.computed=!0;const i=t.slot.appliedPose.attachment,r=i.worldVerticesLength;this.clippingVertAux.length>1)*u,b>this.verticesCache.length&&(this.verticesCache=V.newFloatArray(b)),v.computeWorldVertices(w,o,0,v.worldVerticesLength,this.verticesCache,0,u),t=v.triangles;const y=p.sequence,T=y.resolveIndex(m);s=y.getUVs(T),x=y.regions[T]?.texture}else if(p instanceof Mt){j.clipper.clipStart(w,o,p),n={slot:o,computed:!1};continue}else{this.hasMeshForSlot(o)&&(this.getMeshForSlot(o).visible=!1),j.clipper.clipEnd(o),this.pixiMaskCleanup(o);continue}if(x!=null){const v=w.color,y=m.color,T=v.a*y.a*g.a;this.lightColor.set(v.r*y.r*g.r,v.g*y.g*g.g,v.b*y.b*g.b,T),m.darkColor!=null?this.darkColor.set(m.darkColor.r,m.darkColor.g,m.darkColor.b,1):this.darkColor.set(0,0,0,1);let C,A,k,S;if(j.clipper.isClipping()&&j.clipper.clipTriangles(this.verticesCache,t,t.length,s,this.lightColor,this.darkColor,f,u))C=j.clipper.clippedVertices,A=C.length,k=j.clipper.clippedTriangles,S=k.length;else{const P=this.verticesCache;for(let F=2,B=0,X=b;F{if(this.drawEvents){const i=Math.abs(e.scale.x||e.scale.y||1),r=new io(n.data.name,{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,baseTexture:!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,a=i.y,c=i.bones;t.skeletonXY.lineStyle(s,this.skeletonXYColor,1);for(let o=0,h=c.length;og&&pg&&p>x?F=-S:ux?F=S:p===x&&ug?F=-90*k:u===g&&px&&(F=0),I.rotation=F,I.lineStyle(s+P/2.4,this.bonesColor,1),I.beginFill(0,.6),I.drawCircle(0,C,P*1.2),I.endFill()}const l=s*3;t.skeletonXY.moveTo(r-l,a-l),t.skeletonXY.lineTo(r+l,a+l),t.skeletonXY.moveTo(r+l,a-l),t.skeletonXY.lineTo(r-l,a+l)}drawRegionAttachmentsFunc(e,t,s){const i=e.skeleton.slots;t.regionAttachmentsShape.lineStyle(s,this.regionAttachmentsColor,1);for(let r=0,a=i.length;r0){m=(m>>1)*2;let f=h[m-2],u=h[m-1];for(let p=0,g=m;p{if(t.boundingBoxesPolygon.lineStyle(s,this.boundingBoxesPolygonColor,1),t.boundingBoxesPolygon.beginFill(this.boundingBoxesPolygonColor,.1),l<3)throw new Error("Polygon must contain at least 3 vertices");const o=[],h=s*2;for(let d=0,m=a.length;d