@canvasengine/presets 2.0.0-beta.52 → 2.0.0-beta.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FogOfWar.d.ts +38 -0
- package/dist/FogOfWar.d.ts.map +1 -0
- package/dist/NightAmbiant.d.ts +0 -2
- package/dist/NightAmbiant.d.ts.map +1 -1
- package/dist/Weathers/fog.d.ts.map +1 -1
- package/dist/Weathers/index.d.ts +376 -0
- package/dist/Weathers/index.d.ts.map +1 -1
- package/dist/Weathers/rain.d.ts.map +1 -1
- package/dist/Weathers/snow.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +228 -134
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2635 -2274
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
var CanvasEnginePresets=(function(At,D,P){"use strict";function ii(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const e in h)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(h,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>h[e]})}}return t.default=h,Object.freeze(t)}const xt=ii(P);function te(h){var t=h.toString(16);return t.length==1?"0"+t:t}function ri(h,t,e){return"#"+te(h)+te(t)+te(e)}function si(h){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:l,border:o,innerMargin:y,borderRadius:C}=D.useProps(h,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...h,width:t,height:e,draw(v){C()?v.roundRect(0,0,t(),e(),C()):v.rect(0,0,t(),e()),o&&v.stroke(o),v.fill(c())}},D.h(D.Graphics,{width:t,height:e,draw(v){const B=y(),A=C(),I=Math.max(0,Math.min(t()-2*B,i()/s()*(t()-2*B))),M=e()-2*B;C?v.roundRect(B,B,I,M,A):v.rect(B,B,I,M);const N=l();if(N.startsWith("rgba")){const[O,_,E,m]=N.match(/\d+(\.\d+)?/g).map(Number);v.fill({color:ri(O,_,E),alpha:m})}else v.fill(N)}}))}class Ht{constructor(){this.__length=0}get length(){return this.__length}add(t){return this.first==null?this.first=this.last=t:(t.prev=this.last,this.last.next=t,this.last=t),t.list=this,this.__length++,this}remove(t){if(t.list!=null)return this.first===this.last?this.first=this.last=null:this.__length>0&&(t===this.last?(t.prev.next=null,this.last=t.prev):t===this.first?(t.next.prev=null,this.first=t.next):(t.next.prev=t.prev,t.prev.next=t.next)),t.next=t.prev=t.list=null,this.__length--,this}clear(){if(!this.first)return;let t=this.first;for(;t;){let e=t.next;t.next=t.prev=t.list=null,t=e}this.first=this.last=null}toArray(){const t=[];if(!this.first)return t;let e=this.first;for(;e;)t.push(e),e=e.next;return t}}class Pt{constructor(t){this.data=t}update(t){}dispose(){}}class Se extends Pt{constructor(t){super(),this.componentId=t,this.exhausted=!1,this.completed=!1,this.name="",this.endTime=0,this._x=0,this._y=0,this._rotation=0,this._alpha=0,this._scale=new xt.Point,this._time=0,this._active=!1,this.__recycled=!0}update(t){}recycle(){}get active(){return this._active}get scale(){return this._scale}set scale(t){this._scale=t}get alpha(){return this._alpha}set alpha(t){this._alpha=t}set rotation(t){this._rotation=t}get rotation(){return this._rotation}get y(){return this._y}set y(t){this._y=t}get x(){return this._x}set x(t){this._x=t}__applySettings(t){}}var ee;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip"})(ee||(ee={}));class ie{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class Y{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Yt;(function(h){h.Circle="circle",h.Box="box",h.Ring="ring"})(Yt||(Yt={}));class ni extends ie{constructor(){super(Yt.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let l=i.rotation;const o=Y.float(-s,s),y=Y.float(-c,c);l!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+o*Math.cos(l)-y*Math.sin(l),t.component.y=this.__y+this._t*(this.y-this.__y)+o*Math.sin(l)+y*Math.cos(l)):(t.component.x=this.__x+this._t*(this.x-this.__x)+o,t.component.y=this.__y+this._t*(this.y-this.__y)+y),e.radial?(l+=Math.atan2(y,o),t.dx=Math.cos(l),t.dy=Math.sin(l)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=l,this._t+=this._posInterpolationStep}}class ai extends ie{constructor(){super(Yt.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=Y.float(-e.angle*.5,e.angle*.5)+i.rotation:s=Y.float(0,6.28319)+i.rotation,e.radius>0){let c=Y.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c}else t.component.x=this.__x+this._t*(this.x-this.__x),t.component.y=this.__y+this._t*(this.y-this.__y);e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class oi extends ie{constructor(){super(Yt.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=Y.float(-e.angle*.5,e.angle*.5)+i.rotation;const c=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c,e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var St;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(St||(St={}));class li extends xt.AnimatedSprite{constructor(t,e,i,s){let c=[],l=e.length;for(let o=0;o<l;o++)c.push(xt.Texture.from(e[o]));super(c),this.componentId=t,this.anchor.set(.5,.5),this.loop=!1,this.__sequenceEndTime=0}recycle(){this.alpha=1,this.tint=16777215,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.__fx.__recycleMovieClip(this.componentId,this)}dispose(){this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.destroy()}}class ci{constructor(){}setRgb(t,e){this.startRgb=this.rgb=t,this.r=this.sR=t>>16&255,this.g=this.sG=t>>8&255,this.b=this.sB=t&255,this.targetRgb=e,this.dR=(e>>16&255)-this.r,this.dG=(e>>8&255)-this.g,this.dB=(e&255)-this.b}tween(t,e,i){return t?(this.r=t(e,this.sR,this.dR,i),this.g=t(e,this.sG,this.dG,i),this.b=t(e,this.sB,this.dB,i)):(e/=i,this.r=this.dR*e+this.sR,this.g=this.dG*e+this.sG,this.b=this.dB*e+this.sB),this.rgb=this.r<<16|this.g<<8|this.b,this.rgb}}var Ce;(function(h){h.Linear="linear",h.EaseInQuad="easeInQuad",h.EaseOutQuad="easeOutQuad",h.EaseInOutQuad="easeInOutQuad",h.EaseInCubic="easeInCubic",h.EaseOutCubic="easeOutCubic",h.EaseInOutCubic="easeInOutCubic",h.EaseInQuart="easeInQuart",h.EaseOutQuart="easeOutQuart",h.EaseInOutQuart="easeInOutQuart",h.EaseInQuint="easeInQuint",h.EaseOutQuint="easeOutQuint",h.EaseInOutQuint="easeInOutQuint",h.EaseInSine="easeInSine",h.EaseOutSine="easeOutSine",h.EaseInOutSine="easeInOutSine",h.EaseInExpo="easeInExpo",h.EaseOutExpo="easeOutExpo",h.EaseInOutExpo="easeInOutExpo",h.EaseInCirc="easeInCirc",h.EaseOutCirc="easeOutCirc",h.EaseInOutCirc="easeInOutCirc",h.EaseInElastic="easeInElastic",h.EaseOutElastic="easeOutElastic",h.EaseInOutElastic="easeInOutElastic",h.EaseInBack="easeInBack",h.EaseOutBack="easeOutBack",h.EaseInOutBack="easeInOutBack",h.EaseInBounce="easeInBounce",h.EaseOutBounce="easeOutBounce",h.EaseInOutBounce="easeInOutBounce"})(Ce||(Ce={}));class vt{static linear(t,e,i,s){return i*t/s+e}static easeInQuad(t,e,i,s){return i*(t/=s)*t+e}static easeOutQuad(t,e,i,s){return-i*(t/=s)*(t-2)+e}static easeInOutQuad(t,e,i,s){return(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,s){return i*(t/=s)*t*t+e}static easeOutCubic(t,e,i,s){return i*((t=t/s-1)*t*t+1)+e}static easeInOutCubic(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,s){return i*(t/=s)*t*t*t+e}static easeOutQuart(t,e,i,s){return-i*((t=t/s-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,s){return i*(t/=s)*t*t*t*t+e}static easeOutQuint(t,e,i,s){return i*((t=t/s-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}static easeInSine(t,e,i,s){return-i*Math.cos(t/s*(Math.PI/2))+i+e}static easeOutSine(t,e,i,s){return i*Math.sin(t/s*(Math.PI/2))+e}static easeInOutSine(t,e,i,s){return-i/2*(Math.cos(Math.PI*t/s)-1)+e}static easeInExpo(t,e,i,s){return t===0?e:i*Math.pow(2,10*(t/s-1))+e}static easeOutExpo(t,e,i,s){return t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}static easeInOutExpo(t,e,i,s){return(t/=s/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e}static easeInCirc(t,e,i,s){return-i*(Math.sqrt(1-(t/=s)*t)-1)+e}static easeOutCirc(t,e,i,s){return i*Math.sqrt(1-(t=t/s-1)*t)+e}static easeInOutCirc(t,e,i,s){return(t/=s/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}static easeInElastic(t,e,i,s){let c,l,o;return o=1.70158,l=0,c=i,t===0||(t/=s),l||(l=s*.3),c<Math.abs(i)?(c=i,o=l/4):o=l/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/l))+e}static easeOutElastic(t,e,i,s){let c,l,o;return o=1.70158,l=0,c=i,t===0||(t/=s),l||(l=s*.3),c<Math.abs(i)?(c=i,o=l/4):o=l/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/l)+i+e}static easeInOutElastic(t,e,i,s){let c,l,o;return o=1.70158,l=0,c=i,t===0||(t/=s/2),l||(l=s*.44999999999999996),c<Math.abs(i)?(c=i,o=l/4):o=l/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/l))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/l)*.5+i+e}static easeInBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*(t/=s)*t*((c+1)*t-c)+e}static easeOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*((t=t/s-1)*t*((c+1)*t+c)+1)+e}static easeInOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),(t/=s/2)<1?i/2*(t*t*(((c*=1.525)+1)*t-c))+e:i/2*((t-=2)*t*(((c*=1.525)+1)*t+c)+2)+e}static easeInBounce(t,e,i,s){let c;return c=vt.easeOutBounce(s-t,0,i,s),i-c+e}static easeOutBounce(t,e,i,s){return(t/=s)<.36363636363636365?i*(7.5625*t*t)+e:t<.7272727272727273?i*(7.5625*(t-=.5454545454545454)*t+.75)+e:t<.9090909090909091?i*(7.5625*(t-=.8181818181818182)*t+.9375)+e:i*(7.5625*(t-=.9545454545454546)*t+.984375)+e}static easeInOutBounce(t,e,i,s){let c;return t<s/2?(c=vt.easeInBounce(t*2,0,i,s),c*.5+e):(c=vt.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class mt{constructor(){this.__hasCallback=!1,this._list=new Ht}add(t,e,i){this._list.add(new Pt(new Be(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Pt(new Be(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const l=i.data;l.callRate&&l.calls%l.callRate!=0&&(c=!1),c&&(l.callback.apply(l.scope,t),l.once&&e.remove(i)),i=s}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,s;for(;i;){if(s=i.next,i.data.callback===t){e.remove(i);return}i=s}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Be{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let ui=class extends Pt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new mt,bounced:new mt,updated:new mt},this._color=new ci}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const l=this.duration=Y.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(s):t.container.addChildAt(s,0),s.blendMode=c.__getBlendMode(e.blendMode),this.startX=s.x,this.startY=s.y,this.useGravity=t.settings.useGravity,this.useScale=e.useScale,this.useRotation=e.useRotation,this.useAlpha=e.useAlpha,this.useTint=e.useTint,this.useSpawns=e.useSpawns,this.useChilds=e.useChilds,this.useMotion=e.useMotion,this.useGravity)if(this.gravity=t.settings.gravity,this.useFloor=t.settings.useFloor,this.floorY=t.settings.floorY,this.bounceFac=Y.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-Y.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=Y.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=o*this.dx*i,this.moveSpeedY=o*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const o=this.distance=Y.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+o*this.dx-this.startX)*.8,this.deltaY=(s.y+o*this.dy-this.startY)*.8,this.distanceEase=vt[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=Y.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=Y.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=Y.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=vt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=l*(1-e.fadeInDurationFac),this.fadeInDuration=l*e.fadeInDurationFac,this.fadeInEase=vt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=vt[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=Y.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(Y.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=Y.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(Y.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=vt[e.scaleXEase],this.scaleYStart=s.scale.y=Y.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(Y.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=vt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=l*(1-e.scaleInDurationFac),this.scaleInDuration=l*e.scaleInDurationFac,this.scaleInEase=vt[e.scaleInEase||"easeInSine"])):e.uniformScale?(s.scale.x=e.scaleStartMin,s.scale.y=e.scaleStartMin):(s.scale.x=e.scaleXStartMin,s.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=Y.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=Y.sign())),e.useTint&&(this.tintEase=vt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let o=e.childs.length;if(this._hasChildEmitters=o>0,this._childEmitters)for(;--o>-1;){const y=e.childs[o],C=c.getParticleEmitterById(y.id);C.init(t.container,!0,(y.scale||1)*(i||1)),y.adoptRotation&&(C.rotation=s.rotation,C.__adoptRotation=!0),C.__parent=this,this._childEmitters.push(C)}}return e.useSpawns&&(e.spawn.onStart.length>0&&t.__subSpawn(this,e.spawn.onStart),this._spawnOnHalfway=e.spawn.onHalfway.length>0),t.__on.particleSpawned.__hasCallback&&t.__on.particleSpawned.dispatch(this),this}update(t){const e=this.time+=t,i=this.duration;if(e>=i){this.emitter.__removeParticle(this);return}const s=this.component,c=e*t;if(this.useGravity){const l=t/.0166666;if(s.x+=this.moveSpeedX*l,s.y+=this.moveSpeedY*l,this.moveSpeedY+=this.gravity*l,this.useAlign&&(s.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&s.y>this.floorY){s.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const o=this.emitter;o.__on.particleBounced.__hasCallback&&o.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&o.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(s.x=this.distanceEase(e,this.startX,this.deltaX,i),s.y=this.distanceEase(e,this.startY,this.deltaY,i)):(s.x=this.deltaX*c+this.startX,s.y=this.deltaY*c+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?s.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):s.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?s.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):s.alpha=this.alphaDelta*c+this.alphaStart),this.useRotation&&(s.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?s.scale.x=s.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):s.scale.x=s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(s.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),s.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):s.scale.x=s.scale.y=this.scaleDelta*c+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(s.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),s.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(s.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?s.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):s.scale.x=this.scaleXDelta*c+this.scaleXStart,this.scaleYEase?s.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):s.scale.y=this.scaleYDelta*c+this.scaleYStart)),this.useTint&&(s.tint=this._color.tween(this.tintEase,e,i)),this._spawnOnHalfway&&e>=.5&&(this._spawnOnHalfway=!1,this.emitter.__subSpawn(this,this.settings.spawn.onHalfway)),this.useChilds&&this._hasChildEmitters){const l=this._childEmitters;let o=l.length;for(;--o>-1;){const y=l[o];y.__recycled||(y.x=s.position.x,y.y=s.position.y,y.__adoptRotation&&(y.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class Ct{static sanitizeBundle(t){for(let e of t.emitters){const i=Ct._presetStructure.emitter;Ct.parse(e,i,Ct._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=Ct._presetStructure.sequence;Ct.parse(e,i,Ct._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let s in e)if(t[s]==null)t[s]=e[s];else{const c=t[s];if(typeof c!="object")continue;const l=e[s];if(!c.hasOwnProperty("length"))Ct.parse(c,l,i);else for(let o of c)for(let y in i)o[y]==null&&(o[y]=i[y])}}}Ct._presetStructure={sequence:{id:0,name:"",type:1,delay:0,scaleMin:1,scaleMax:1,effects:[]},sequenceEffect:{id:0,componentId:null,componentType:0,delay:0,componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},scaleMin:1,scaleMax:1,alphaMin:1,alphaMax:1,rotationMin:0,rotationMax:0,blendMode:0,duration:.1,tint:16777215,containerId:"",triggerValue:""},emitter:{id:0,name:"",type:0,core:{type:"circle",params:{radius:100,radial:!0,angle:6.28318530718,uniform:!1,width:100,height:100}},spawnFrequencyMin:.1,spawnFrequencyMax:.1,maxParticles:1e3,spawnCountMin:1,spawnCountMax:1,duration:0,infinite:!0,useGravity:!1,gravity:0,useFloor:!1,floorY:700,rotation:0,autoRotation:0,particleSettings:{componentType:0,componentId:"",componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},durationMin:1,durationMax:2,distanceMin:0,distanceMax:0,distanceEase:"linear",moveSpeedMin:0,moveSpeedMax:0,bounceFacMin:0,bounceFacMax:0,frictionMin:0,frictionMax:0,useMotion:!1,useRotation:!1,useAlpha:!1,useScale:!1,useTint:!1,useChilds:!1,useSpawns:!1,stopOnBounce:!1,align:!1,blendMode:1,addOnTop:!0,rotationSpeedMin:0,rotationSpeedMax:0,randomRotationDirection:!1,randomStartRotation:!1,fadeIn:!0,fadeInDurationFac:.1,fadeInEase:"linear",alphaStartMin:.7,alphaStartMax:.9,alphaEndMin:.7,alphaEndMax:.8,alphaEase:"linear",tintStart:16777215,tintEnd:16777215,tintEase:"linear",scaleIn:!1,scaleInDurationFac:.2,scaleInEase:"linear",uniformScale:!0,scaleXStartMin:1,scaleXStartMax:1,scaleXEndMin:1,scaleXEndMax:1,scaleXEase:"linear",scaleYStartMin:1,scaleYStartMax:1,scaleYEndMin:1,scaleYEndMax:1,scaleYEase:"linear",scaleStartMin:1,scaleStartMax:1,scaleEndMin:1,scaleEndMax:1,scaleEase:"linear",childs:[],spawn:{onComplete:[],onBounce:[],onHalfway:[],onStart:[]}},childs:[]},emitterSpawn:{type:0,id:0,scale:1,adoptRotation:!0,containerId:""}};class hi extends xt.Sprite{constructor(t,e,i,s){super(xt.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,s||.5),this.__sequenceEndTime=null}recycle(){this.tint=16777215,this.alpha=1,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.__fx.__recycleSprite(this.componentId,this)}dispose(){this.__fx=null,this.recycle(),this.destroy(!1)}}function Ut(h){if(typeof h!="object"||h===null)return h;const t=Array.isArray(h)?[]:{};for(const e in h){const i=h[e];t[e]=Ut(i)}return t}var fi=function(h,t,e,i){function s(c){return c instanceof e?c:new e(function(l){l(c)})}return new(e||(e=Promise))(function(c,l){function o(v){try{C(i.next(v))}catch(B){l(B)}}function y(v){try{C(i.throw(v))}catch(B){l(B)}}function C(v){v.done?c(v.value):s(v.value).then(o,y)}C((i=i.apply(h,t||[])).next())})};class Et{constructor(){this.useBlendModes=!0,this.particleCount=0,this.emitterCount=0,this.effectSequenceCount=0,this.maxParticles=5e3,this.particleFac=1,this._active=!1,this._effects=new Ht,this.__containers={},this.clearCache(),this.start()}start(){this._active=!0,this._timeElapsed=Date.now()}pause(){this._active=!1}update(t=1){if(!this.active)return;const e=Date.now();let i=(e-this._timeElapsed)*.001;i*=t;let c=this._effects.first,l;for(;c;)l=c.next,c.update(i),c=l;this._timeElapsed=e}clearCache(){this._cache={particles:[],mcs:[],sprites:[],effectSequences:[],emitters:[],cores:{}},this._settingsCache={mcs:{},sprites:{},emitters:{},effectSequences:{}},this._nameMaps={emitters:{},effectSequences:{}}}setFloorY(t){const e=this._settingsCache.emitters;for(let i in e)e[i].floorY=t}dispose(){let t=this._effects,e=t.first;for(;e;)e.dispose(),e=e.next;t.clear(),this.clearCache()}loadBundleFiles(t,e,i="",s=[]){return new Promise((c,l)=>fi(this,void 0,void 0,function*(){const o={rfx_spritesheet:e,rfx_bundleSettings:t};for(var y in s)o[y]=s[y];xt.Assets.addBundle("rfx_assets",o);const C=yield xt.Assets.loadBundle("rfx_assets");c(this.initBundle(C.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==Et._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=Et.settingsVersion)throw new Error("Settings version mismatch.");Ct.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const s=t.emitters[i];this.addParticleEmitter(s.id,s)}for(let i in t.sequences){const s=t.sequences[i];this.addEffectSequence(s.id,s)}return this.useBlendModes=t.useBlendModes,this.maxParticles=t.maxParticles,this.parseTextureCache(t.spritesheetFilter)}addParticleEmitter(t,e){if(this._settingsCache.emitters[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.emitters[t]=e,this._nameMaps.emitters[e.name]=e,this}addEffectSequence(t,e){if(this._settingsCache.effectSequences[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.effectSequences[t]=e,this._nameMaps.effectSequences[e.name]=e,this}initSprite(t,e){if(this._settingsCache.sprites[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.sprites[t]=e,this}initMovieClip(t,e){if(this._settingsCache.mcs[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.mcs[t]=e,this}getMovieClips(){return this._settingsCache.mcs}getSprites(){return this._settingsCache.sprites}addContainer(t,e){this.__containers[t]=e}getEffectSequence(t,e=!1){const i=this._nameMaps.effectSequences[t];if(!i)throw new Error(`Settings not defined for '${t}'`);return this.getEffectSequenceById(i.id,e)}getEffectSequenceById(t,e=!1){const i=this._cache.effectSequences;let s,c=this._settingsCache.effectSequences[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(s=new Me(t),s.__fx=this):s=i.pop(),e&&(c=Ut(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,l=this._settingsCache.emitters[t];if(!l)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new re(t),c.__fx=this):c=s.pop(),i&&(l=Ut(l),l.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(l),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new re(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Me(t.id),i.__fx=this):i=e.pop(),i.__applySettings(t),i}stopEmitter(t,e=!1){t.list===this._effects&&this._effects.remove(t),e?t.dispose():this.__recycleEmitter(t)}stopAllEffects(){const t=this._effects.toArray();for(let e of t)e.recycle()}parseSpriteSheet(t,e){return this.parseObject(t.data.frames,e)}parseTextureCache(t){return this.parseObject(xt.Cache._cache,t)}get active(){return this._active}__addActiveEffect(t){this._effects.add(t)}__removeActiveEffect(t){this._effects.remove(t)}__getSprite(t){const e=this._cache.sprites;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){const s=this._settingsCache.sprites[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new hi(t,s.texture,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getMovieClip(t){const e=this._cache.mcs;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){let s=this._settingsCache.mcs[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new li(t,s.textures,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new ui;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,s=i[t];return s==null&&(s=i[t]=[]),s.length==0?new Et.__emitterCores[t](t):s.pop()}__recycleParticle(t){this._cache.particles.push(t)}__recycleSprite(t,e){this._cache.sprites[t].push(e)}__recycleMovieClip(t,e){this._cache.mcs[t].push(e)}__recycleEmitter(t){this._effects.remove(t),this.__recycleEmitterCore(t.core),this._cache.emitters.push(t)}__recycleEffectSequence(t){this._effects.remove(t),this._cache.effectSequences.push(t)}__recycleEmitterCore(t){this._cache.cores[t.type].push(t)}__getBlendMode(t){return xt.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?Et._blendModes[t]:"normal":t}__getSequenceSettings(t){let e=this._settingsCache.effectSequences[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}__getEmitterSettings(t){let e=this._settingsCache.emitters[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}parseObject(t,e){let i;if(t instanceof Map){i=new Map;const l=t;l.values();for(const[o,y]of l)y instanceof xt.Texture&&(i[o]=y)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let l in i)if(!(e&&l.indexOf(e)==-1)&&(this.initSprite(l,{texture:l,anchorX:.5,anchorY:.5}),c.sprites.push(l),l.substr(0,3)=="mc_")){const y=l.split("_")[1];s[y]==null&&(s[y]=[]),s[y].push(l)}for(let l in s){let o=s[l];c.movieClips.push(l),this.initMovieClip(l,{textures:o,anchorX:.5,anchorY:.5})}return c}}Et.settingsVersion=0,Et.version="1.3.4",Et._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",Et.ComponentType=ee,Et.EffectSequenceComponentType=St,Et._blendModes=["normal","add","multiply","screen"],Et.__emitterCores={circle:ai,box:ni,ring:oi};var Lt;(function(h){h[h.ParticleEmitter=0]="ParticleEmitter",h[h.EffectSequence=1]="EffectSequence"})(Lt||(Lt={}));class re extends Se{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new Ht,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new mt,completed:new mt,exhausted:new mt,particleUpdated:new mt,particleSpawned:new mt,particleBounced:new mt,particleDied:new mt}}init(t,e=!0,i=1){return this.container=t,this.core.__scaleMod=this._scaleMod=i,e&&this.start(),this}start(){if(this._active)return this;const t=Date.now(),e=this.settings,i=this.__fx;i.emitterCount++,this.infinite=e.infinite,this._time=Number.MAX_VALUE,e.duration>0?this.endTime=t+e.duration*1e3:this.endTime=e.duration,this._nextSpawnTime=0,this._particleCount=0,this._active=!0,this.exhausted=this.completed=!1,i.__addActiveEffect(this);let s=e.childs.length;if(this._hasChildEmitters=s>0,this._hasChildEmitters)for(;--s>-1;){const c=e.childs[s],l=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[l.settings.containerId]||this.container;l.init(o,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(l.rotation=this._rotation,l.__adoptRotation=!0),l.__parent=this,this._childEmitters.push(l)}return this.rotation=this._rotation,this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this}stop(t=!0){t?(this.exhausted=!0,this._hasChildEmitters&&this.stopChildEmitters(!0)):(this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.autoRecycleOnComplete?this.recycle():(this.recycleParticles(),this.completed=!0,this._active=!1,this.__fx.__removeActiveEffect(this)))}update(t){if(!this._active)return this;const e=Date.now(),i=this.settings;this.exhausted?this._particleCount==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.__fx.__removeActiveEffect(this),this.autoRecycleOnComplete&&this.recycle()):(this.settings.autoRotation!==0&&(this.rotation+=i.autoRotation*(t/.016666)),this.target&&(this.rotation=this.target.rotation,this.targetOffset==0?(this.x=this.target.x,this.y=this.target.y):(this.x=this.target.x+Math.cos(this._rotation)*this.targetOffset,this.y=this.target.y+Math.sin(this._rotation)*this.targetOffset)),this.endTime==0&&!this.infinite?(this.spawn(),this.exhausted=!0):this.infinite||e<this.endTime?(this._time+=t,this._time>=this._nextSpawnTime&&(this._time=0,this.spawn(),this._nextSpawnTime=this._time+Y.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,l;for(;c;)l=c.next,c.update(t),c=l;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=Y.integer(t.spawnCountMin,t.spawnCountMax)*e.particleFac;for(this.core.prepare(i);--i>-1;){if(this._particleCount>=t.maxParticles||e.particleCount>=e.maxParticles)return this;const s=t.particleSettings,c=e.__getParticle();let l;switch(s.componentType){case 0:c.componentId=s.componentId,l=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,l=e.__getMovieClip(c.componentId),s.componentParams&&(l.loop=!(s.componentParams.loop==null||!s.componentParams.loop),l.animationSpeed=Y.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),l.gotoAndPlay(0);break}l.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=l,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=Y.float(t.spawnFrequencyMin,t.spawnFrequencyMax),this}recycle(){if(this.__recycled)return;this.__parent&&(this.__parent.__removeChildEmitter(this),this.__parent=void 0),this.recycleParticles(),this.settings=void 0,this._active=!1,this._paused=!1,this.completed=!0,this._x=this._y=this._rotation=0,this._hasChildEmitters&&(this.stopChildEmitters(!0),this._childEmitters.length=0,this._hasChildEmitters=!1),this.__fx.emitterCount--,this.__fx.__recycleEmitter(this),this.__recycled=!0,this.__adoptRotation=!1,this.core=null,this.target=null,this.name=null;const t=this.__on;t.completed.__hasCallback&&t.completed.removeAll(),t.started.__hasCallback&&t.started.removeAll(),t.exhausted.__hasCallback&&t.exhausted.removeAll(),t.particleBounced.__hasCallback&&t.particleBounced.removeAll(),t.particleDied.__hasCallback&&t.particleDied.removeAll(),t.particleSpawned.__hasCallback&&t.particleSpawned.removeAll(),t.particleUpdated.__hasCallback&&t.particleUpdated.removeAll()}dispose(){const t=this._particles;let e=t.first,i;for(;e;)i=e.next,e.recycle(),e=i;t.clear(),this.__recycled=!0,this._hasChildEmitters&&this.stopChildEmitters(!1),this.__fx.particleCount-=this._particleCount,this._particles=null,this.componentId=null,this.settings=null,this._active=!1,this.completed=!0,this._childEmitters=null,this.core&&this.core.dispose(),this.core=null,this.target=null,this.name=null;const s=this.__on;s.completed.removeAll(),s.started.removeAll(),s.exhausted.removeAll(),s.particleBounced.removeAll(),s.particleDied.removeAll(),s.particleSpawned.removeAll(),s.particleUpdated.removeAll(),this.__parent=null,this.__fx.__removeActiveEffect(this),this.__fx=null}get x(){return this._x}set x(t){if(this._x=this.core.x=t,this._xPosIntialized||(this.core.__x=t,this._xPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].x=t}}get y(){return this._y}set y(t){if(this._y=this.core.y=t,this._yPosIntialized||(this.core.__y=t,this._yPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].y=t}}set rotation(t){if(this._rotation=this.core.rotation=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;){const s=e[i];s.__adoptRotation&&(s.rotation=s.settings.rotation+t)}}}get rotation(){return this._rotation}get paused(){return this._paused}set paused(t){if(this._paused=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].paused=t}}get on(){return this.__on}recycleParticles(){let t=this._particles.first,e;for(;t;)e=t.next,t.recycle(),t=e;this._particles.clear(),this.__fx.particleCount-=this._particleCount}stopChildEmitters(t){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(t)}__removeParticle(t){t.useSpawns&&this._spawnOnComplete&&this.__subSpawn(t,this.settings.particleSettings.spawn.onComplete),this._particles.remove(t),this._particleCount--,this.__fx.particleCount--,t.recycle()}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}__subSpawn(t,e){const i=this.__fx;if(e){let s=e.length;for(;--s>-1;){const c=e[s];let l,o;switch(c.type){case 0:l=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[l.settings.containerId]||this.container,l.init(o,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(l.rotation=t.component.rotation+l.settings.rotation,l.__adoptRotation=!0):l.rotation=l.settings.rotation;break;case 1:l=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),o=i.__containers[l.settings.containerId]||this.container,l.init(o,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(l.rotation=t.component.rotation);break}l.x=t.component.x,l.y=t.component.y}}}__applySettings(t){const e=this.__fx;if(this.__recycled=this._xPosIntialized=this._yPosIntialized=!1,this.settings=t,this.core=e.__getEmitterCore(t.core.type,this),this.core.init(this),this.rotation=t.rotation,this.name=t.name,this._spawnOnComplete=t.particleSettings.spawn.onComplete.length>0,this._childEmitters.length=0,t.__isClone){const i=t.particleSettings.spawn;for(const c in i){const l=i[c];for(const o of l){switch(o.type){case Lt.ParticleEmitter:o.settings=Ut(e.__getEmitterSettings(o.id));break;case Lt.EffectSequence:o.settings=Ut(e.__getSequenceSettings(o.id));break}o.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Lt.ParticleEmitter:c.settings=Ut(e.__getEmitterSettings(c.id));break;case Lt.EffectSequence:c.settings=Ut(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class Me extends Se{constructor(t){super(t),this._list=[],this._elements=new Ht,this.__on={started:new mt,completed:new mt,exhausted:new mt,effectSpawned:new mt,triggerActivated:new mt}}init(t,e=0,i=!0,s=1){return this.container=t,this._scaleMod=s,this._delay=e*1e3,i&&this.start(),this}start(){if(!this._active)return this._startTime=Date.now()+(this.settings.delay?this.settings.delay*1e3:0)+this._delay,this._index=0,this._list.length==0?(this._active=!1,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this),this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle(),this):(this.exhausted=this.completed=!1,this.setNextEffect(),this.__fx.effectSequenceCount++,this.__fx.__addActiveEffect(this),this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this)}update(t){const e=Date.now();if(e<this._startTime)return;if(this._time+=t,!this.exhausted&&e>=this._effectStartTime){const c=this.__fx,l=this._nextEffectSettings;let o,y,C;switch(l.componentType){case St.Sprite:o=c.__getSprite(l.componentId),C=c.__containers[l.containerId]||this.container,C.addChild(o),o.blendMode=c.__getBlendMode(l.blendMode),o.tint=l.tint,o.scale.set(Y.float(l.scaleMin,l.scaleMax)*Y.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=Y.float(l.alphaMin,l.alphaMax),o.anchor.set(l.componentParams.anchorX,l.componentParams.anchorY),y=new Pt({component:o,endTime:e+l.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+Y.float(l.rotationMin,l.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(St.Sprite,o);break;case St.MovieClip:o=c.__getMovieClip(l.componentId),l.componentParams.loop?(o.animationSpeed=Y.float(l.componentParams.animationSpeedMin||1,l.componentParams.animationSpeedMax||1),o.loop=l.componentParams.loop||!1):l.duration,o.anchor.set(l.componentParams.anchorX,l.componentParams.anchorY),o.gotoAndPlay(0),C=c.__containers[l.containerId]||this.container,C.addChild(o),o.blendMode=c.__getBlendMode(l.blendMode),o.tint=l.tint,o.scale.set(Y.float(l.scaleMin,l.scaleMax)*Y.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=Y.float(l.alphaMin,l.alphaMax),y=new Pt({component:o,endTime:e+l.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+Y.float(l.rotationMin,l.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(St.MovieClip,o);break;case St.Emitter:o=c.getParticleEmitterById(l.componentId),C=c.__containers[l.containerId]||this.container,o.init(C,!0,Y.float(l.scaleMin,l.scaleMax)*Y.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),y=new Pt({component:o,endTime:o.endTime}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+o.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(St.Emitter,o);break;case St.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(l.triggerValue);break}this._index==this._list.length?(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)):this.setNextEffect()}const i=this._elements;let s=i.first;for(;s;){if(s.update(t),e>s.data.endTime){const c=s.data.component;c instanceof re?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function di(h){const{emit:t,settings:e={}}=h,{name:i}=D.useProps(h),s=new Et;let c;return xt.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),xt.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:l})=>{s.update(l)}),D.mount(async l=>{c=l;let y={...(await xt.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const v=e.emitters.map((B,A)=>({...B,id:1e4+A}));y.emitters=[...y.emitters,...v]}s.initBundle(y,!0)}),D.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),D.h(D.Container)}const pi=`/**
|
|
1
|
+
var CanvasEnginePresets=(function(Et,I,P){"use strict";function _i(u){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>u[e]})}}return t.default=u,Object.freeze(t)}const At=_i(P);function ae(u){var t=u.toString(16);return t.length==1?"0"+t:t}function yi(u,t,e){return"#"+ae(u)+ae(t)+ae(e)}function gi(u){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:o,border:a,innerMargin:y,borderRadius:C}=I.useProps(u,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return I.h(I.Graphics,{...u,width:t,height:e,draw(S){C()?S.roundRect(0,0,t(),e(),C()):S.rect(0,0,t(),e()),a&&S.stroke(a),S.fill(c())}},I.h(I.Graphics,{width:t,height:e,draw(S){const B=y(),A=C(),D=Math.max(0,Math.min(t()-2*B,i()/s()*(t()-2*B))),F=e()-2*B;C?S.roundRect(B,B,D,F,A):S.rect(B,B,D,F);const R=o();if(R.startsWith("rgba")){const[N,m,x,_]=R.match(/\d+(\.\d+)?/g).map(Number);S.fill({color:yi(N,m,x),alpha:_})}else S.fill(R)}}))}class te{constructor(){this.__length=0}get length(){return this.__length}add(t){return this.first==null?this.first=this.last=t:(t.prev=this.last,this.last.next=t,this.last=t),t.list=this,this.__length++,this}remove(t){if(t.list!=null)return this.first===this.last?this.first=this.last=null:this.__length>0&&(t===this.last?(t.prev.next=null,this.last=t.prev):t===this.first?(t.next.prev=null,this.first=t.next):(t.next.prev=t.prev,t.prev.next=t.next)),t.next=t.prev=t.list=null,this.__length--,this}clear(){if(!this.first)return;let t=this.first;for(;t;){let e=t.next;t.next=t.prev=t.list=null,t=e}this.first=this.last=null}toArray(){const t=[];if(!this.first)return t;let e=this.first;for(;e;)t.push(e),e=e.next;return t}}class Yt{constructor(t){this.data=t}update(t){}dispose(){}}class Oe extends Yt{constructor(t){super(),this.componentId=t,this.exhausted=!1,this.completed=!1,this.name="",this.endTime=0,this._x=0,this._y=0,this._rotation=0,this._alpha=0,this._scale=new At.Point,this._time=0,this._active=!1,this.__recycled=!0}update(t){}recycle(){}get active(){return this._active}get scale(){return this._scale}set scale(t){this._scale=t}get alpha(){return this._alpha}set alpha(t){this._alpha=t}set rotation(t){this._rotation=t}get rotation(){return this._rotation}get y(){return this._y}set y(t){this._y=t}get x(){return this._x}set x(t){this._x=t}__applySettings(t){}}var oe;(function(u){u[u.Sprite=0]="Sprite",u[u.MovieClip=1]="MovieClip"})(oe||(oe={}));class le{constructor(t){this.type=t,this._dx=0,this._dy=0,this._rotation=0}init(t){this.emitter=t,this._settings=t.settings.core.params,this.x=this.__x=t.x,this.y=this.__y=t.y,this.rotation=t.rotation}emit(t){}prepare(t){this._posInterpolationStep=1/t,this._t=this._posInterpolationStep*.5}step(){this.__x=this.x,this.__y=this.y}recycle(){this.emitter=null,this._settings=null}dispose(){this.recycle(),this.emitter=null,this._settings=null}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._dx=Math.cos(t),this._dy=Math.sin(t)}}class H{static float(t,e){return Math.random()*(e-t)+t}static bool(t=.5){return Math.random()<t}static sign(t=.5){return Math.random()<t?1:-1}static bit(t=.5){return Math.random()<t?1:0}static integer(t,e){return Math.floor(Math.random()*(e-t)+t)}}var Ht;(function(u){u.Circle="circle",u.Box="box",u.Ring="ring"})(Ht||(Ht={}));class xi extends le{constructor(){super(Ht.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let o=i.rotation;const a=H.float(-s,s),y=H.float(-c,c);o!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+a*Math.cos(o)-y*Math.sin(o),t.component.y=this.__y+this._t*(this.y-this.__y)+a*Math.sin(o)+y*Math.cos(o)):(t.component.x=this.__x+this._t*(this.x-this.__x)+a,t.component.y=this.__y+this._t*(this.y-this.__y)+y),e.radial?(o+=Math.atan2(y,a),t.dx=Math.cos(o),t.dy=Math.sin(o)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=o,this._t+=this._posInterpolationStep}}class wi extends le{constructor(){super(Ht.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=H.float(-e.angle*.5,e.angle*.5)+i.rotation:s=H.float(0,6.28319)+i.rotation,e.radius>0){let c=H.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c}else t.component.x=this.__x+this._t*(this.x-this.__x),t.component.y=this.__y+this._t*(this.y-this.__y);e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class Ei extends le{constructor(){super(Ht.Ring)}prepare(t){super.prepare(t);const e=this._settings.angle;2*Math.PI-e<.1?(this._uniformStep=e/t,this._angle=e):(this._uniformStep=e/(t-1),this._angle=-e*.5)}emit(t){const e=this._settings,i=this.emitter;let s;e.uniform?(s=this._angle+i.rotation,this._angle+=this._uniformStep):s=H.float(-e.angle*.5,e.angle*.5)+i.rotation;const c=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(s)*c,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(s)*c,e.radial?(t.dx=Math.cos(s),t.dy=Math.sin(s),t.component.rotation=s):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var Dt;(function(u){u[u.Sprite=0]="Sprite",u[u.MovieClip=1]="MovieClip",u[u.Emitter=2]="Emitter",u[u.Trigger=3]="Trigger"})(Dt||(Dt={}));class vi extends At.AnimatedSprite{constructor(t,e,i,s){let c=[],o=e.length;for(let a=0;a<o;a++)c.push(At.Texture.from(e[a]));super(c),this.componentId=t,this.anchor.set(.5,.5),this.loop=!1,this.__sequenceEndTime=0}recycle(){this.alpha=1,this.tint=16777215,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.__fx.__recycleMovieClip(this.componentId,this)}dispose(){this.parent&&this.parent.removeChild(this),this.gotoAndStop(0),this.destroy()}}class Si{constructor(){}setRgb(t,e){this.startRgb=this.rgb=t,this.r=this.sR=t>>16&255,this.g=this.sG=t>>8&255,this.b=this.sB=t&255,this.targetRgb=e,this.dR=(e>>16&255)-this.r,this.dG=(e>>8&255)-this.g,this.dB=(e&255)-this.b}tween(t,e,i){return t?(this.r=t(e,this.sR,this.dR,i),this.g=t(e,this.sG,this.dG,i),this.b=t(e,this.sB,this.dB,i)):(e/=i,this.r=this.dR*e+this.sR,this.g=this.dG*e+this.sG,this.b=this.dB*e+this.sB),this.rgb=this.r<<16|this.g<<8|this.b,this.rgb}}var Re;(function(u){u.Linear="linear",u.EaseInQuad="easeInQuad",u.EaseOutQuad="easeOutQuad",u.EaseInOutQuad="easeInOutQuad",u.EaseInCubic="easeInCubic",u.EaseOutCubic="easeOutCubic",u.EaseInOutCubic="easeInOutCubic",u.EaseInQuart="easeInQuart",u.EaseOutQuart="easeOutQuart",u.EaseInOutQuart="easeInOutQuart",u.EaseInQuint="easeInQuint",u.EaseOutQuint="easeOutQuint",u.EaseInOutQuint="easeInOutQuint",u.EaseInSine="easeInSine",u.EaseOutSine="easeOutSine",u.EaseInOutSine="easeInOutSine",u.EaseInExpo="easeInExpo",u.EaseOutExpo="easeOutExpo",u.EaseInOutExpo="easeInOutExpo",u.EaseInCirc="easeInCirc",u.EaseOutCirc="easeOutCirc",u.EaseInOutCirc="easeInOutCirc",u.EaseInElastic="easeInElastic",u.EaseOutElastic="easeOutElastic",u.EaseInOutElastic="easeInOutElastic",u.EaseInBack="easeInBack",u.EaseOutBack="easeOutBack",u.EaseInOutBack="easeInOutBack",u.EaseInBounce="easeInBounce",u.EaseOutBounce="easeOutBounce",u.EaseInOutBounce="easeInOutBounce"})(Re||(Re={}));class Mt{static linear(t,e,i,s){return i*t/s+e}static easeInQuad(t,e,i,s){return i*(t/=s)*t+e}static easeOutQuad(t,e,i,s){return-i*(t/=s)*(t-2)+e}static easeInOutQuad(t,e,i,s){return(t/=s/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,s){return i*(t/=s)*t*t+e}static easeOutCubic(t,e,i,s){return i*((t=t/s-1)*t*t+1)+e}static easeInOutCubic(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,s){return i*(t/=s)*t*t*t+e}static easeOutQuart(t,e,i,s){return-i*((t=t/s-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,s){return i*(t/=s)*t*t*t*t+e}static easeOutQuint(t,e,i,s){return i*((t=t/s-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,s){return(t/=s/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e}static easeInSine(t,e,i,s){return-i*Math.cos(t/s*(Math.PI/2))+i+e}static easeOutSine(t,e,i,s){return i*Math.sin(t/s*(Math.PI/2))+e}static easeInOutSine(t,e,i,s){return-i/2*(Math.cos(Math.PI*t/s)-1)+e}static easeInExpo(t,e,i,s){return t===0?e:i*Math.pow(2,10*(t/s-1))+e}static easeOutExpo(t,e,i,s){return t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}static easeInOutExpo(t,e,i,s){return(t/=s/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(-Math.pow(2,-10*--t)+2)+e}static easeInCirc(t,e,i,s){return-i*(Math.sqrt(1-(t/=s)*t)-1)+e}static easeOutCirc(t,e,i,s){return i*Math.sqrt(1-(t=t/s-1)*t)+e}static easeInOutCirc(t,e,i,s){return(t/=s/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}static easeInElastic(t,e,i,s){let c,o,a;return a=1.70158,o=0,c=i,t===0||(t/=s),o||(o=s*.3),c<Math.abs(i)?(c=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-a)*(2*Math.PI)/o))+e}static easeOutElastic(t,e,i,s){let c,o,a;return a=1.70158,o=0,c=i,t===0||(t/=s),o||(o=s*.3),c<Math.abs(i)?(c=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-a)*(2*Math.PI)/o)+i+e}static easeInOutElastic(t,e,i,s){let c,o,a;return a=1.70158,o=0,c=i,t===0||(t/=s/2),o||(o=s*.44999999999999996),c<Math.abs(i)?(c=i,a=o/4):a=o/(2*Math.PI)*Math.asin(i/c),t<1?-.5*(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-a)*(2*Math.PI)/o))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-a)*(2*Math.PI)/o)*.5+i+e}static easeInBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*(t/=s)*t*((c+1)*t-c)+e}static easeOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),i*((t=t/s-1)*t*((c+1)*t+c)+1)+e}static easeInOutBack(t,e,i,s,c){return c===void 0&&(c=1.70158),(t/=s/2)<1?i/2*(t*t*(((c*=1.525)+1)*t-c))+e:i/2*((t-=2)*t*(((c*=1.525)+1)*t+c)+2)+e}static easeInBounce(t,e,i,s){let c;return c=Mt.easeOutBounce(s-t,0,i,s),i-c+e}static easeOutBounce(t,e,i,s){return(t/=s)<.36363636363636365?i*(7.5625*t*t)+e:t<.7272727272727273?i*(7.5625*(t-=.5454545454545454)*t+.75)+e:t<.9090909090909091?i*(7.5625*(t-=.8181818181818182)*t+.9375)+e:i*(7.5625*(t-=.9545454545454546)*t+.984375)+e}static easeInOutBounce(t,e,i,s){let c;return t<s/2?(c=Mt.easeInBounce(t*2,0,i,s),c*.5+e):(c=Mt.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class St{constructor(){this.__hasCallback=!1,this._list=new te}add(t,e,i){this._list.add(new Yt(new Pe(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Yt(new Pe(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,s;for(;i;){s=i.next;let c=!0;const o=i.data;o.callRate&&o.calls%o.callRate!=0&&(c=!1),c&&(o.callback.apply(o.scope,t),o.once&&e.remove(i)),i=s}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,s;for(;i;){if(s=i.next,i.data.callback===t){e.remove(i);return}i=s}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Pe{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let Ti=class extends Yt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new St,bounced:new St,updated:new St},this._color=new Si}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const o=this.duration=H.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(s):t.container.addChildAt(s,0),s.blendMode=c.__getBlendMode(e.blendMode),this.startX=s.x,this.startY=s.y,this.useGravity=t.settings.useGravity,this.useScale=e.useScale,this.useRotation=e.useRotation,this.useAlpha=e.useAlpha,this.useTint=e.useTint,this.useSpawns=e.useSpawns,this.useChilds=e.useChilds,this.useMotion=e.useMotion,this.useGravity)if(this.gravity=t.settings.gravity,this.useFloor=t.settings.useFloor,this.floorY=t.settings.floorY,this.bounceFac=H.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-H.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const a=H.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=a*this.dx*i,this.moveSpeedY=a*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const a=this.distance=H.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(s.x+a*this.dx-this.startX)*.8,this.deltaY=(s.y+a*this.dy-this.startY)*.8,this.distanceEase=Mt[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=H.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=H.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=H.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=Mt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=o*(1-e.fadeInDurationFac),this.fadeInDuration=o*e.fadeInDurationFac,this.fadeInEase=Mt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=Mt[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=H.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(H.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=H.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(H.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=Mt[e.scaleXEase],this.scaleYStart=s.scale.y=H.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(H.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=Mt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=o*(1-e.scaleInDurationFac),this.scaleInDuration=o*e.scaleInDurationFac,this.scaleInEase=Mt[e.scaleInEase||"easeInSine"])):e.uniformScale?(s.scale.x=e.scaleStartMin,s.scale.y=e.scaleStartMin):(s.scale.x=e.scaleXStartMin,s.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=H.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=H.sign())),e.useTint&&(this.tintEase=Mt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let a=e.childs.length;if(this._hasChildEmitters=a>0,this._childEmitters)for(;--a>-1;){const y=e.childs[a],C=c.getParticleEmitterById(y.id);C.init(t.container,!0,(y.scale||1)*(i||1)),y.adoptRotation&&(C.rotation=s.rotation,C.__adoptRotation=!0),C.__parent=this,this._childEmitters.push(C)}}return e.useSpawns&&(e.spawn.onStart.length>0&&t.__subSpawn(this,e.spawn.onStart),this._spawnOnHalfway=e.spawn.onHalfway.length>0),t.__on.particleSpawned.__hasCallback&&t.__on.particleSpawned.dispatch(this),this}update(t){const e=this.time+=t,i=this.duration;if(e>=i){this.emitter.__removeParticle(this);return}const s=this.component,c=e*t;if(this.useGravity){const o=t/.0166666;if(s.x+=this.moveSpeedX*o,s.y+=this.moveSpeedY*o,this.moveSpeedY+=this.gravity*o,this.useAlign&&(s.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&s.y>this.floorY){s.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const a=this.emitter;a.__on.particleBounced.__hasCallback&&a.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&a.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(s.x=this.distanceEase(e,this.startX,this.deltaX,i),s.y=this.distanceEase(e,this.startY,this.deltaY,i)):(s.x=this.deltaX*c+this.startX,s.y=this.deltaY*c+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?s.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):s.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?s.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):s.alpha=this.alphaDelta*c+this.alphaStart),this.useRotation&&(s.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?s.scale.x=s.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):s.scale.x=s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(s.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),s.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):s.scale.x=s.scale.y=this.scaleDelta*c+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(s.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),s.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(s.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),s.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?s.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):s.scale.x=this.scaleXDelta*c+this.scaleXStart,this.scaleYEase?s.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):s.scale.y=this.scaleYDelta*c+this.scaleYStart)),this.useTint&&(s.tint=this._color.tween(this.tintEase,e,i)),this._spawnOnHalfway&&e>=.5&&(this._spawnOnHalfway=!1,this.emitter.__subSpawn(this,this.settings.spawn.onHalfway)),this.useChilds&&this._hasChildEmitters){const o=this._childEmitters;let a=o.length;for(;--a>-1;){const y=o[a];y.__recycled||(y.x=s.position.x,y.y=s.position.y,y.__adoptRotation&&(y.rotation=s.rotation))}}this.emitter.__on.particleUpdated.__hasCallback&&this.emitter.__on.particleUpdated.dispatch(this),this.__on.updated.__hasCallback&&this.__on.updated.dispatch(this)}stop(){this.time=this.duration}recycle(){this.emitter.__on.particleDied.__hasCallback&&this.emitter.__on.particleDied.dispatch(this);const t=this.__on;if(t.died.__hasCallback&&(t.died.dispatch(this),t.died.removeAll()),t.updated.__hasCallback&&t.updated.removeAll(),t.bounced.__hasCallback&&t.bounced.removeAll(),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(!0);this._childEmitters.length=0,this._hasChildEmitters=!1}this.component.recycle(),this.__fx.__recycleParticle(this),this.dx=this.dy=this.deltaX=this.deltaY=0,this.component=null,this.emitter=null,this.settings=null,this.__recycled=!0}dispose(){this.recycle(),this.__fx=null}get x(){return this.component.x}get y(){return this.component.y}get on(){return this.__on}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}};class Nt{static sanitizeBundle(t){for(let e of t.emitters){const i=Nt._presetStructure.emitter;Nt.parse(e,i,Nt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=Nt._presetStructure.sequence;Nt.parse(e,i,Nt._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let s in e)if(t[s]==null)t[s]=e[s];else{const c=t[s];if(typeof c!="object")continue;const o=e[s];if(!c.hasOwnProperty("length"))Nt.parse(c,o,i);else for(let a of c)for(let y in i)a[y]==null&&(a[y]=i[y])}}}Nt._presetStructure={sequence:{id:0,name:"",type:1,delay:0,scaleMin:1,scaleMax:1,effects:[]},sequenceEffect:{id:0,componentId:null,componentType:0,delay:0,componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},scaleMin:1,scaleMax:1,alphaMin:1,alphaMax:1,rotationMin:0,rotationMax:0,blendMode:0,duration:.1,tint:16777215,containerId:"",triggerValue:""},emitter:{id:0,name:"",type:0,core:{type:"circle",params:{radius:100,radial:!0,angle:6.28318530718,uniform:!1,width:100,height:100}},spawnFrequencyMin:.1,spawnFrequencyMax:.1,maxParticles:1e3,spawnCountMin:1,spawnCountMax:1,duration:0,infinite:!0,useGravity:!1,gravity:0,useFloor:!1,floorY:700,rotation:0,autoRotation:0,particleSettings:{componentType:0,componentId:"",componentParams:{animationSpeedMin:1,animationSpeedMax:1,anchorX:.5,anchorY:.5,loop:!1},durationMin:1,durationMax:2,distanceMin:0,distanceMax:0,distanceEase:"linear",moveSpeedMin:0,moveSpeedMax:0,bounceFacMin:0,bounceFacMax:0,frictionMin:0,frictionMax:0,useMotion:!1,useRotation:!1,useAlpha:!1,useScale:!1,useTint:!1,useChilds:!1,useSpawns:!1,stopOnBounce:!1,align:!1,blendMode:1,addOnTop:!0,rotationSpeedMin:0,rotationSpeedMax:0,randomRotationDirection:!1,randomStartRotation:!1,fadeIn:!0,fadeInDurationFac:.1,fadeInEase:"linear",alphaStartMin:.7,alphaStartMax:.9,alphaEndMin:.7,alphaEndMax:.8,alphaEase:"linear",tintStart:16777215,tintEnd:16777215,tintEase:"linear",scaleIn:!1,scaleInDurationFac:.2,scaleInEase:"linear",uniformScale:!0,scaleXStartMin:1,scaleXStartMax:1,scaleXEndMin:1,scaleXEndMax:1,scaleXEase:"linear",scaleYStartMin:1,scaleYStartMax:1,scaleYEndMin:1,scaleYEndMax:1,scaleYEase:"linear",scaleStartMin:1,scaleStartMax:1,scaleEndMin:1,scaleEndMax:1,scaleEase:"linear",childs:[],spawn:{onComplete:[],onBounce:[],onHalfway:[],onStart:[]}},childs:[]},emitterSpawn:{type:0,id:0,scale:1,adoptRotation:!0,containerId:""}};class bi extends At.Sprite{constructor(t,e,i,s){super(At.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,s||.5),this.__sequenceEndTime=null}recycle(){this.tint=16777215,this.alpha=1,this.rotation=0,this.scale.set(1),this.parent&&this.parent.removeChild(this),this.__fx.__recycleSprite(this.componentId,this)}dispose(){this.__fx=null,this.recycle(),this.destroy(!1)}}function Gt(u){if(typeof u!="object"||u===null)return u;const t=Array.isArray(u)?[]:{};for(const e in u){const i=u[e];t[e]=Gt(i)}return t}var Ai=function(u,t,e,i){function s(c){return c instanceof e?c:new e(function(o){o(c)})}return new(e||(e=Promise))(function(c,o){function a(S){try{C(i.next(S))}catch(B){o(B)}}function y(S){try{C(i.throw(S))}catch(B){o(B)}}function C(S){S.done?c(S.value):s(S.value).then(a,y)}C((i=i.apply(u,t||[])).next())})};class Ct{constructor(){this.useBlendModes=!0,this.particleCount=0,this.emitterCount=0,this.effectSequenceCount=0,this.maxParticles=5e3,this.particleFac=1,this._active=!1,this._effects=new te,this.__containers={},this.clearCache(),this.start()}start(){this._active=!0,this._timeElapsed=Date.now()}pause(){this._active=!1}update(t=1){if(!this.active)return;const e=Date.now();let i=(e-this._timeElapsed)*.001;i*=t;let c=this._effects.first,o;for(;c;)o=c.next,c.update(i),c=o;this._timeElapsed=e}clearCache(){this._cache={particles:[],mcs:[],sprites:[],effectSequences:[],emitters:[],cores:{}},this._settingsCache={mcs:{},sprites:{},emitters:{},effectSequences:{}},this._nameMaps={emitters:{},effectSequences:{}}}setFloorY(t){const e=this._settingsCache.emitters;for(let i in e)e[i].floorY=t}dispose(){let t=this._effects,e=t.first;for(;e;)e.dispose(),e=e.next;t.clear(),this.clearCache()}loadBundleFiles(t,e,i="",s=[]){return new Promise((c,o)=>Ai(this,void 0,void 0,function*(){const a={rfx_spritesheet:e,rfx_bundleSettings:t};for(var y in s)a[y]=s[y];At.Assets.addBundle("rfx_assets",a);const C=yield At.Assets.loadBundle("rfx_assets");c(this.initBundle(C.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==Ct._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=Ct.settingsVersion)throw new Error("Settings version mismatch.");Nt.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const s=t.emitters[i];this.addParticleEmitter(s.id,s)}for(let i in t.sequences){const s=t.sequences[i];this.addEffectSequence(s.id,s)}return this.useBlendModes=t.useBlendModes,this.maxParticles=t.maxParticles,this.parseTextureCache(t.spritesheetFilter)}addParticleEmitter(t,e){if(this._settingsCache.emitters[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.emitters[t]=e,this._nameMaps.emitters[e.name]=e,this}addEffectSequence(t,e){if(this._settingsCache.effectSequences[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.effectSequences[t]=e,this._nameMaps.effectSequences[e.name]=e,this}initSprite(t,e){if(this._settingsCache.sprites[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.sprites[t]=e,this}initMovieClip(t,e){if(this._settingsCache.mcs[t])throw new Error(`ComponentId '${t}' already exists.`);return this._settingsCache.mcs[t]=e,this}getMovieClips(){return this._settingsCache.mcs}getSprites(){return this._settingsCache.sprites}addContainer(t,e){this.__containers[t]=e}getEffectSequence(t,e=!1){const i=this._nameMaps.effectSequences[t];if(!i)throw new Error(`Settings not defined for '${t}'`);return this.getEffectSequenceById(i.id,e)}getEffectSequenceById(t,e=!1){const i=this._cache.effectSequences;let s,c=this._settingsCache.effectSequences[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(s=new ke(t),s.__fx=this):s=i.pop(),e&&(c=Gt(c),c.__isClone=!0),s.__applySettings(c),s}getParticleEmitter(t,e=!0,i=!1){const s=this._nameMaps.emitters[t];if(!s)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(s.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const s=this._cache.emitters;let c,o=this._settingsCache.emitters[t];if(!o)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new ce(t),c.__fx=this):c=s.pop(),i&&(o=Gt(o),o.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(o),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new ce(t.id),s.__fx=this):s=i.pop(),s.autoRecycleOnComplete=e,s.__applySettings(t),s}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new ke(t.id),i.__fx=this):i=e.pop(),i.__applySettings(t),i}stopEmitter(t,e=!1){t.list===this._effects&&this._effects.remove(t),e?t.dispose():this.__recycleEmitter(t)}stopAllEffects(){const t=this._effects.toArray();for(let e of t)e.recycle()}parseSpriteSheet(t,e){return this.parseObject(t.data.frames,e)}parseTextureCache(t){return this.parseObject(At.Cache._cache,t)}get active(){return this._active}__addActiveEffect(t){this._effects.add(t)}__removeActiveEffect(t){this._effects.remove(t)}__getSprite(t){const e=this._cache.sprites;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){const s=this._settingsCache.sprites[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new bi(t,s.texture,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getMovieClip(t){const e=this._cache.mcs;let i=e[t];if(e[t]==null&&(i=e[t]=[]),i.length==0){let s=this._settingsCache.mcs[t];if(s==null)throw new Error(`Settings not defined for '${t}'`);const c=new vi(t,s.textures,s.anchorX,s.anchorY);return c.__fx=this,c}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new Ti;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,s=i[t];return s==null&&(s=i[t]=[]),s.length==0?new Ct.__emitterCores[t](t):s.pop()}__recycleParticle(t){this._cache.particles.push(t)}__recycleSprite(t,e){this._cache.sprites[t].push(e)}__recycleMovieClip(t,e){this._cache.mcs[t].push(e)}__recycleEmitter(t){this._effects.remove(t),this.__recycleEmitterCore(t.core),this._cache.emitters.push(t)}__recycleEffectSequence(t){this._effects.remove(t),this._cache.effectSequences.push(t)}__recycleEmitterCore(t){this._cache.cores[t.type].push(t)}__getBlendMode(t){return At.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?Ct._blendModes[t]:"normal":t}__getSequenceSettings(t){let e=this._settingsCache.effectSequences[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}__getEmitterSettings(t){let e=this._settingsCache.emitters[t];if(!e)throw new Error(`Settings not defined for '${t}'`);return e}parseObject(t,e){let i;if(t instanceof Map){i=new Map;const o=t;o.values();for(const[a,y]of o)y instanceof At.Texture&&(i[a]=y)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let o in i)if(!(e&&o.indexOf(e)==-1)&&(this.initSprite(o,{texture:o,anchorX:.5,anchorY:.5}),c.sprites.push(o),o.substr(0,3)=="mc_")){const y=o.split("_")[1];s[y]==null&&(s[y]=[]),s[y].push(o)}for(let o in s){let a=s[o];c.movieClips.push(o),this.initMovieClip(o,{textures:a,anchorX:.5,anchorY:.5})}return c}}Ct.settingsVersion=0,Ct.version="1.3.4",Ct._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",Ct.ComponentType=oe,Ct.EffectSequenceComponentType=Dt,Ct._blendModes=["normal","add","multiply","screen"],Ct.__emitterCores={circle:wi,box:xi,ring:Ei};var Kt;(function(u){u[u.ParticleEmitter=0]="ParticleEmitter",u[u.EffectSequence=1]="EffectSequence"})(Kt||(Kt={}));class ce extends Oe{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new te,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new St,completed:new St,exhausted:new St,particleUpdated:new St,particleSpawned:new St,particleBounced:new St,particleDied:new St}}init(t,e=!0,i=1){return this.container=t,this.core.__scaleMod=this._scaleMod=i,e&&this.start(),this}start(){if(this._active)return this;const t=Date.now(),e=this.settings,i=this.__fx;i.emitterCount++,this.infinite=e.infinite,this._time=Number.MAX_VALUE,e.duration>0?this.endTime=t+e.duration*1e3:this.endTime=e.duration,this._nextSpawnTime=0,this._particleCount=0,this._active=!0,this.exhausted=this.completed=!1,i.__addActiveEffect(this);let s=e.childs.length;if(this._hasChildEmitters=s>0,this._hasChildEmitters)for(;--s>-1;){const c=e.childs[s],o=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),a=i.__containers[o.settings.containerId]||this.container;o.init(a,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(o.rotation=this._rotation,o.__adoptRotation=!0),o.__parent=this,this._childEmitters.push(o)}return this.rotation=this._rotation,this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this}stop(t=!0){t?(this.exhausted=!0,this._hasChildEmitters&&this.stopChildEmitters(!0)):(this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.autoRecycleOnComplete?this.recycle():(this.recycleParticles(),this.completed=!0,this._active=!1,this.__fx.__removeActiveEffect(this)))}update(t){if(!this._active)return this;const e=Date.now(),i=this.settings;this.exhausted?this._particleCount==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.__fx.__removeActiveEffect(this),this.autoRecycleOnComplete&&this.recycle()):(this.settings.autoRotation!==0&&(this.rotation+=i.autoRotation*(t/.016666)),this.target&&(this.rotation=this.target.rotation,this.targetOffset==0?(this.x=this.target.x,this.y=this.target.y):(this.x=this.target.x+Math.cos(this._rotation)*this.targetOffset,this.y=this.target.y+Math.sin(this._rotation)*this.targetOffset)),this.endTime==0&&!this.infinite?(this.spawn(),this.exhausted=!0):this.infinite||e<this.endTime?(this._time+=t,this._time>=this._nextSpawnTime&&(this._time=0,this.spawn(),this._nextSpawnTime=this._time+H.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,o;for(;c;)o=c.next,c.update(t),c=o;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=H.integer(t.spawnCountMin,t.spawnCountMax)*e.particleFac;for(this.core.prepare(i);--i>-1;){if(this._particleCount>=t.maxParticles||e.particleCount>=e.maxParticles)return this;const s=t.particleSettings,c=e.__getParticle();let o;switch(s.componentType){case 0:c.componentId=s.componentId,o=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,o=e.__getMovieClip(c.componentId),s.componentParams&&(o.loop=!(s.componentParams.loop==null||!s.componentParams.loop),o.animationSpeed=H.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),o.gotoAndPlay(0);break}o.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=o,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=H.float(t.spawnFrequencyMin,t.spawnFrequencyMax),this}recycle(){if(this.__recycled)return;this.__parent&&(this.__parent.__removeChildEmitter(this),this.__parent=void 0),this.recycleParticles(),this.settings=void 0,this._active=!1,this._paused=!1,this.completed=!0,this._x=this._y=this._rotation=0,this._hasChildEmitters&&(this.stopChildEmitters(!0),this._childEmitters.length=0,this._hasChildEmitters=!1),this.__fx.emitterCount--,this.__fx.__recycleEmitter(this),this.__recycled=!0,this.__adoptRotation=!1,this.core=null,this.target=null,this.name=null;const t=this.__on;t.completed.__hasCallback&&t.completed.removeAll(),t.started.__hasCallback&&t.started.removeAll(),t.exhausted.__hasCallback&&t.exhausted.removeAll(),t.particleBounced.__hasCallback&&t.particleBounced.removeAll(),t.particleDied.__hasCallback&&t.particleDied.removeAll(),t.particleSpawned.__hasCallback&&t.particleSpawned.removeAll(),t.particleUpdated.__hasCallback&&t.particleUpdated.removeAll()}dispose(){const t=this._particles;let e=t.first,i;for(;e;)i=e.next,e.recycle(),e=i;t.clear(),this.__recycled=!0,this._hasChildEmitters&&this.stopChildEmitters(!1),this.__fx.particleCount-=this._particleCount,this._particles=null,this.componentId=null,this.settings=null,this._active=!1,this.completed=!0,this._childEmitters=null,this.core&&this.core.dispose(),this.core=null,this.target=null,this.name=null;const s=this.__on;s.completed.removeAll(),s.started.removeAll(),s.exhausted.removeAll(),s.particleBounced.removeAll(),s.particleDied.removeAll(),s.particleSpawned.removeAll(),s.particleUpdated.removeAll(),this.__parent=null,this.__fx.__removeActiveEffect(this),this.__fx=null}get x(){return this._x}set x(t){if(this._x=this.core.x=t,this._xPosIntialized||(this.core.__x=t,this._xPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].x=t}}get y(){return this._y}set y(t){if(this._y=this.core.y=t,this._yPosIntialized||(this.core.__y=t,this._yPosIntialized=!0),this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].y=t}}set rotation(t){if(this._rotation=this.core.rotation=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;){const s=e[i];s.__adoptRotation&&(s.rotation=s.settings.rotation+t)}}}get rotation(){return this._rotation}get paused(){return this._paused}set paused(t){if(this._paused=t,this._hasChildEmitters){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].paused=t}}get on(){return this.__on}recycleParticles(){let t=this._particles.first,e;for(;t;)e=t.next,t.recycle(),t=e;this._particles.clear(),this.__fx.particleCount-=this._particleCount}stopChildEmitters(t){const e=this._childEmitters;let i=e.length;for(;--i>-1;)e[i].stop(t)}__removeParticle(t){t.useSpawns&&this._spawnOnComplete&&this.__subSpawn(t,this.settings.particleSettings.spawn.onComplete),this._particles.remove(t),this._particleCount--,this.__fx.particleCount--,t.recycle()}__removeChildEmitter(t){const e=this._childEmitters.indexOf(t);e>-1&&(this._childEmitters.splice(e,1),this._childEmitters.length==0&&(this._hasChildEmitters=!1))}__subSpawn(t,e){const i=this.__fx;if(e){let s=e.length;for(;--s>-1;){const c=e[s];let o,a;switch(c.type){case 0:o=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),a=i.__containers[o.settings.containerId]||this.container,o.init(a,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(o.rotation=t.component.rotation+o.settings.rotation,o.__adoptRotation=!0):o.rotation=o.settings.rotation;break;case 1:o=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),a=i.__containers[o.settings.containerId]||this.container,o.init(a,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(o.rotation=t.component.rotation);break}o.x=t.component.x,o.y=t.component.y}}}__applySettings(t){const e=this.__fx;if(this.__recycled=this._xPosIntialized=this._yPosIntialized=!1,this.settings=t,this.core=e.__getEmitterCore(t.core.type,this),this.core.init(this),this.rotation=t.rotation,this.name=t.name,this._spawnOnComplete=t.particleSettings.spawn.onComplete.length>0,this._childEmitters.length=0,t.__isClone){const i=t.particleSettings.spawn;for(const c in i){const o=i[c];for(const a of o){switch(a.type){case Kt.ParticleEmitter:a.settings=Gt(e.__getEmitterSettings(a.id));break;case Kt.EffectSequence:a.settings=Gt(e.__getSequenceSettings(a.id));break}a.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Kt.ParticleEmitter:c.settings=Gt(e.__getEmitterSettings(c.id));break;case Kt.EffectSequence:c.settings=Gt(e.__getSequenceSettings(c.id));break}c.settings.__isClone=!0}}}__setCore(t){this.core=this.__fx.__getEmitterCore(t,this),this.core.init(this),this.core.__scaleMod=this._scaleMod,this._xPosIntialized=this._yPosIntialized=!1}}class ke extends Oe{constructor(t){super(t),this._list=[],this._elements=new te,this.__on={started:new St,completed:new St,exhausted:new St,effectSpawned:new St,triggerActivated:new St}}init(t,e=0,i=!0,s=1){return this.container=t,this._scaleMod=s,this._delay=e*1e3,i&&this.start(),this}start(){if(!this._active)return this._startTime=Date.now()+(this.settings.delay?this.settings.delay*1e3:0)+this._delay,this._index=0,this._list.length==0?(this._active=!1,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this),this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle(),this):(this.exhausted=this.completed=!1,this.setNextEffect(),this.__fx.effectSequenceCount++,this.__fx.__addActiveEffect(this),this.__on.started.__hasCallback&&this.__on.started.dispatch(this),this)}update(t){const e=Date.now();if(e<this._startTime)return;if(this._time+=t,!this.exhausted&&e>=this._effectStartTime){const c=this.__fx,o=this._nextEffectSettings;let a,y,C;switch(o.componentType){case Dt.Sprite:a=c.__getSprite(o.componentId),C=c.__containers[o.containerId]||this.container,C.addChild(a),a.blendMode=c.__getBlendMode(o.blendMode),a.tint=o.tint,a.scale.set(H.float(o.scaleMin,o.scaleMax)*H.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=H.float(o.alphaMin,o.alphaMax),a.anchor.set(o.componentParams.anchorX,o.componentParams.anchorY),y=new Yt({component:a,endTime:e+o.duration*1e3}),this._elements.add(y),a.x=this._x,a.y=this._y,a.rotation=this._rotation+H.float(o.rotationMin,o.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Dt.Sprite,a);break;case Dt.MovieClip:a=c.__getMovieClip(o.componentId),o.componentParams.loop?(a.animationSpeed=H.float(o.componentParams.animationSpeedMin||1,o.componentParams.animationSpeedMax||1),a.loop=o.componentParams.loop||!1):o.duration,a.anchor.set(o.componentParams.anchorX,o.componentParams.anchorY),a.gotoAndPlay(0),C=c.__containers[o.containerId]||this.container,C.addChild(a),a.blendMode=c.__getBlendMode(o.blendMode),a.tint=o.tint,a.scale.set(H.float(o.scaleMin,o.scaleMax)*H.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=H.float(o.alphaMin,o.alphaMax),y=new Yt({component:a,endTime:e+o.duration*1e3}),this._elements.add(y),a.x=this._x,a.y=this._y,a.rotation=this._rotation+H.float(o.rotationMin,o.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Dt.MovieClip,a);break;case Dt.Emitter:a=c.getParticleEmitterById(o.componentId),C=c.__containers[o.containerId]||this.container,a.init(C,!0,H.float(o.scaleMin,o.scaleMax)*H.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),y=new Yt({component:a,endTime:a.endTime}),this._elements.add(y),a.x=this._x,a.y=this._y,a.rotation=this._rotation+a.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Dt.Emitter,a);break;case Dt.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(o.triggerValue);break}this._index==this._list.length?(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)):this.setNextEffect()}const i=this._elements;let s=i.first;for(;s;){if(s.update(t),e>s.data.endTime){const c=s.data.component;c instanceof ce?c.completed&&i.remove(s):(i.remove(s),c.recycle())}s=s.next}this.exhausted&&i.length==0&&(this._active=!1,this.completed=!0,this.__on.completed.__hasCallback&&this.__on.completed.dispatch(this),this.recycle())}stop(){this.recycle()}recycle(){if(this.__recycled)return;const t=this._elements;let e=t.first,i;for(;e;)i=e.next,e.data.component.recycle(),e=i;const s=this.__on;s.completed.__hasCallback&&s.completed.removeAll(),s.started.__hasCallback&&s.started.removeAll(),s.exhausted.__hasCallback&&s.exhausted.removeAll(),s.effectSpawned.__hasCallback&&s.effectSpawned.removeAll(),s.triggerActivated.__hasCallback&&s.triggerActivated.removeAll(),t.clear(),this.__recycled=!0,this._x=this._y=this._rotation=0,this.__fx.effectSequenceCount--,this.__fx.__recycleEffectSequence(this)}dispose(){this._elements.clear(),this.__fx=void 0;const t=this.__on;t.completed=t.started=t.exhausted=t.effectSpawned=t.triggerActivated=void 0}set rotation(t){this._rotation=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.rotation=t,i=s}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.x=t,i=s}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,s;for(;i;)s=i.next,i.data.y=t,i=s}get rotation(){return this._rotation}get on(){return this.__on}setNextEffect(){if(this.exhausted)return;const t=this._nextEffectSettings=this._list[this._index++];this._effectStartTime=this._startTime+t.delay*1e3}__applySettings(t){this.settings=t,this.name=t.name,this._list=t.effects.slice(),this.__recycled=!1}}function Ci(u){const{emit:t,settings:e={}}=u,{name:i}=I.useProps(u),s=new Ct;let c;return At.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),At.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),I.tick(({deltaRatio:o})=>{s.update(o)}),I.mount(async o=>{c=o;let y={...(await At.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const S=e.emitters.map((B,A)=>({...B,id:1e4+A}));y.emitters=[...y.emitters,...S]}s.initBundle(y,!0)}),I.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),I.h(I.Container)}const Mi=`/**
|
|
2
2
|
* Night + spot light + fog fragment shader.
|
|
3
|
-
* - Supports multiple circular spots (uSpots) in
|
|
4
|
-
* - Each spot is vec4(
|
|
3
|
+
* - Supports multiple circular spots (uSpots) in screen-pixel space.
|
|
4
|
+
* - Each spot is vec4(xPx, yPx, radiusPx, intensity).
|
|
5
5
|
* - Fog is based on the nearest light source so illuminated areas stay readable.
|
|
6
6
|
* - Dark zones are tinted with uDarkColor for colored night effects.
|
|
7
7
|
*/
|
|
8
|
+
precision highp float;
|
|
9
|
+
precision highp int;
|
|
10
|
+
|
|
8
11
|
in vec2 vTextureCoord;
|
|
9
12
|
|
|
10
13
|
out vec4 finalColor;
|
|
11
14
|
|
|
12
15
|
uniform sampler2D uTexture;
|
|
16
|
+
uniform highp vec4 uInputSize;
|
|
13
17
|
uniform vec4 uSpots[24];
|
|
14
|
-
uniform float uAspect;
|
|
15
18
|
uniform float uDarkness;
|
|
16
19
|
uniform vec3 uDarkColor;
|
|
17
20
|
uniform vec3 uFogColor;
|
|
@@ -22,20 +25,21 @@ void main() {
|
|
|
22
25
|
vec4 color = texture(uTexture, vTextureCoord);
|
|
23
26
|
float light = 0.0;
|
|
24
27
|
float nearestDist = 1.0;
|
|
28
|
+
vec2 fragPx = vTextureCoord * uInputSize.xy;
|
|
29
|
+
float minInputDim = max(min(uInputSize.x, uInputSize.y), 1.0);
|
|
25
30
|
|
|
26
31
|
for (int i = 0; i < 24; i++) {
|
|
27
32
|
vec4 spotData = uSpots[i];
|
|
28
|
-
vec2
|
|
29
|
-
float
|
|
33
|
+
vec2 lightPosPx = spotData.xy;
|
|
34
|
+
float radiusPx = max(spotData.z, 0.0001);
|
|
30
35
|
float intensity = max(spotData.w, 0.0);
|
|
31
36
|
if (intensity <= 0.0001) continue;
|
|
32
37
|
|
|
33
|
-
vec2
|
|
34
|
-
|
|
35
|
-
float
|
|
36
|
-
float spot = (1.0 - smoothstep(0.0, radius, dist)) * intensity;
|
|
38
|
+
vec2 deltaPx = fragPx - lightPosPx;
|
|
39
|
+
float distPx = length(deltaPx);
|
|
40
|
+
float spot = (1.0 - smoothstep(0.0, radiusPx, distPx)) * intensity;
|
|
37
41
|
light = clamp(light + spot, 0.0, 1.0);
|
|
38
|
-
nearestDist = min(nearestDist,
|
|
42
|
+
nearestDist = min(nearestDist, distPx / minInputDim);
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
// Night: full brightness where light is strong, darker elsewhere.
|
|
@@ -53,14 +57,14 @@ void main() {
|
|
|
53
57
|
|
|
54
58
|
finalColor = color;
|
|
55
59
|
}
|
|
56
|
-
`,
|
|
60
|
+
`,Fi=`/**
|
|
57
61
|
* Default Pixi filter vertex shader.
|
|
58
62
|
* Outputs vTextureCoord (0-1) for sampling the input texture in fragment shader.
|
|
59
63
|
*/
|
|
60
64
|
in vec2 aPosition;
|
|
61
65
|
out vec2 vTextureCoord;
|
|
62
66
|
|
|
63
|
-
uniform vec4 uInputSize;
|
|
67
|
+
uniform highp vec4 uInputSize;
|
|
64
68
|
uniform vec4 uOutputFrame;
|
|
65
69
|
uniform vec4 uOutputTexture;
|
|
66
70
|
|
|
@@ -79,19 +83,19 @@ void main(void) {
|
|
|
79
83
|
gl_Position = filterVertexPosition();
|
|
80
84
|
vTextureCoord = filterTextureCoord();
|
|
81
85
|
}
|
|
82
|
-
`,se=24,_i=180,gi=.75,yi=.5,xi=.35,Ei=new Float32Array([.08,.08,.14]),$t=h=>{if(typeof h=="string"){let t=h.replace(/^#/,"");t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);const e=parseInt(t,16);return new Float32Array([(e>>16&255)/255,(e>>8&255)/255,(e&255)/255])}if(typeof h=="number")return new Float32Array([(h>>16&255)/255,(h>>8&255)/255,(h&255)/255]);if(Array.isArray(h)&&h.length>=3){const t=h.every(e=>e<=1);return new Float32Array(t?h:h.map(e=>e/255))}return new Float32Array([0,0,0])};function Fe(h,t){const e=new Float32Array(se*4),i={value:e,type:"vec4<f32>",size:se},s={value:1,type:"f32"},c={value:t?.darkness??gi,type:"f32"},l={value:t?.fogColor?$t(t.fogColor):Ei,type:"vec3<f32>"},o={value:t?.fogRadius??yi,type:"f32"},y={value:t?.fogSoftness??xi,type:"f32"},C={value:t?.darkColor?$t(t.darkColor):new Float32Array([0,0,0]),type:"vec3<f32>"};let v=t?.spots?[...t.spots]:[],B=t?.lightWorldPosition??null;const A=P.Filter.from({gl:{vertex:mi,fragment:pi},resources:{nightUniforms:{uSpots:i,uAspect:s,uDarkness:c,uDarkColor:C,uFogColor:l,uFogRadius:o,uFogSoftness:y}}}),I=(m,d,b)=>Math.min(Math.max(m,d),b),M=()=>Date.now()/1e3,N=()=>B?[{x:B.x,y:B.y},...v]:v,O=()=>{const m=N(),d=Math.min(m.length,se),b=h?.getVisibleBounds?.()??t?.getBounds?.(),R=!!b&&b.width>0&&b.height>0,U=M();R&&(s.value=b.width/b.height),e.fill(0);for(let k=0;k<d;k++){const g=m[k],V=g.radius??_i,j=I(g.intensity??1,0,2),z=g.phase??k*.7;let Q=j;if(g.flicker){const nt=g.flickerSpeed??12;Q*=.88+.12*Math.sin(U*nt+z)}if(g.pulse){const nt=g.pulseSpeed??2;Q*=.8+.2*Math.sin(U*nt+z)}let ut=g.x,tt=g.y,ht=.15;R&&(ut=(g.x-b.x)/b.width,tt=(g.y-b.y)/b.height,ht=V/b.height);const L=k*4;e[L]=ut,e[L+1]=tt,e[L+2]=ht,e[L+3]=I(Q,0,2)}i.value=e},_=A.apply.bind(A);A.apply=((...m)=>(O(),_(...m)));const E=A;return E.setLightWorldPosition=m=>{B=m,O()},E.getLightWorldPosition=()=>B,E.setSpots=m=>{v=[...m],O()},E.getSpots=()=>N().map(m=>({...m})),E.syncLightToViewport=O,E.setDarkness=m=>{c.value=m},E.setDarkColor=m=>{C.value=$t(m)},E.setFogColor=m=>{l.value=$t(m)},E.setFogRadius=m=>{o.value=m},E.setFogSoftness=m=>{y.value=m},O(),E}const st=h=>typeof h=="function"?h():h,_t=h=>typeof h=="number"&&Number.isFinite(h),wi=h=>{const t=st(h);if(!t)return null;const e=st(t.x),i=st(t.y);if(!_t(e)||!_t(i))return null;const s=st(t.radius),c=st(t.intensity),l=st(t.flickerSpeed),o=st(t.pulseSpeed),y=st(t.phase);return{x:e,y:i,radius:_t(s)?s:void 0,intensity:_t(c)?c:void 0,flicker:!!st(t.flicker),flickerSpeed:_t(l)?l:void 0,pulse:!!st(t.pulse),pulseSpeed:_t(o)?o:void 0,phase:_t(y)?y:void 0}},Ie=h=>{const t=st(h);return Array.isArray(t)?t.map(wi).filter(e=>!!e):[]},vi=h=>{if(!h)return null;if(typeof h.getVisibleBounds=="function"){const t=h.getVisibleBounds();if(t)return t}if(typeof h.getLocalBounds=="function"){const t=h.getLocalBounds();if(t)return t}return _t(h.width)&&_t(h.height)?{x:0,y:0,width:h.width,height:h.height}:null};function bi(h={}){const t=D.useProps(h),e=()=>t.lightSpots??t.spots;return D.mount(i=>{const c=i.props.context?.viewport,l=c??i.parent?.componentInstance;if(!l)return;const o=st(t.darkness),y=st(t.darkColor),C=st(t.fogColor),v=st(t.fogRadius),B=st(t.fogSoftness),A=Fe(c,{spots:Ie(e()),getBounds:()=>vi(l),darkness:_t(o)?o:void 0,darkColor:y??void 0,fogColor:C??void 0,fogRadius:_t(v)?v:void 0,fogSoftness:_t(B)?B:void 0}),I=Array.isArray(l.filters)?l.filters:[];return I.includes(A)||(l.filters=[...I,A]),D.effect(()=>{A.setSpots(Ie(e()))}),D.effect(()=>{const M=st(t.darkness);_t(M)&&A.setDarkness(M)}),D.effect(()=>{const M=st(t.darkColor);M!==void 0&&A.setDarkColor(M)}),D.effect(()=>{const M=st(t.fogColor);M!==void 0&&A.setFogColor(M)}),D.effect(()=>{const M=st(t.fogRadius);_t(M)&&A.setFogRadius(M)}),D.effect(()=>{const M=st(t.fogSoftness);_t(M)&&A.setFogSoftness(M)}),()=>{const N=(Array.isArray(l.filters)?l.filters:[]).filter(O=>O!==A);l.filters=N.length>0?N:null}}),D.h(D.Container)}function Ti(h={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:l=3,inactiveAlpha:o=.15}=D.useProps(h,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),y=D.signal(0);D.tick(({deltaTime:M})=>{const O=(typeof s=="function"?s():s)*M/1e3;y.set(y()+O)});const C=M=>{const N=typeof t=="function"?t():t,O=typeof e=="function"?e():e,_=i?typeof i=="function"?i():i:null,E=typeof c=="function"?c():c;typeof l=="function"&&l();const m=typeof o=="function"?o():o,d=y();_&&M.circle(0,0,N).fill(_);const b=360/E,R=N*.4,U=N;for(let k=0;k<E;k++){const g=k*b,V=(d%360+360)%360;let j=Math.abs(V-g);j>180&&(j=360-j);let Q=j/120;Q=Math.min(1,Q),Q=Q*Q*Q;const ut=m+(1-Q)*(1-m),tt=g*(Math.PI/180),ht=b*(Math.PI/180),L=tt-ht/2,nt=tt+ht/2;M.arc(0,0,R,L,nt).arc(0,0,U,nt,L,!0).fill({color:O,alpha:ut})}},B=(typeof t=="function"?t():t)*2,A=D.signal(B),I=D.signal(B);return typeof t=="function"&&D.effect(()=>{const M=t();A.set(M*2),I.set(M*2)}),D.h(D.Container,h,[D.h(D.Graphics,{draw:C})])}var Vt=(h=>(h.Tile="tilelayer",h.ObjectGroup="objectgroup",h.Image="imagelayer",h.Group="group",h))(Vt||{});function De(...h){return h.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function Ai(h){if(Object.prototype.hasOwnProperty.call(h,"__esModule"))return h;var t=h.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(h).forEach(function(i){var s=Object.getOwnPropertyDescriptor(h,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return h[i]}})}),e}var ne={};const Si=Ai(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ae={},Xt={exports:{}},oe={},Gt={},Ne;function Ci(){if(Ne)return Gt;Ne=1,Gt.byteLength=o,Gt.toByteArray=C,Gt.fromByteArray=A;for(var h=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)h[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function l(I){var M=I.length;if(M%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=I.indexOf("=");N===-1&&(N=M);var O=N===M?0:4-N%4;return[N,O]}function o(I){var M=l(I),N=M[0],O=M[1];return(N+O)*3/4-O}function y(I,M,N){return(M+N)*3/4-N}function C(I){var M,N=l(I),O=N[0],_=N[1],E=new e(y(I,O,_)),m=0,d=_>0?O-4:O,b;for(b=0;b<d;b+=4)M=t[I.charCodeAt(b)]<<18|t[I.charCodeAt(b+1)]<<12|t[I.charCodeAt(b+2)]<<6|t[I.charCodeAt(b+3)],E[m++]=M>>16&255,E[m++]=M>>8&255,E[m++]=M&255;return _===2&&(M=t[I.charCodeAt(b)]<<2|t[I.charCodeAt(b+1)]>>4,E[m++]=M&255),_===1&&(M=t[I.charCodeAt(b)]<<10|t[I.charCodeAt(b+1)]<<4|t[I.charCodeAt(b+2)]>>2,E[m++]=M>>8&255,E[m++]=M&255),E}function v(I){return h[I>>18&63]+h[I>>12&63]+h[I>>6&63]+h[I&63]}function B(I,M,N){for(var O,_=[],E=M;E<N;E+=3)O=(I[E]<<16&16711680)+(I[E+1]<<8&65280)+(I[E+2]&255),_.push(v(O));return _.join("")}function A(I){for(var M,N=I.length,O=N%3,_=[],E=16383,m=0,d=N-O;m<d;m+=E)_.push(B(I,m,m+E>d?d:m+E));return O===1?(M=I[N-1],_.push(h[M>>2]+h[M<<4&63]+"==")):O===2&&(M=(I[N-2]<<8)+I[N-1],_.push(h[M>>10]+h[M>>4&63]+h[M<<2&63]+"=")),_.join("")}return Gt}var Qt={};var Oe;function Bi(){return Oe||(Oe=1,Qt.read=function(h,t,e,i,s){var c,l,o=s*8-i-1,y=(1<<o)-1,C=y>>1,v=-7,B=e?s-1:0,A=e?-1:1,I=h[t+B];for(B+=A,c=I&(1<<-v)-1,I>>=-v,v+=o;v>0;c=c*256+h[t+B],B+=A,v-=8);for(l=c&(1<<-v)-1,c>>=-v,v+=i;v>0;l=l*256+h[t+B],B+=A,v-=8);if(c===0)c=1-C;else{if(c===y)return l?NaN:(I?-1:1)*(1/0);l=l+Math.pow(2,i),c=c-C}return(I?-1:1)*l*Math.pow(2,c-i)},Qt.write=function(h,t,e,i,s,c){var l,o,y,C=c*8-s-1,v=(1<<C)-1,B=v>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=i?0:c-1,M=i?1:-1,N=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,l=v):(l=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-l))<1&&(l--,y*=2),l+B>=1?t+=A/y:t+=A*Math.pow(2,1-B),t*y>=2&&(l++,y/=2),l+B>=v?(o=0,l=v):l+B>=1?(o=(t*y-1)*Math.pow(2,s),l=l+B):(o=t*Math.pow(2,B-1)*Math.pow(2,s),l=0));s>=8;h[e+I]=o&255,I+=M,o/=256,s-=8);for(l=l<<s|o,C+=s;C>0;h[e+I]=l&255,I+=M,l/=256,C-=8);h[e+I-M]|=N*128}),Qt}var Re;function Pe(){return Re||(Re=1,(function(h){const t=Ci(),e=Bi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=o,h.SlowBuffer=E,h.INSPECT_MAX_BYTES=50;const s=2147483647;h.kMaxLength=s,o.TYPED_ARRAY_SUPPORT=c(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const u=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(u,r),u.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function l(u){if(u>s)throw new RangeError('The value "'+u+'" is invalid for option "size"');const r=new Uint8Array(u);return Object.setPrototypeOf(r,o.prototype),r}function o(u,r,n){if(typeof u=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(u)}return y(u,r,n)}o.poolSize=8192;function y(u,r,n){if(typeof u=="string")return A(u,r);if(ArrayBuffer.isView(u))return M(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(wt(u,ArrayBuffer)||u&&wt(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(wt(u,SharedArrayBuffer)||u&&wt(u.buffer,SharedArrayBuffer)))return N(u,r,n);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=u.valueOf&&u.valueOf();if(p!=null&&p!==u)return o.from(p,r,n);const x=O(u);if(x)return x;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return o.from(u[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}o.from=function(u,r,n){return y(u,r,n)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function C(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function v(u,r,n){return C(u),u<=0?l(u):r!==void 0?typeof n=="string"?l(u).fill(r,n):l(u).fill(r):l(u)}o.alloc=function(u,r,n){return v(u,r,n)};function B(u){return C(u),l(u<0?0:_(u)|0)}o.allocUnsafe=function(u){return B(u)},o.allocUnsafeSlow=function(u){return B(u)};function A(u,r){if((typeof r!="string"||r==="")&&(r="utf8"),!o.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=m(u,r)|0;let p=l(n);const x=p.write(u,r);return x!==n&&(p=p.slice(0,x)),p}function I(u){const r=u.length<0?0:_(u.length)|0,n=l(r);for(let p=0;p<r;p+=1)n[p]=u[p]&255;return n}function M(u){if(wt(u,Uint8Array)){const r=new Uint8Array(u);return N(r.buffer,r.byteOffset,r.byteLength)}return I(u)}function N(u,r,n){if(r<0||u.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let p;return r===void 0&&n===void 0?p=new Uint8Array(u):n===void 0?p=new Uint8Array(u,r):p=new Uint8Array(u,r,n),Object.setPrototypeOf(p,o.prototype),p}function O(u){if(o.isBuffer(u)){const r=_(u.length)|0,n=l(r);return n.length===0||u.copy(n,0,0,r),n}if(u.length!==void 0)return typeof u.length!="number"||Ae(u.length)?l(0):I(u);if(u.type==="Buffer"&&Array.isArray(u.data))return I(u.data)}function _(u){if(u>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return u|0}function E(u){return+u!=u&&(u=0),o.alloc(+u)}o.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==o.prototype},o.compare=function(r,n){if(wt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),wt(n,Uint8Array)&&(n=o.from(n,n.offset,n.byteLength)),!o.isBuffer(r)||!o.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let p=r.length,x=n.length;for(let T=0,F=Math.min(p,x);T<F;++T)if(r[T]!==n[T]){p=r[T],x=n[T];break}return p<x?-1:x<p?1:0},o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);let p;if(n===void 0)for(n=0,p=0;p<r.length;++p)n+=r[p].length;const x=o.allocUnsafe(n);let T=0;for(p=0;p<r.length;++p){let F=r[p];if(wt(F,Uint8Array))T+F.length>x.length?(o.isBuffer(F)||(F=o.from(F)),F.copy(x,T)):Uint8Array.prototype.set.call(x,F,T);else if(o.isBuffer(F))F.copy(x,T);else throw new TypeError('"list" argument must be an Array of Buffers');T+=F.length}return x};function m(u,r){if(o.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||wt(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);const n=u.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&n===0)return 0;let x=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return at(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return zt(u).length;default:if(x)return p?-1:at(u).length;r=(""+r).toLowerCase(),x=!0}}o.byteLength=m;function d(u,r,n){let p=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(u||(u="utf8");;)switch(u){case"hex":return dt(this,r,n);case"utf8":case"utf-8":return ut(this,r,n);case"ascii":return L(this,r,n);case"latin1":case"binary":return nt(this,r,n);case"base64":return Q(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yt(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),p=!0}}o.prototype._isBuffer=!0;function b(u,r,n){const p=u[r];u[r]=u[n],u[n]=p}o.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)b(this,n,n+1);return this},o.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)b(this,n,n+3),b(this,n+1,n+2);return this},o.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)b(this,n,n+7),b(this,n+1,n+6),b(this,n+2,n+5),b(this,n+3,n+4);return this},o.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?ut(this,0,r):d.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(r){if(!o.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0},o.prototype.inspect=function(){let r="";const n=h.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(r,n,p,x,T){if(wt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),!o.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),p===void 0&&(p=r?r.length:0),x===void 0&&(x=0),T===void 0&&(T=this.length),n<0||p>r.length||x<0||T>this.length)throw new RangeError("out of range index");if(x>=T&&n>=p)return 0;if(x>=T)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,x>>>=0,T>>>=0,this===r)return 0;let F=T-x,G=p-n;const it=Math.min(F,G),Z=this.slice(x,T),rt=r.slice(n,p);for(let H=0;H<it;++H)if(Z[H]!==rt[H]){F=Z[H],G=rt[H];break}return F<G?-1:G<F?1:0};function R(u,r,n,p,x){if(u.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ae(n)&&(n=x?0:u.length-1),n<0&&(n=u.length+n),n>=u.length){if(x)return-1;n=u.length-1}else if(n<0)if(x)n=0;else return-1;if(typeof r=="string"&&(r=o.from(r,p)),o.isBuffer(r))return r.length===0?-1:U(u,r,n,p,x);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?x?Uint8Array.prototype.indexOf.call(u,r,n):Uint8Array.prototype.lastIndexOf.call(u,r,n):U(u,[r],n,p,x);throw new TypeError("val must be string, number or Buffer")}function U(u,r,n,p,x){let T=1,F=u.length,G=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(u.length<2||r.length<2)return-1;T=2,F/=2,G/=2,n/=2}function it(rt,H){return T===1?rt[H]:rt.readUInt16BE(H*T)}let Z;if(x){let rt=-1;for(Z=n;Z<F;Z++)if(it(u,Z)===it(r,rt===-1?0:Z-rt)){if(rt===-1&&(rt=Z),Z-rt+1===G)return rt*T}else rt!==-1&&(Z-=Z-rt),rt=-1}else for(n+G>F&&(n=F-G),Z=n;Z>=0;Z--){let rt=!0;for(let H=0;H<G;H++)if(it(u,Z+H)!==it(r,H)){rt=!1;break}if(rt)return Z}return-1}o.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},o.prototype.indexOf=function(r,n,p){return R(this,r,n,p,!0)},o.prototype.lastIndexOf=function(r,n,p){return R(this,r,n,p,!1)};function k(u,r,n,p){n=Number(n)||0;const x=u.length-n;p?(p=Number(p),p>x&&(p=x)):p=x;const T=r.length;p>T/2&&(p=T/2);let F;for(F=0;F<p;++F){const G=parseInt(r.substr(F*2,2),16);if(Ae(G))return F;u[n+F]=G}return F}function g(u,r,n,p){return Ot(at(r,u.length-n),u,n,p)}function V(u,r,n,p){return Ot(Tt(r),u,n,p)}function j(u,r,n,p){return Ot(zt(r),u,n,p)}function z(u,r,n,p){return Ot(Te(r,u.length-n),u,n,p)}o.prototype.write=function(r,n,p,x){if(n===void 0)x="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")x=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,x===void 0&&(x="utf8")):(x=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const T=this.length-n;if((p===void 0||p>T)&&(p=T),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");x||(x="utf8");let F=!1;for(;;)switch(x){case"hex":return k(this,r,n,p);case"utf8":case"utf-8":return g(this,r,n,p);case"ascii":case"latin1":case"binary":return V(this,r,n,p);case"base64":return j(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,r,n,p);default:if(F)throw new TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),F=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Q(u,r,n){return r===0&&n===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(r,n))}function ut(u,r,n){n=Math.min(u.length,n);const p=[];let x=r;for(;x<n;){const T=u[x];let F=null,G=T>239?4:T>223?3:T>191?2:1;if(x+G<=n){let it,Z,rt,H;switch(G){case 1:T<128&&(F=T);break;case 2:it=u[x+1],(it&192)===128&&(H=(T&31)<<6|it&63,H>127&&(F=H));break;case 3:it=u[x+1],Z=u[x+2],(it&192)===128&&(Z&192)===128&&(H=(T&15)<<12|(it&63)<<6|Z&63,H>2047&&(H<55296||H>57343)&&(F=H));break;case 4:it=u[x+1],Z=u[x+2],rt=u[x+3],(it&192)===128&&(Z&192)===128&&(rt&192)===128&&(H=(T&15)<<18|(it&63)<<12|(Z&63)<<6|rt&63,H>65535&&H<1114112&&(F=H))}}F===null?(F=65533,G=1):F>65535&&(F-=65536,p.push(F>>>10&1023|55296),F=56320|F&1023),p.push(F),x+=G}return ht(p)}const tt=4096;function ht(u){const r=u.length;if(r<=tt)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=tt));return n}function L(u,r,n){let p="";n=Math.min(u.length,n);for(let x=r;x<n;++x)p+=String.fromCharCode(u[x]&127);return p}function nt(u,r,n){let p="";n=Math.min(u.length,n);for(let x=r;x<n;++x)p+=String.fromCharCode(u[x]);return p}function dt(u,r,n){const p=u.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let x="";for(let T=r;T<n;++T)x+=yr[u[T]];return x}function yt(u,r,n){const p=u.slice(r,n);let x="";for(let T=0;T<p.length-1;T+=2)x+=String.fromCharCode(p[T]+p[T+1]*256);return x}o.prototype.slice=function(r,n){const p=this.length;r=~~r,n=n===void 0?p:~~n,r<0?(r+=p,r<0&&(r=0)):r>p&&(r=p),n<0?(n+=p,n<0&&(n=0)):n>p&&(n=p),n<r&&(n=r);const x=this.subarray(r,n);return Object.setPrototypeOf(x,o.prototype),x};function K(u,r,n){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+r>n)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=this[r],T=1,F=0;for(;++F<n&&(T*=256);)x+=this[r+F]*T;return x},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=this[r+--n],T=1;for(;n>0&&(T*=256);)x+=this[r+--n]*T;return x},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||K(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||K(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||K(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||K(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||K(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,T=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(x)+(BigInt(T)<<BigInt(32))}),o.prototype.readBigUInt64BE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],T=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(x)<<BigInt(32))+BigInt(T)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=this[r],T=1,F=0;for(;++F<n&&(T*=256);)x+=this[r+F]*T;return T*=128,x>=T&&(x-=Math.pow(2,8*n)),x},o.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||K(r,n,this.length);let x=n,T=1,F=this[r+--x];for(;x>0&&(T*=256);)F+=this[r+--x]*T;return T*=128,F>=T&&(F-=Math.pow(2,8*n)),F},o.prototype.readInt8=function(r,n){return r=r>>>0,n||K(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||K(r,2,this.length);const p=this[r]|this[r+1]<<8;return p&32768?p|4294901760:p},o.prototype.readInt16BE=function(r,n){r=r>>>0,n||K(r,2,this.length);const p=this[r+1]|this[r]<<8;return p&32768?p|4294901760:p},o.prototype.readInt32LE=function(r,n){return r=r>>>0,n||K(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},o.prototype.readInt32BE=function(r,n){return r=r>>>0,n||K(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(x)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),o.prototype.readBigInt64BE=Rt(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&ot(r,this.length-8);const x=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(x)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||K(r,4,this.length),e.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||K(r,4,this.length),e.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||K(r,8,this.length),e.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||K(r,8,this.length),e.read(this,r,!1,52,8)};function W(u,r,n,p,x,T){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>x||r<T)throw new RangeError('"value" argument is out of bounds');if(n+p>u.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,p=p>>>0,!x){const G=Math.pow(2,8*p)-1;W(this,r,n,p,G,0)}let T=1,F=0;for(this[n]=r&255;++F<p&&(T*=256);)this[n+F]=r/T&255;return n+p},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,p=p>>>0,!x){const G=Math.pow(2,8*p)-1;W(this,r,n,p,G,0)}let T=p-1,F=1;for(this[n+T]=r&255;--T>=0&&(F*=256);)this[n+T]=r/F&255;return n+p},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,1,255,0),this[n]=r&255,n+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function ft(u,r,n,p,x){et(r,p,x,u,n,7);let T=Number(r&BigInt(4294967295));u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T,T=T>>8,u[n++]=T;let F=Number(r>>BigInt(32)&BigInt(4294967295));return u[n++]=F,F=F>>8,u[n++]=F,F=F>>8,u[n++]=F,F=F>>8,u[n++]=F,n}function ct(u,r,n,p,x){et(r,p,x,u,n,7);let T=Number(r&BigInt(4294967295));u[n+7]=T,T=T>>8,u[n+6]=T,T=T>>8,u[n+5]=T,T=T>>8,u[n+4]=T;let F=Number(r>>BigInt(32)&BigInt(4294967295));return u[n+3]=F,F=F>>8,u[n+2]=F,F=F>>8,u[n+1]=F,F=F>>8,u[n]=F,n+8}o.prototype.writeBigUInt64LE=Rt(function(r,n=0){return ft(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Rt(function(r,n=0){return ct(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const it=Math.pow(2,8*p-1);W(this,r,n,p,it-1,-it)}let T=0,F=1,G=0;for(this[n]=r&255;++T<p&&(F*=256);)r<0&&G===0&&this[n+T-1]!==0&&(G=1),this[n+T]=(r/F>>0)-G&255;return n+p},o.prototype.writeIntBE=function(r,n,p,x){if(r=+r,n=n>>>0,!x){const it=Math.pow(2,8*p-1);W(this,r,n,p,it-1,-it)}let T=p-1,F=1,G=0;for(this[n+T]=r&255;--T>=0&&(F*=256);)r<0&&G===0&&this[n+T+1]!==0&&(G=1),this[n+T]=(r/F>>0)-G&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},o.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},o.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},o.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},o.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||W(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},o.prototype.writeBigInt64LE=Rt(function(r,n=0){return ft(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Rt(function(r,n=0){return ct(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(u,r,n,p,x,T){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function $(u,r,n,p,x){return r=+r,n=n>>>0,x||J(u,r,n,4),e.write(u,r,n,p,23,4),n+4}o.prototype.writeFloatLE=function(r,n,p){return $(this,r,n,!0,p)},o.prototype.writeFloatBE=function(r,n,p){return $(this,r,n,!1,p)};function f(u,r,n,p,x){return r=+r,n=n>>>0,x||J(u,r,n,8),e.write(u,r,n,p,52,8),n+8}o.prototype.writeDoubleLE=function(r,n,p){return f(this,r,n,!0,p)},o.prototype.writeDoubleBE=function(r,n,p){return f(this,r,n,!1,p)},o.prototype.copy=function(r,n,p,x){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!x&&x!==0&&(x=this.length),n>=r.length&&(n=r.length),n||(n=0),x>0&&x<p&&(x=p),x===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(x<0)throw new RangeError("sourceEnd out of bounds");x>this.length&&(x=this.length),r.length-n<x-p&&(x=r.length-n+p);const T=x-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,x):Uint8Array.prototype.set.call(r,this.subarray(p,x),n),T},o.prototype.fill=function(r,n,p,x){if(typeof r=="string"){if(typeof n=="string"?(x=n,n=0,p=this.length):typeof p=="string"&&(x=p,p=this.length),x!==void 0&&typeof x!="string")throw new TypeError("encoding must be a string");if(typeof x=="string"&&!o.isEncoding(x))throw new TypeError("Unknown encoding: "+x);if(r.length===1){const F=r.charCodeAt(0);(x==="utf8"&&F<128||x==="latin1")&&(r=F)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<p)throw new RangeError("Out of range index");if(p<=n)return this;n=n>>>0,p=p===void 0?this.length:p>>>0,r||(r=0);let T;if(typeof r=="number")for(T=n;T<p;++T)this[T]=r;else{const F=o.isBuffer(r)?r:o.from(r,x),G=F.length;if(G===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(T=0;T<p-n;++T)this[T+n]=F[T%G]}return this};const a={};function S(u,r,n){a[u]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${u}]`,this.stack,delete this.name}get code(){return u}set code(x){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:x,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}S("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),S("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),S("ERR_OUT_OF_RANGE",function(u,r,n){let p=`The value of "${u}" is out of range.`,x=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?x=w(String(n)):typeof n=="bigint"&&(x=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(x=w(x)),x+="n"),p+=` It must be ${r}. Received ${x}`,p},RangeError);function w(u){let r="",n=u.length;const p=u[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${u.slice(n-3,n)}${r}`;return`${u.slice(0,n)}${r}`}function q(u,r,n){X(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&ot(r,u.length-(n+1))}function et(u,r,n,p,x,T){if(u>n||u<r){const F=typeof r=="bigint"?"n":"";let G;throw r===0||r===BigInt(0)?G=`>= 0${F} and < 2${F} ** ${(T+1)*8}${F}`:G=`>= -(2${F} ** ${(T+1)*8-1}${F}) and < 2 ** ${(T+1)*8-1}${F}`,new a.ERR_OUT_OF_RANGE("value",G,u)}q(p,x,T)}function X(u,r){if(typeof u!="number")throw new a.ERR_INVALID_ARG_TYPE(r,"number",u)}function ot(u,r,n){throw Math.floor(u)!==u?(X(u,n),new a.ERR_OUT_OF_RANGE("offset","an integer",u)):r<0?new a.ERR_BUFFER_OUT_OF_BOUNDS:new a.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,u)}const pt=/[^+/0-9A-Za-z-_]/g;function Nt(u){if(u=u.split("=")[0],u=u.trim().replace(pt,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function at(u,r){r=r||1/0;let n;const p=u.length;let x=null;const T=[];for(let F=0;F<p;++F){if(n=u.charCodeAt(F),n>55295&&n<57344){if(!x){if(n>56319){(r-=3)>-1&&T.push(239,191,189);continue}else if(F+1===p){(r-=3)>-1&&T.push(239,191,189);continue}x=n;continue}if(n<56320){(r-=3)>-1&&T.push(239,191,189),x=n;continue}n=(x-55296<<10|n-56320)+65536}else x&&(r-=3)>-1&&T.push(239,191,189);if(x=null,n<128){if((r-=1)<0)break;T.push(n)}else if(n<2048){if((r-=2)<0)break;T.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;T.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;T.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return T}function Tt(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function Te(u,r){let n,p,x;const T=[];for(let F=0;F<u.length&&!((r-=2)<0);++F)n=u.charCodeAt(F),p=n>>8,x=n%256,T.push(x),T.push(p);return T}function zt(u){return t.toByteArray(Nt(u))}function Ot(u,r,n,p){let x;for(x=0;x<p&&!(x+n>=r.length||x>=u.length);++x)r[x+n]=u[x];return x}function wt(u,r){return u instanceof r||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===r.name}function Ae(u){return u!==u}const yr=(function(){const u="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let x=0;x<16;++x)r[p+x]=u[n]+u[x]}return r})();function Rt(u){return typeof BigInt>"u"?xr:u}function xr(){throw new Error("BigInt not supported")}})(oe)),oe}var Ue;function Mi(){return Ue||(Ue=1,(function(h,t){var e=Pe(),i=e.Buffer;function s(l,o){for(var y in l)o[y]=l[y]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?h.exports=e:(s(e,t),t.Buffer=c);function c(l,o,y){return i(l,o,y)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(l,o,y){if(typeof l=="number")throw new TypeError("Argument must not be a number");return i(l,o,y)},c.alloc=function(l,o,y){if(typeof l!="number")throw new TypeError("Argument must be a number");var C=i(l);return o!==void 0?typeof y=="string"?C.fill(o,y):C.fill(o):C.fill(0),C},c.allocUnsafe=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return i(l)},c.allocUnsafeSlow=function(l){if(typeof l!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(l)}})(Xt,Xt.exports)),Xt.exports}var ke;function Fi(){if(ke)return ae;ke=1;var h=Mi().Buffer,t=h.isEncoding||function(_){switch(_=""+_,_&&_.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(_){if(!_)return"utf8";for(var E;;)switch(_){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return _;default:if(E)return;_=(""+_).toLowerCase(),E=!0}}function i(_){var E=e(_);if(typeof E!="string"&&(h.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return E||_}ae.StringDecoder=s;function s(_){this.encoding=i(_);var E;switch(this.encoding){case"utf16le":this.text=B,this.end=A,E=4;break;case"utf8":this.fillLast=y,E=4;break;case"base64":this.text=I,this.end=M,E=3;break;default:this.write=N,this.end=O;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=h.allocUnsafe(E)}s.prototype.write=function(_){if(_.length===0)return"";var E,m;if(this.lastNeed){if(E=this.fillLast(_),E===void 0)return"";m=this.lastNeed,this.lastNeed=0}else m=0;return m<_.length?E?E+this.text(_,m):this.text(_,m):E||""},s.prototype.end=v,s.prototype.text=C,s.prototype.fillLast=function(_){if(this.lastNeed<=_.length)return _.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,this.lastTotal-this.lastNeed,0,_.length),this.lastNeed-=_.length};function c(_){return _<=127?0:_>>5===6?2:_>>4===14?3:_>>3===30?4:_>>6===2?-1:-2}function l(_,E,m){var d=E.length-1;if(d<m)return 0;var b=c(E[d]);return b>=0?(b>0&&(_.lastNeed=b-1),b):--d<m||b===-2?0:(b=c(E[d]),b>=0?(b>0&&(_.lastNeed=b-2),b):--d<m||b===-2?0:(b=c(E[d]),b>=0?(b>0&&(b===2?b=0:_.lastNeed=b-3),b):0))}function o(_,E,m){if((E[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&E.length>1){if((E[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&E.length>2&&(E[2]&192)!==128)return _.lastNeed=2,"�"}}function y(_){var E=this.lastTotal-this.lastNeed,m=o(this,_);if(m!==void 0)return m;if(this.lastNeed<=_.length)return _.copy(this.lastChar,E,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,E,0,_.length),this.lastNeed-=_.length}function C(_,E){var m=l(this,_,E);if(!this.lastNeed)return _.toString("utf8",E);this.lastTotal=m;var d=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,d),_.toString("utf8",E,d)}function v(_){var E=_&&_.length?this.write(_):"";return this.lastNeed?E+"�":E}function B(_,E){if((_.length-E)%2===0){var m=_.toString("utf16le",E);if(m){var d=m.charCodeAt(m.length-1);if(d>=55296&&d<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1],m.slice(0,-1)}return m}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=_[_.length-1],_.toString("utf16le",E,_.length-1)}function A(_){var E=_&&_.length?this.write(_):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return E+this.lastChar.toString("utf16le",0,m)}return E}function I(_,E){var m=(_.length-E)%3;return m===0?_.toString("base64",E):(this.lastNeed=3-m,this.lastTotal=3,m===1?this.lastChar[0]=_[_.length-1]:(this.lastChar[0]=_[_.length-2],this.lastChar[1]=_[_.length-1]),_.toString("base64",E,_.length-m))}function M(_){var E=_&&_.length?this.write(_):"";return this.lastNeed?E+this.lastChar.toString("base64",0,3-this.lastNeed):E}function N(_){return _.toString(this.encoding)}function O(_){return _&&_.length?this.write(_):""}return ae}var Le;function Ii(){return Le||(Le=1,(function(h){(function(t){t.parser=function(f,a){return new i(f,a)},t.SAXParser=i,t.SAXStream=v,t.createStream=C,t.MAX_BUFFER_LENGTH=65536;var e=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function i(f,a){if(!(this instanceof i))return new i(f,a);var S=this;c(S),S.q=S.c="",S.bufferCheckPosition=t.MAX_BUFFER_LENGTH,S.opt=a||{},S.opt.lowercase=S.opt.lowercase||S.opt.lowercasetags,S.looseCase=S.opt.lowercase?"toLowerCase":"toUpperCase",S.tags=[],S.closed=S.closedRoot=S.sawRoot=!1,S.tag=S.error=null,S.strict=!!f,S.noscript=!!(f||S.opt.noscript),S.state=g.BEGIN,S.strictEntities=S.opt.strictEntities,S.ENTITIES=S.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),S.attribList=[],S.opt.xmlns&&(S.ns=Object.create(N)),S.opt.unquotedAttributeValues===void 0&&(S.opt.unquotedAttributeValues=!f),S.trackPosition=S.opt.position!==!1,S.trackPosition&&(S.position=S.line=S.column=0),j(S,"onready")}Object.create||(Object.create=function(f){function a(){}a.prototype=f;var S=new a;return S}),Object.keys||(Object.keys=function(f){var a=[];for(var S in f)f.hasOwnProperty(S)&&a.push(S);return a});function s(f){for(var a=Math.max(t.MAX_BUFFER_LENGTH,10),S=0,w=0,q=e.length;w<q;w++){var et=f[e[w]].length;if(et>a)switch(e[w]){case"textNode":Q(f);break;case"cdata":z(f,"oncdata",f.cdata),f.cdata="";break;case"script":z(f,"onscript",f.script),f.script="";break;default:tt(f,"Max buffer length exceeded: "+e[w])}S=Math.max(S,et)}var X=t.MAX_BUFFER_LENGTH-S;f.bufferCheckPosition=X+f.position}function c(f){for(var a=0,S=e.length;a<S;a++)f[e[a]]=""}function l(f){Q(f),f.cdata!==""&&(z(f,"oncdata",f.cdata),f.cdata=""),f.script!==""&&(z(f,"onscript",f.script),f.script="")}i.prototype={end:function(){ht(this)},write:$,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){l(this)}};var o;try{o=Si.Stream}catch{o=function(){}}o||(o=function(){});var y=t.EVENTS.filter(function(f){return f!=="error"&&f!=="end"});function C(f,a){return new v(f,a)}function v(f,a){if(!(this instanceof v))return new v(f,a);o.apply(this),this._parser=new i(f,a),this.writable=!0,this.readable=!0;var S=this;this._parser.onend=function(){S.emit("end")},this._parser.onerror=function(w){S.emit("error",w),S._parser.error=null},this._decoder=null,y.forEach(function(w){Object.defineProperty(S,"on"+w,{get:function(){return S._parser["on"+w]},set:function(q){if(!q)return S.removeAllListeners(w),S._parser["on"+w]=q,q;S.on(w,q)},enumerable:!0,configurable:!1})})}v.prototype=Object.create(o.prototype,{constructor:{value:v}}),v.prototype.write=function(f){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(f)){if(!this._decoder){var a=Fi().StringDecoder;this._decoder=new a("utf8")}f=this._decoder.write(f)}return this._parser.write(f.toString()),this.emit("data",f),!0},v.prototype.end=function(f){return f&&f.length&&this.write(f),this._parser.end(),!0},v.prototype.on=function(f,a){var S=this;return!S._parser["on"+f]&&y.indexOf(f)!==-1&&(S._parser["on"+f]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,f),S.emit.apply(S,w)}),o.prototype.on.call(S,f,a)};var B="[CDATA[",A="DOCTYPE",I="http://www.w3.org/XML/1998/namespace",M="http://www.w3.org/2000/xmlns/",N={xml:I,xmlns:M},O=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,E=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function d(f){return f===" "||f===`
|
|
83
|
-
`||
|
|
84
|
-
Line: `+
|
|
85
|
-
Column: `+
|
|
86
|
-
Char: `+
|
|
87
|
-
Actual: `+
|
|
88
|
-
Actual: `+
|
|
89
|
-
`?(
|
|
90
|
-
`?(a.line++,a.column=0):a.column++);a.textNode+=f.substring(q,S-1)}w==="<"&&!(a.sawRoot&&a.closedRoot&&!a.strict)?(a.state=g.OPEN_WAKA,a.startTagPosition=a.position):(!d(w)&&(!a.sawRoot||a.closedRoot)&&L(a,"Text data outside of root node."),w==="&"?a.state=g.TEXT_ENTITY:a.textNode+=w);continue;case g.SCRIPT:w==="<"?a.state=g.SCRIPT_ENDING:a.script+=w;continue;case g.SCRIPT_ENDING:w==="/"?a.state=g.CLOSE_TAG:(a.script+="<"+w,a.state=g.SCRIPT);continue;case g.OPEN_WAKA:if(w==="!")a.state=g.SGML_DECL,a.sgmlDecl="";else if(!d(w))if(U(O,w))a.state=g.OPEN_TAG,a.tagName=w;else if(w==="/")a.state=g.CLOSE_TAG,a.tagName="";else if(w==="?")a.state=g.PROC_INST,a.procInstName=a.procInstBody="";else{if(L(a,"Unencoded <"),a.startTagPosition+1<a.position){var et=a.position-a.startTagPosition;w=new Array(et).join(" ")+w}a.textNode+="<"+w,a.state=g.TEXT}continue;case g.SGML_DECL:if(a.sgmlDecl+w==="--"){a.state=g.COMMENT,a.comment="",a.sgmlDecl="";continue}a.doctype&&a.doctype!==!0&&a.sgmlDecl?(a.state=g.DOCTYPE_DTD,a.doctype+="<!"+a.sgmlDecl+w,a.sgmlDecl=""):(a.sgmlDecl+w).toUpperCase()===B?(z(a,"onopencdata"),a.state=g.CDATA,a.sgmlDecl="",a.cdata=""):(a.sgmlDecl+w).toUpperCase()===A?(a.state=g.DOCTYPE,(a.doctype||a.sawRoot)&&L(a,"Inappropriately located doctype declaration"),a.doctype="",a.sgmlDecl=""):w===">"?(z(a,"onsgmldeclaration",a.sgmlDecl),a.sgmlDecl="",a.state=g.TEXT):(b(w)&&(a.state=g.SGML_DECL_QUOTED),a.sgmlDecl+=w);continue;case g.SGML_DECL_QUOTED:w===a.q&&(a.state=g.SGML_DECL,a.q=""),a.sgmlDecl+=w;continue;case g.DOCTYPE:w===">"?(a.state=g.TEXT,z(a,"ondoctype",a.doctype),a.doctype=!0):(a.doctype+=w,w==="["?a.state=g.DOCTYPE_DTD:b(w)&&(a.state=g.DOCTYPE_QUOTED,a.q=w));continue;case g.DOCTYPE_QUOTED:a.doctype+=w,w===a.q&&(a.q="",a.state=g.DOCTYPE);continue;case g.DOCTYPE_DTD:w==="]"?(a.doctype+=w,a.state=g.DOCTYPE):w==="<"?(a.state=g.OPEN_WAKA,a.startTagPosition=a.position):b(w)?(a.doctype+=w,a.state=g.DOCTYPE_DTD_QUOTED,a.q=w):a.doctype+=w;continue;case g.DOCTYPE_DTD_QUOTED:a.doctype+=w,w===a.q&&(a.state=g.DOCTYPE_DTD,a.q="");continue;case g.COMMENT:w==="-"?a.state=g.COMMENT_ENDING:a.comment+=w;continue;case g.COMMENT_ENDING:w==="-"?(a.state=g.COMMENT_ENDED,a.comment=ut(a.opt,a.comment),a.comment&&z(a,"oncomment",a.comment),a.comment=""):(a.comment+="-"+w,a.state=g.COMMENT);continue;case g.COMMENT_ENDED:w!==">"?(L(a,"Malformed comment"),a.comment+="--"+w,a.state=g.COMMENT):a.doctype&&a.doctype!==!0?a.state=g.DOCTYPE_DTD:a.state=g.TEXT;continue;case g.CDATA:w==="]"?a.state=g.CDATA_ENDING:a.cdata+=w;continue;case g.CDATA_ENDING:w==="]"?a.state=g.CDATA_ENDING_2:(a.cdata+="]"+w,a.state=g.CDATA);continue;case g.CDATA_ENDING_2:w===">"?(a.cdata&&z(a,"oncdata",a.cdata),z(a,"onclosecdata"),a.cdata="",a.state=g.TEXT):w==="]"?a.cdata+="]":(a.cdata+="]]"+w,a.state=g.CDATA);continue;case g.PROC_INST:w==="?"?a.state=g.PROC_INST_ENDING:d(w)?a.state=g.PROC_INST_BODY:a.procInstName+=w;continue;case g.PROC_INST_BODY:if(!a.procInstBody&&d(w))continue;w==="?"?a.state=g.PROC_INST_ENDING:a.procInstBody+=w;continue;case g.PROC_INST_ENDING:w===">"?(z(a,"onprocessinginstruction",{name:a.procInstName,body:a.procInstBody}),a.procInstName=a.procInstBody="",a.state=g.TEXT):(a.procInstBody+="?"+w,a.state=g.PROC_INST_BODY);continue;case g.OPEN_TAG:U(_,w)?a.tagName+=w:(nt(a),w===">"?K(a):w==="/"?a.state=g.OPEN_TAG_SLASH:(d(w)||L(a,"Invalid character in tag name"),a.state=g.ATTRIB));continue;case g.OPEN_TAG_SLASH:w===">"?(K(a,!0),W(a)):(L(a,"Forward-slash in opening tag not followed by >"),a.state=g.ATTRIB);continue;case g.ATTRIB:if(d(w))continue;w===">"?K(a):w==="/"?a.state=g.OPEN_TAG_SLASH:U(O,w)?(a.attribName=w,a.attribValue="",a.state=g.ATTRIB_NAME):L(a,"Invalid attribute name");continue;case g.ATTRIB_NAME:w==="="?a.state=g.ATTRIB_VALUE:w===">"?(L(a,"Attribute without value"),a.attribValue=a.attribName,yt(a),K(a)):d(w)?a.state=g.ATTRIB_NAME_SAW_WHITE:U(_,w)?a.attribName+=w:L(a,"Invalid attribute name");continue;case g.ATTRIB_NAME_SAW_WHITE:if(w==="=")a.state=g.ATTRIB_VALUE;else{if(d(w))continue;L(a,"Attribute without value"),a.tag.attributes[a.attribName]="",a.attribValue="",z(a,"onattribute",{name:a.attribName,value:""}),a.attribName="",w===">"?K(a):U(O,w)?(a.attribName=w,a.state=g.ATTRIB_NAME):(L(a,"Invalid attribute name"),a.state=g.ATTRIB)}continue;case g.ATTRIB_VALUE:if(d(w))continue;b(w)?(a.q=w,a.state=g.ATTRIB_VALUE_QUOTED):(a.opt.unquotedAttributeValues||tt(a,"Unquoted attribute value"),a.state=g.ATTRIB_VALUE_UNQUOTED,a.attribValue=w);continue;case g.ATTRIB_VALUE_QUOTED:if(w!==a.q){w==="&"?a.state=g.ATTRIB_VALUE_ENTITY_Q:a.attribValue+=w;continue}yt(a),a.q="",a.state=g.ATTRIB_VALUE_CLOSED;continue;case g.ATTRIB_VALUE_CLOSED:d(w)?a.state=g.ATTRIB:w===">"?K(a):w==="/"?a.state=g.OPEN_TAG_SLASH:U(O,w)?(L(a,"No whitespace between attributes"),a.attribName=w,a.attribValue="",a.state=g.ATTRIB_NAME):L(a,"Invalid attribute name");continue;case g.ATTRIB_VALUE_UNQUOTED:if(!R(w)){w==="&"?a.state=g.ATTRIB_VALUE_ENTITY_U:a.attribValue+=w;continue}yt(a),w===">"?K(a):a.state=g.ATTRIB;continue;case g.CLOSE_TAG:if(a.tagName)w===">"?W(a):U(_,w)?a.tagName+=w:a.script?(a.script+="</"+a.tagName,a.tagName="",a.state=g.SCRIPT):(d(w)||L(a,"Invalid tagname in closing tag"),a.state=g.CLOSE_TAG_SAW_WHITE);else{if(d(w))continue;k(O,w)?a.script?(a.script+="</"+w,a.state=g.SCRIPT):L(a,"Invalid tagname in closing tag."):a.tagName=w}continue;case g.CLOSE_TAG_SAW_WHITE:if(d(w))continue;w===">"?W(a):L(a,"Invalid characters in closing tag");continue;case g.TEXT_ENTITY:case g.ATTRIB_VALUE_ENTITY_Q:case g.ATTRIB_VALUE_ENTITY_U:var X,ot;switch(a.state){case g.TEXT_ENTITY:X=g.TEXT,ot="textNode";break;case g.ATTRIB_VALUE_ENTITY_Q:X=g.ATTRIB_VALUE_QUOTED,ot="attribValue";break;case g.ATTRIB_VALUE_ENTITY_U:X=g.ATTRIB_VALUE_UNQUOTED,ot="attribValue";break}if(w===";"){var pt=ft(a);a.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(pt)?(a.entity="",a.state=X,a.write(pt)):(a[ot]+=pt,a.entity="",a.state=X)}else U(a.entity.length?m:E,w)?a.entity+=w:(L(a,"Invalid character in entity name"),a[ot]+="&"+a.entity+w,a.entity="",a.state=X);continue;default:throw new Error(a,"Unknown state: "+a.state)}return a.position>=a.bufferCheckPosition&&s(a),a}String.fromCodePoint||(function(){var f=String.fromCharCode,a=Math.floor,S=function(){var w=16384,q=[],et,X,ot=-1,pt=arguments.length;if(!pt)return"";for(var Nt="";++ot<pt;){var at=Number(arguments[ot]);if(!isFinite(at)||at<0||at>1114111||a(at)!==at)throw RangeError("Invalid code point: "+at);at<=65535?q.push(at):(at-=65536,et=(at>>10)+55296,X=at%1024+56320,q.push(et,X)),(ot+1===pt||q.length>w)&&(Nt+=f.apply(null,q),q.length=0)}return Nt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:S,configurable:!0,writable:!0}):String.fromCodePoint=S})()})(h)})(ne)),ne}var le,Ve;function ce(){return Ve||(Ve=1,le={isArray:function(h){return Array.isArray?Array.isArray(h):Object.prototype.toString.call(h)==="[object Array]"}}),le}var ue,Ye;function he(){if(Ye)return ue;Ye=1;var h=ce().isArray;return ue={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!h(t.alwaysArray))&&(t.alwaysArray=!1)},ensureKeyExists:function(t,e){(!(t+"Key"in e)||typeof e[t+"Key"]!="string")&&(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}},ue}var fe,Ge;function Ke(){if(Ge)return fe;Ge=1;var h=Ii(),t=he(),e=ce().isArray,i,s;function c(_){return i=t.copyOptions(_),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function l(_){var E=Number(_);if(!isNaN(E))return E;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function o(_,E){var m;if(i.compact){if(!s[i[_+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[_+"Key"])!==-1:i.alwaysArray)&&(s[i[_+"Key"]]=[]),s[i[_+"Key"]]&&!e(s[i[_+"Key"]])&&(s[i[_+"Key"]]=[s[i[_+"Key"]]]),_+"Fn"in i&&typeof E=="string"&&(E=i[_+"Fn"](E,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in E)if(E.hasOwnProperty(m))if("instructionFn"in i)E[m]=i.instructionFn(E[m],m,s);else{var d=E[m];delete E[m],E[i.instructionNameFn(m,d,s)]=d}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(E):s[i[_+"Key"]]=E}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=_,_==="instruction"){for(m in E)if(E.hasOwnProperty(m))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,E,s):m,i.instructionHasAttributes?(b[i.attributesKey]=E[m][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],m,s))):("instructionFn"in i&&(E[m]=i.instructionFn(E[m],m,s)),b[i.instructionKey]=E[m])}else _+"Fn"in i&&(E=i[_+"Fn"](E,s)),b[i[_+"Key"]]=E;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function y(_){if("attributesFn"in i&&_&&(_=i.attributesFn(_,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&_){var E;for(E in _)if(_.hasOwnProperty(E)&&(i.trim&&(_[E]=_[E].trim()),i.nativeTypeAttributes&&(_[E]=l(_[E])),"attributeValueFn"in i&&(_[E]=i.attributeValueFn(_[E],E,s)),"attributeNameFn"in i)){var m=_[E];delete _[E],_[i.attributeNameFn(E,_[E],s)]=m}}return _}function C(_){var E={};if(_.body&&(_.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var m=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,d;(d=m.exec(_.body))!==null;)E[d[1]]=d[2]||d[3]||d[4];E=y(E)}if(_.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(E).length&&(s[i.declarationKey][i.attributesKey]=E),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(_.body=_.body.trim());var b={};i.instructionHasAttributes&&Object.keys(E).length?(b[_.name]={},b[_.name][i.attributesKey]=E):b[_.name]=_.body,o("instruction",b)}}function v(_,E){var m;if(typeof _=="object"&&(E=_.attributes,_=_.name),E=y(E),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&E&&Object.keys(E).length){m[i.attributesKey]={};var d;for(d in E)E.hasOwnProperty(d)&&(m[i.attributesKey][d]=E[d])}!(_ in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(_)!==-1:i.alwaysArray)&&(s[_]=[]),s[_]&&!e(s[_])&&(s[_]=[s[_]]),e(s[_])?s[_].push(m):s[_]=m}else s[i.elementsKey]||(s[i.elementsKey]=[]),m={},m[i.typeKey]="element",m[i.nameKey]=_,!i.ignoreAttributes&&E&&Object.keys(E).length&&(m[i.attributesKey]=E),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function B(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=l(_)),i.sanitize&&(_=_.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),o("text",_))}function A(_){i.ignoreComment||(i.trim&&(_=_.trim()),o("comment",_))}function I(_){var E=s[i.parentKey];i.addParent||delete s[i.parentKey],s=E}function M(_){i.ignoreCdata||(i.trim&&(_=_.trim()),o("cdata",_))}function N(_){i.ignoreDoctype||(_=_.replace(/^ /,""),i.trim&&(_=_.trim()),o("doctype",_))}function O(_){_.note=_}return fe=function(_,E){var m=h.parser(!0,{}),d={};if(s=d,i=c(E),m.opt={strictEntities:!0},m.onopentag=v,m.ontext=B,m.oncomment=A,m.onclosetag=I,m.onerror=O,m.oncdata=M,m.ondoctype=N,m.onprocessinginstruction=C,m.write(_).close(),d[i.elementsKey]){var b=d[i.elementsKey];delete d[i.elementsKey],d[i.elementsKey]=b,delete d.text}return d},fe}var de,je;function Di(){if(je)return de;je=1;var h=he(),t=Ke();function e(i){var s=h.copyOptions(i);return h.ensureSpacesExists(s),s}return de=function(i,s){var c,l,o,y;return c=e(s),l=t(i,c),y="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?o=JSON.stringify(l,function(C,v){return C===y?"_":v},c.spaces):o=JSON.stringify(l,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},de}var pe,qe;function ze(){if(qe)return pe;qe=1;var h=he(),t=ce().isArray,e,i;function s(m){var d=h.copyOptions(m);return h.ensureFlagExists("ignoreDeclaration",d),h.ensureFlagExists("ignoreInstruction",d),h.ensureFlagExists("ignoreAttributes",d),h.ensureFlagExists("ignoreText",d),h.ensureFlagExists("ignoreComment",d),h.ensureFlagExists("ignoreCdata",d),h.ensureFlagExists("ignoreDoctype",d),h.ensureFlagExists("compact",d),h.ensureFlagExists("indentText",d),h.ensureFlagExists("indentCdata",d),h.ensureFlagExists("indentAttributes",d),h.ensureFlagExists("indentInstruction",d),h.ensureFlagExists("fullTagEmptyElement",d),h.ensureFlagExists("noQuotesForNativeAttributes",d),h.ensureSpacesExists(d),typeof d.spaces=="number"&&(d.spaces=Array(d.spaces+1).join(" ")),h.ensureKeyExists("declaration",d),h.ensureKeyExists("instruction",d),h.ensureKeyExists("attributes",d),h.ensureKeyExists("text",d),h.ensureKeyExists("comment",d),h.ensureKeyExists("cdata",d),h.ensureKeyExists("doctype",d),h.ensureKeyExists("type",d),h.ensureKeyExists("name",d),h.ensureKeyExists("elements",d),h.checkFnExists("doctype",d),h.checkFnExists("instruction",d),h.checkFnExists("cdata",d),h.checkFnExists("comment",d),h.checkFnExists("text",d),h.checkFnExists("instructionName",d),h.checkFnExists("elementName",d),h.checkFnExists("attributeName",d),h.checkFnExists("attributeValue",d),h.checkFnExists("attributes",d),h.checkFnExists("fullTagEmptyElement",d),d}function c(m,d,b){return(!b&&m.spaces?`
|
|
91
|
-
`:"")+Array(
|
|
92
|
-
`+Array(b+1).join(d.spaces):""),R.push("</"+U+">")):R.push("/>"),R.join("")}function N(m,d,b,R){return m.reduce(function(U,k){var g=c(d,b,R&&!U);switch(k.type){case"element":return U+g+M(k,d,b);case"comment":return U+g+C(k[d.commentKey],d);case"doctype":return U+g+B(k[d.doctypeKey],d);case"cdata":return U+(d.indentCdata?g:"")+v(k[d.cdataKey],d);case"text":return U+(d.indentText?g:"")+A(k[d.textKey],d);case"instruction":var V={};return V[k[d.nameKey]]=k[d.attributesKey]?k:k[d.instructionKey],U+(d.indentInstruction?g:"")+y(V,d,b)}},"")}function O(m,d,b){var R;for(R in m)if(m.hasOwnProperty(R))switch(R){case d.parentKey:case d.attributesKey:break;case d.textKey:if(d.indentText||b)return!0;break;case d.cdataKey:if(d.indentCdata||b)return!0;break;case d.instructionKey:if(d.indentInstruction||b)return!0;break;case d.doctypeKey:case d.commentKey:return!0;default:return!0}return!1}function _(m,d,b,R,U){e=m,i=d;var k="elementNameFn"in b?b.elementNameFn(d,m):d;if(typeof m>"u"||m===null||m==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(d,m)||b.fullTagEmptyElement?"<"+k+"></"+k+">":"<"+k+"/>";var g=[];if(d){if(g.push("<"+k),typeof m!="object")return g.push(">"+A(m,b)+"</"+k+">"),g.join("");m[b.attributesKey]&&g.push(l(m[b.attributesKey],b,R));var V=O(m,b,!0)||m[b.attributesKey]&&m[b.attributesKey]["xml:space"]==="preserve";if(V||("fullTagEmptyElementFn"in b?V=b.fullTagEmptyElementFn(d,m):V=b.fullTagEmptyElement),V)g.push(">");else return g.push("/>"),g.join("")}return g.push(E(m,b,R+1,!1)),e=m,i=d,d&&g.push((U?c(b,R,!1):"")+"</"+k+">"),g.join("")}function E(m,d,b,R){var U,k,g,V=[];for(k in m)if(m.hasOwnProperty(k))for(g=t(m[k])?m[k]:[m[k]],U=0;U<g.length;++U){switch(k){case d.declarationKey:V.push(o(g[U],d,b));break;case d.instructionKey:V.push((d.indentInstruction?c(d,b,R):"")+y(g[U],d,b));break;case d.attributesKey:case d.parentKey:break;case d.textKey:V.push((d.indentText?c(d,b,R):"")+A(g[U],d));break;case d.cdataKey:V.push((d.indentCdata?c(d,b,R):"")+v(g[U],d));break;case d.doctypeKey:V.push(c(d,b,R)+B(g[U],d));break;case d.commentKey:V.push(c(d,b,R)+C(g[U],d));break;default:V.push(c(d,b,R)+_(g[U],k,d,b,O(g[U],d)))}R=R&&!V.length}return V.join("")}return pe=function(m,d){d=s(d);var b=[];return e=m,i="_root_",d.compact?b.push(E(m,d,0,!0)):(m[d.declarationKey]&&b.push(o(m[d.declarationKey],d,0)),m[d.elementsKey]&&m[d.elementsKey].length&&b.push(N(m[d.elementsKey],d,0,!b.length))),b.join("")},pe}var me,We;function Ni(){if(We)return me;We=1;var h=ze();return me=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if(typeof t=="string")try{i=JSON.parse(t)}catch{throw new Error("The JSON structure is invalid")}else i=t;return h(i,e)},me}var _e,He;function Oi(){if(He)return _e;He=1;var h=Ke(),t=Di(),e=ze(),i=Ni();return _e={xml2js:h,xml2json:t,js2xml:e,json2xml:i},_e}var ge=Oi(),Ri=Pe();const gt=class gt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let l={...s,...c,...gt.propToNumber(c,["version","width","height","tilewidth","tileheight","nextlayerid","nextobjectid","hexsidelength","opacity","x","y","offsetx","offsety","startx","starty","id","firstgid","imageheight","imagewidth","margin","columns","rows","tilecount","rotation","gid","tileid","duration","parallaxx","parallaxy","repeatx","repeaty","pixelsize"]),...gt.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(l.properties){const y=gt.toArray(l.properties.property),C={};for(let v of y){const B=v._attributes;if(!B)continue;let A;switch(B.type){case"file":A=this.getImagePath(B.value);break;case"object":case"float":case"int":A=+B.value;break;case"bool":A=B.value=="true";break;case"class":A={...this.transform(v)?.properties??{},_classname:B.propertytype};break;default:A=B.value}C[B.name]=A}l.properties=C}l.polygon&&(l.polygon=this.transform(l.polygon)),l.polyline&&(l.polyline=this.transform(l.polyline)),l.points&&(l=l.points.split(" ").map(y=>{const C=y.split(",");return{x:+C[0],y:+C[1]}})),l.point&&(l.point=!0),l.ellipse&&(l.ellipse=!0),l.text&&(l.text={text:l.text._text,...this.transform(l.text)},delete l.text._text),l.image&&(l.image=this.transform(l.image)),l.source&&(this.isTilesetSource(l)||(l.source=this.getImagePath(l.source)));const o=l.object||l.objectgroup?.object;return o&&(l.objects=gt.toArray(o).map(y=>this.transform(y))),delete l._attributes,delete l.attributes,delete l.object,delete l.objectgroup,l}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:De(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let l=0;l<i;l+=4)c[s]=t.readUInt32LE(l),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?gt.unpackTileBytes(Ri.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=ge.xml2js(this.xml,{compact:!0}),e=ge.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=C=>{const{objectgroup:v,group:B,layer:A,imagelayer:I}=C,M=N=>{N&>.toArray(N).forEach(O=>{if(this.layers.has(+O._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${O._attributes.id} already exists`);this.layers.set(+O._attributes.id,O)})};M(v),M(A),M(B),M(I),B&&s(B)};s(t.map);const c=(C,v=[])=>{if(!C)return v;for(let B of C){const{name:A}=B;if(!["layer","group","imagelayer","objectgroup"].includes(A))continue;const I=B.elements?.find(N=>N.name=="data");B.layer=this.layers.get(+B.attributes.id);const M={...this.transform(I)??{},...this.transform(B),...this.transform(B.layer),layers:c(B.elements),data:I?I.elements[0].text:void 0,type:A=="layer"?"tilelayer":A};delete M.elements,delete M.layer,M.data&&(M.data=gt.decode(M,M.width*M.height)),v.push(M)}return v},l=c(e.elements[0].elements),o=gt.toArray(i).map(C=>this.transform(C)),y={...this.transform(t.map),layers:l,tilesets:o};return delete y.layer,delete y.tileset,delete y.group,delete y.imagelayer,y}parseTileset(){const t=ge.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:gt.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=gt.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};gt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},gt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let ye=gt;class xe{constructor(t){this.properties={},this.properties=t?.properties??{}}getProperty(t,e){const i=this.properties[t];return i===void 0?e:i}hasProperty(t){return!!this.properties[t]}setProperty(t,e){this.properties[t]=e}getType(){return this.class||this.type}}const Pi=2147483648,Ui=1073741824,ki=536870912,Li=268435456;class Kt extends xe{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&Pi)}get verticalFlip(){return!!(this._gid&Ui)}get diagonalFlip(){return!!(this._gid&ki)}get rotatedHex120(){return!!(this._gid&Li)}get gid(){return Kt.getRealGid(this._gid)}set gid(t){this._gid=t}}let Ee=class extends Kt{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class Vi extends Kt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class we extends xe{constructor(t,e,i){super(t),this.tilesets=e,this.parent=i,this.cacheTiles=!1,this.tiles=[],Object.assign(this,t),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty("cache-tiles",!1),this.cacheTiles&&this.propertiesTiles()}get size(){return this.data.length}createTile(t,e,i){if(t==0)return;const s=Kt.getRealGid(t),c=we.findTileSet(s,this.tilesets);if(!c)return;const l=c.getTile(s-c.firstgid);return l?new Ee({...l.tile,gid:t,index:e,layerIndex:i}):new Ee({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new Vi(t);return e.layerName=this.name,e}))}getTileByIndex(t){return this.cacheTiles?this.tiles[t]:this.createTile(this.data[t],t)}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}getLayerParent(){return this.parent}tilesForEach(t){for(let e=0;e<this.data.length;e++){if(this.cacheTiles){t(this.tiles[e],e);continue}t(this.createTile(this.data[e],e),e)}}setData(t,e){this.data[t]=e}}class Yi extends xe{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new Ee(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class Mt{constructor(t,{basePath:e="",staticDir:i="",relativePath:s=""}={}){this.file=t,this.basePath=e}static isBrowser(){return typeof window<"u"&&!window.useFileSystem}static typeOfFile(t){t=t.trim();const e=typeof t=="string",i={isXml:e&&t.startsWith("<?xml"),isObject:!!t.version,isHttp:e&&t.startsWith("http")};return{...i,isPath:!i.isXml&&!i.isObject&&!i.isHttp}}_parseFile(t,e,i){const s=o=>Mt.typeOfFile(o).isXml,c=o=>{if(!o)return i(null);if(s(o)){const y=new ye(o,t,this.basePath);if(e=="map"){const C=y.parseMap();return i(C)}else if(e=="tileset"){const C=y.parseTileset();return i(C)}}return i(JSON.parse(o))};if(Mt.typeOfFile(t).isObject)return i(t);const{isHttp:l}=Mt.typeOfFile(t);if(s(t))c(t);else if(l||Mt.isBrowser()){let o=l?t:De(this.basePath,t);Mt.isBrowser()&&window.urlCache&&(o=window.urlCache[t]),fetch(o,{headers:{"Content-Type":"application/xml"}}).then(y=>y.text()).then(c).catch(y=>i(null,y))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&Mt.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,l)=>{let o=!1;if(l)return t(null,l);if(c.tilesets){const y=[],C=()=>{v++,v==c.tilesets.length&&!o&&(c.tilesets=y,t(c))};let v=0;for(let B=0;B<c.tilesets.length;B++){const A=c.tilesets[B];if(!A.source||A.tiles||A.image||A.tile){y[B]=A,C();continue}i&&Mt.typeOfFile(A.source).isPath&&(A.source=s(A.source)),this._parseFile(A.source,"tileset",(I,M)=>{if(M)return o=!0,t(null,M);y[B]={...I,firstgid:A.firstgid},C()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const Ft={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var Gi=Object.defineProperty,Ki=(h,t,e)=>t in h?Gi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,It=(h,t,e)=>(Ki(h,typeof t!="symbol"?t+"":t,e),e);const jt=class Wt extends P.Geometry{constructor(t){const e=new P.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:P.BufferUsage.VERTEX|P.BufferUsage.COPY_DST,shrinkToFit:!1}),i=Wt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:8},aFrame:{buffer:e,format:"float32x4",stride:i,offset:16},aAnim:{buffer:e,format:"float32x2",stride:i,offset:32},aTextureId:{buffer:e,format:"sint32",stride:i,offset:40},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:44},aAlpha:{buffer:e,format:"float32",stride:i,offset:48}}}),It(this,"lastTimeAccess",0),It(this,"vertSize",Wt.vertSize),It(this,"vertPerQuad",Wt.vertPerQuad),It(this,"stride",Wt.stride),It(this,"buf"),this.buf=e}};It(jt,"vertSize",13),It(jt,"vertPerQuad",4),It(jt,"stride",jt.vertSize*4);let ji=jt;var qi=Object.defineProperty,zi=(h,t,e)=>t in h?qi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Dt=(h,t,e)=>(zi(h,typeof t!="symbol"?t+"":t,e),e);class $e{constructor(){Dt(this,"pipe_uniforms",new P.UniformGroup({u_proj_trans:{value:new P.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class Xe{constructor(t,e){Dt(this,"renderer"),Dt(this,"tileAnim",[0,0]),Dt(this,"ibLen",0),Dt(this,"indexBuffer",null),Dt(this,"shader"),Dt(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new P.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:P.BufferUsage.INDEX|P.BufferUsage.COPY_DST}),this.indexBuffer.destroy=P.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new ji(this.indexBuffer);return t.lastTimeAccess=Date.now(),t}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(t){const e=t*6;e<=this.ibLen||(this.ibLen=e,this.indexBuffer.data=Wi(t,Ft.use32bitIndex?new Uint32Array(e):new Uint16Array(e)))}destroyRenderable(t){t.vb.destroy(!0),t.vb=null}addRenderable(t,e){const i=this.renderer.renderPipes.batch;t.updateBuffer(this),t.checkValid(),t.getTileset().update(),t.is_valid&&(i.break(e),e.add(t._instruction))}updateRenderable(t,e){t.updateBuffer(this),t.getTileset().update()}validateRenderable(t){return t.checkValid()}execute({tilemap:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const{pipe_uniforms:e}=this.adaptor,i=e.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let c=this.tileAnim;const{u_anim_frame:l}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),l[0]=c[0],l[1]=c[1],e.update(),this.adaptor.execute(this,t)}}Dt(Xe,"extension",{type:[P.ExtensionType.WebGLPipes,P.ExtensionType.WebGPUPipes],name:"tilemap"});function Wi(h,t){const e=h*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}var Hi=Object.defineProperty,$i=(h,t,e)=>t in h?Hi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Bt=(h,t,e)=>($i(h,typeof t!="symbol"?t+"":t,e),e);class kt{constructor(t){Bt(this,"max_textures"),Bt(this,"arr",[]),Bt(this,"count",0),Bt(this,"dirty",!1),Bt(this,"dirty_gpu",!1),Bt(this,"bind_group",null),Bt(this,"bind_group_resources",{}),Bt(this,"tex_sizes",null),Bt(this,"null_color",new Float32Array([0,0,0,.5])),Bt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new P.Buffer({usage:P.BufferUsage.UNIFORM|P.BufferUsage.COPY_DST})}get length(){return this.count}push(t){this.arr[this.count++]=t,this.dirty=!0}at(t){return this.arr[t]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:t,arr:e,count:i,max_textures:s,null_color:c}=this;for(let l=0;l<i;l++){const o=e[l];o&&(t[l*4]=o.pixelWidth,t[l*4+1]=o.pixelHeight,t[l*4+2]=1/o.pixelWidth,t[l*4+3]=1/o.pixelHeight)}t[s*4]=c[0],t[s*4+1]=c[1],t[s*4+2]=c[2],t[s*4+3]=c[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;const{bind_group_resources:t,max_textures:e,arr:i,count:s}=this;let c=0;t[c++]=new P.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:e},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let l=0;l<e;l++){const o=(l<s?i[l]:null)||P.Texture.EMPTY.source;t[c++]=o.source,t[c++]=o.style}return this.bind_group||(this.bind_group=new P.BindGroup(t)),this.bind_group}static generate_gpu_textures(t){const e=[];e.push("struct TextureArrayFields {"),e.push(` u_texture_size: array<vec4f, ${t}>,`),e.push(" u_null_color: vec4f"),e.push("}"),e.push("@group(1) @binding(0) var<uniform> taf: TextureArrayFields;");for(let i=0;i<t;i++)e.push(`@group(1) @binding(${i*2+1}) var u_texture_${i}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i*2+2}) var u_sampler_${i}: sampler;`);e.push("fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {"),e.push("switch texture_id {");for(let i=0;i<t;i++)e.push(` case ${i}: { return textureSampleGrad(u_texture_${i}, u_sampler_${i}, uv, dx, dy); }`);return e.push(" default: { return taf.u_null_color; }"),e.push("} }"),e.join(`
|
|
86
|
+
`,ue=24,Bi=180,Ii=.75,Di=.5,Ni=.35,Oi=new Float32Array([.08,.08,.14]),ee=u=>{if(typeof u=="string"){let t=u.replace(/^#/,"");t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);const e=parseInt(t,16);return new Float32Array([(e>>16&255)/255,(e>>8&255)/255,(e&255)/255])}if(typeof u=="number")return new Float32Array([(u>>16&255)/255,(u>>8&255)/255,(u&255)/255]);if(Array.isArray(u)&&u.length>=3){const t=u.every(e=>e<=1);return new Float32Array(t?u:u.map(e=>e/255))}return new Float32Array([0,0,0])};function Ue(u,t){const e=new Float32Array(ue*4),i={value:e,type:"vec4<f32>",size:ue},s={value:t?.darkness??Ii,type:"f32"},c={value:t?.fogColor?ee(t.fogColor):Oi,type:"vec3<f32>"},o={value:t?.fogRadius??Di,type:"f32"},a={value:t?.fogSoftness??Ni,type:"f32"},y={value:t?.darkColor?ee(t.darkColor):new Float32Array([0,0,0]),type:"vec3<f32>"};let C=t?.spots?[...t.spots]:[],S=t?.lightWorldPosition??null;const B=P.Filter.from({gl:{vertex:Fi,fragment:Mi},resources:{nightUniforms:{uSpots:i,uDarkness:s,uDarkColor:y,uFogColor:c,uFogRadius:o,uFogSoftness:a}}}),A=(x,_,f)=>Math.min(Math.max(x,_),f),D=()=>Date.now()/1e3,F=()=>S?[{x:S.x,y:S.y},...C]:C,R=()=>{const x=F(),_=Math.min(x.length,ue),f=u?.getVisibleBounds?.()??t?.getBounds?.(),b=!!f&&f.width>0&&f.height>0,O=u?.toScreen?.bind(u),k=b&&typeof O=="function";let L=0,g=0;if(k){const Y=O(f.x,f.y);_t(Y?.x)&&_t(Y?.y)&&(L=Y.x,g=Y.y)}const q=D();e.fill(0);for(let Y=0;Y<_;Y++){const G=x[Y],st=G.radius??Bi,ft=A(G.intensity??1,0,2),at=G.phase??Y*.7;let ot=ft;if(G.flicker){const W=G.flickerSpeed??12;ot*=.88+.12*Math.sin(q*W+at)}if(G.pulse){const W=G.pulseSpeed??2;ot*=.8+.2*Math.sin(q*W+at)}let K=G.x,gt=G.y,xt=st;if(k){const W=O(G.x,G.y);K=W.x-L,gt=W.y-g}else b&&(K=G.x-f.x,gt=G.y-f.y);const mt=Y*4;e[mt]=K,e[mt+1]=gt,e[mt+2]=xt,e[mt+3]=A(ot,0,2)}i.value=e},N=B.apply.bind(B);B.apply=((...x)=>(R(),N(...x)));const m=B;return m.setLightWorldPosition=x=>{S=x,R()},m.getLightWorldPosition=()=>S,m.setSpots=x=>{C=[...x],R()},m.getSpots=()=>F().map(x=>({...x})),m.syncLightToViewport=R,m.setDarkness=x=>{s.value=x},m.setDarkColor=x=>{y.value=ee(x)},m.setFogColor=x=>{c.value=ee(x)},m.setFogRadius=x=>{o.value=x},m.setFogSoftness=x=>{a.value=x},R(),m}const pt=u=>typeof u=="function"?u():u,_t=u=>typeof u=="number"&&Number.isFinite(u),Ri=u=>{const t=pt(u);if(!t)return null;const e=pt(t.x),i=pt(t.y);if(!_t(e)||!_t(i))return null;const s=pt(t.radius),c=pt(t.intensity),o=pt(t.flickerSpeed),a=pt(t.pulseSpeed),y=pt(t.phase);return{x:e,y:i,radius:_t(s)?s:void 0,intensity:_t(c)?c:void 0,flicker:!!pt(t.flicker),flickerSpeed:_t(o)?o:void 0,pulse:!!pt(t.pulse),pulseSpeed:_t(a)?a:void 0,phase:_t(y)?y:void 0}},Le=u=>{const t=pt(u);return Array.isArray(t)?t.map(Ri).filter(e=>!!e):[]},Pi=u=>{if(!u)return null;if(typeof u.getVisibleBounds=="function"){const t=u.getVisibleBounds();if(t)return t}if(typeof u.getLocalBounds=="function"){const t=u.getLocalBounds();if(t)return t}return _t(u.width)&&_t(u.height)?{x:0,y:0,width:u.width,height:u.height}:null};function ki(u={}){const t=I.useProps(u),e=()=>t.lightSpots??t.spots;return I.mount(i=>{const s=i.props.context,c=s?.viewport,o=c??i.parent?.componentInstance;if(!o)return;const a=s?.canvasSize,y=()=>{if(!c&&typeof a=="function"){const N=a();if(N&&_t(N.width)&&_t(N.height)&&N.width>0&&N.height>0)return{x:0,y:0,width:N.width,height:N.height}}return Pi(o)},C=pt(t.darkness),S=pt(t.darkColor),B=pt(t.fogColor),A=pt(t.fogRadius),D=pt(t.fogSoftness),F=Ue(c,{spots:Le(e()),getBounds:y,darkness:_t(C)?C:void 0,darkColor:S??void 0,fogColor:B??void 0,fogRadius:_t(A)?A:void 0,fogSoftness:_t(D)?D:void 0}),R=Array.isArray(o.filters)?o.filters:[];return R.includes(F)||(o.filters=[...R,F]),I.effect(()=>{F.setSpots(Le(e()))}),I.effect(()=>{const N=pt(t.darkness);_t(N)&&F.setDarkness(N)}),I.effect(()=>{const N=pt(t.darkColor);N!==void 0&&F.setDarkColor(N)}),I.effect(()=>{const N=pt(t.fogColor);N!==void 0&&F.setFogColor(N)}),I.effect(()=>{const N=pt(t.fogRadius);_t(N)&&F.setFogRadius(N)}),I.effect(()=>{const N=pt(t.fogSoftness);_t(N)&&F.setFogSoftness(N)}),()=>{const m=(Array.isArray(o.filters)?o.filters:[]).filter(x=>x!==F);o.filters=m.length>0?m:null}}),I.h(I.Container)}function Ui(u={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:o=3,inactiveAlpha:a=.15}=I.useProps(u,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),y=I.signal(0);I.tick(({deltaTime:F})=>{const N=(typeof s=="function"?s():s)*F/1e3;y.set(y()+N)});const C=F=>{const R=typeof t=="function"?t():t,N=typeof e=="function"?e():e,m=i?typeof i=="function"?i():i:null,x=typeof c=="function"?c():c;typeof o=="function"&&o();const _=typeof a=="function"?a():a,f=y();m&&F.circle(0,0,R).fill(m);const b=360/x,O=R*.4,k=R;for(let L=0;L<x;L++){const g=L*b,q=(f%360+360)%360;let Y=Math.abs(q-g);Y>180&&(Y=360-Y);let st=Y/120;st=Math.min(1,st),st=st*st*st;const ft=_+(1-st)*(1-_),at=g*(Math.PI/180),ot=b*(Math.PI/180),K=at-ot/2,gt=at+ot/2;F.arc(0,0,O,K,gt).arc(0,0,k,gt,K,!0).fill({color:N,alpha:ft})}},B=(typeof t=="function"?t():t)*2,A=I.signal(B),D=I.signal(B);return typeof t=="function"&&I.effect(()=>{const F=t();A.set(F*2),D.set(F*2)}),I.h(I.Container,u,[I.h(I.Graphics,{draw:C})])}var qt=(u=>(u.Tile="tilelayer",u.ObjectGroup="objectgroup",u.Image="imagelayer",u.Group="group",u))(qt||{});function Ve(...u){return u.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function Li(u){if(Object.prototype.hasOwnProperty.call(u,"__esModule"))return u;var t=u.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(u).forEach(function(i){var s=Object.getOwnPropertyDescriptor(u,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return u[i]}})}),e}var he={};const Vi=Li(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var fe={},ie={exports:{}},de={},Xt={},Ye;function Yi(){if(Ye)return Xt;Ye=1,Xt.byteLength=a,Xt.toByteArray=C,Xt.fromByteArray=A;for(var u=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=i.length;s<c;++s)u[s]=i[s],t[i.charCodeAt(s)]=s;t[45]=62,t[95]=63;function o(D){var F=D.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var R=D.indexOf("=");R===-1&&(R=F);var N=R===F?0:4-R%4;return[R,N]}function a(D){var F=o(D),R=F[0],N=F[1];return(R+N)*3/4-N}function y(D,F,R){return(F+R)*3/4-R}function C(D){var F,R=o(D),N=R[0],m=R[1],x=new e(y(D,N,m)),_=0,f=m>0?N-4:N,b;for(b=0;b<f;b+=4)F=t[D.charCodeAt(b)]<<18|t[D.charCodeAt(b+1)]<<12|t[D.charCodeAt(b+2)]<<6|t[D.charCodeAt(b+3)],x[_++]=F>>16&255,x[_++]=F>>8&255,x[_++]=F&255;return m===2&&(F=t[D.charCodeAt(b)]<<2|t[D.charCodeAt(b+1)]>>4,x[_++]=F&255),m===1&&(F=t[D.charCodeAt(b)]<<10|t[D.charCodeAt(b+1)]<<4|t[D.charCodeAt(b+2)]>>2,x[_++]=F>>8&255,x[_++]=F&255),x}function S(D){return u[D>>18&63]+u[D>>12&63]+u[D>>6&63]+u[D&63]}function B(D,F,R){for(var N,m=[],x=F;x<R;x+=3)N=(D[x]<<16&16711680)+(D[x+1]<<8&65280)+(D[x+2]&255),m.push(S(N));return m.join("")}function A(D){for(var F,R=D.length,N=R%3,m=[],x=16383,_=0,f=R-N;_<f;_+=x)m.push(B(D,_,_+x>f?f:_+x));return N===1?(F=D[R-1],m.push(u[F>>2]+u[F<<4&63]+"==")):N===2&&(F=(D[R-2]<<8)+D[R-1],m.push(u[F>>10]+u[F>>4&63]+u[F<<2&63]+"=")),m.join("")}return Xt}var re={};var Ge;function Gi(){return Ge||(Ge=1,re.read=function(u,t,e,i,s){var c,o,a=s*8-i-1,y=(1<<a)-1,C=y>>1,S=-7,B=e?s-1:0,A=e?-1:1,D=u[t+B];for(B+=A,c=D&(1<<-S)-1,D>>=-S,S+=a;S>0;c=c*256+u[t+B],B+=A,S-=8);for(o=c&(1<<-S)-1,c>>=-S,S+=i;S>0;o=o*256+u[t+B],B+=A,S-=8);if(c===0)c=1-C;else{if(c===y)return o?NaN:(D?-1:1)*(1/0);o=o+Math.pow(2,i),c=c-C}return(D?-1:1)*o*Math.pow(2,c-i)},re.write=function(u,t,e,i,s,c){var o,a,y,C=c*8-s-1,S=(1<<C)-1,B=S>>1,A=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,D=i?0:c-1,F=i?1:-1,R=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=S):(o=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-o))<1&&(o--,y*=2),o+B>=1?t+=A/y:t+=A*Math.pow(2,1-B),t*y>=2&&(o++,y/=2),o+B>=S?(a=0,o=S):o+B>=1?(a=(t*y-1)*Math.pow(2,s),o=o+B):(a=t*Math.pow(2,B-1)*Math.pow(2,s),o=0));s>=8;u[e+D]=a&255,D+=F,a/=256,s-=8);for(o=o<<s|a,C+=s;C>0;u[e+D]=o&255,D+=F,o/=256,C-=8);u[e+D-F]|=R*128}),re}var ze;function je(){return ze||(ze=1,(function(u){const t=Yi(),e=Gi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;u.Buffer=a,u.SlowBuffer=x,u.INSPECT_MAX_BYTES=50;const s=2147483647;u.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=c(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const h=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(h,r),h.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(h){if(h>s)throw new RangeError('The value "'+h+'" is invalid for option "size"');const r=new Uint8Array(h);return Object.setPrototypeOf(r,a.prototype),r}function a(h,r,n){if(typeof h=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(h)}return y(h,r,n)}a.poolSize=8192;function y(h,r,n){if(typeof h=="string")return A(h,r);if(ArrayBuffer.isView(h))return F(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(ht(h,ArrayBuffer)||h&&ht(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ht(h,SharedArrayBuffer)||h&&ht(h.buffer,SharedArrayBuffer)))return R(h,r,n);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=h.valueOf&&h.valueOf();if(p!=null&&p!==h)return a.from(p,r,n);const w=N(h);if(w)return w;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return a.from(h[Symbol.toPrimitive]("string"),r,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}a.from=function(h,r,n){return y(h,r,n)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function C(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function S(h,r,n){return C(h),h<=0?o(h):r!==void 0?typeof n=="string"?o(h).fill(r,n):o(h).fill(r):o(h)}a.alloc=function(h,r,n){return S(h,r,n)};function B(h){return C(h),o(h<0?0:m(h)|0)}a.allocUnsafe=function(h){return B(h)},a.allocUnsafeSlow=function(h){return B(h)};function A(h,r){if((typeof r!="string"||r==="")&&(r="utf8"),!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const n=_(h,r)|0;let p=o(n);const w=p.write(h,r);return w!==n&&(p=p.slice(0,w)),p}function D(h){const r=h.length<0?0:m(h.length)|0,n=o(r);for(let p=0;p<r;p+=1)n[p]=h[p]&255;return n}function F(h){if(ht(h,Uint8Array)){const r=new Uint8Array(h);return R(r.buffer,r.byteOffset,r.byteLength)}return D(h)}function R(h,r,n){if(r<0||h.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<r+(n||0))throw new RangeError('"length" is outside of buffer bounds');let p;return r===void 0&&n===void 0?p=new Uint8Array(h):n===void 0?p=new Uint8Array(h,r):p=new Uint8Array(h,r,n),Object.setPrototypeOf(p,a.prototype),p}function N(h){if(a.isBuffer(h)){const r=m(h.length)|0,n=o(r);return n.length===0||h.copy(n,0,0,r),n}if(h.length!==void 0)return typeof h.length!="number"||Pt(h.length)?o(0):D(h);if(h.type==="Buffer"&&Array.isArray(h.data))return D(h.data)}function m(h){if(h>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return h|0}function x(h){return+h!=h&&(h=0),a.alloc(+h)}a.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==a.prototype},a.compare=function(r,n){if(ht(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),ht(n,Uint8Array)&&(n=a.from(n,n.offset,n.byteLength)),!a.isBuffer(r)||!a.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===n)return 0;let p=r.length,w=n.length;for(let v=0,T=Math.min(p,w);v<T;++v)if(r[v]!==n[v]){p=r[v],w=n[v];break}return p<w?-1:w<p?1:0},a.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(r,n){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return a.alloc(0);let p;if(n===void 0)for(n=0,p=0;p<r.length;++p)n+=r[p].length;const w=a.allocUnsafe(n);let v=0;for(p=0;p<r.length;++p){let T=r[p];if(ht(T,Uint8Array))v+T.length>w.length?(a.isBuffer(T)||(T=a.from(T)),T.copy(w,v)):Uint8Array.prototype.set.call(w,T,v);else if(a.isBuffer(T))T.copy(w,v);else throw new TypeError('"list" argument must be an Array of Buffers');v+=T.length}return w};function _(h,r){if(a.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||ht(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const n=h.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&n===0)return 0;let w=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return ut(h).length;default:if(w)return p?-1:j(h).length;r=(""+r).toLowerCase(),w=!0}}a.byteLength=_;function f(h,r,n){let p=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,r>>>=0,n<=r))return"";for(h||(h="utf8");;)switch(h){case"hex":return xt(this,r,n);case"utf8":case"utf-8":return ft(this,r,n);case"ascii":return K(this,r,n);case"latin1":case"binary":return gt(this,r,n);case"base64":return st(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mt(this,r,n);default:if(p)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),p=!0}}a.prototype._isBuffer=!0;function b(h,r,n){const p=h[r];h[r]=h[n],h[n]=p}a.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<r;n+=2)b(this,n,n+1);return this},a.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<r;n+=4)b(this,n,n+3),b(this,n+1,n+2);return this},a.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<r;n+=8)b(this,n,n+7),b(this,n+1,n+6),b(this,n+2,n+5),b(this,n+3,n+4);return this},a.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?ft(this,0,r):f.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(r){if(!a.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:a.compare(this,r)===0},a.prototype.inspect=function(){let r="";const n=u.INSPECT_MAX_BYTES;return r=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(r+=" ... "),"<Buffer "+r+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(r,n,p,w,v){if(ht(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),!a.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(n===void 0&&(n=0),p===void 0&&(p=r?r.length:0),w===void 0&&(w=0),v===void 0&&(v=this.length),n<0||p>r.length||w<0||v>this.length)throw new RangeError("out of range index");if(w>=v&&n>=p)return 0;if(w>=v)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,w>>>=0,v>>>=0,this===r)return 0;let T=v-w,V=p-n;const J=Math.min(T,V),Z=this.slice(w,v),nt=r.slice(n,p);for(let et=0;et<J;++et)if(Z[et]!==nt[et]){T=Z[et],V=nt[et];break}return T<V?-1:V<T?1:0};function O(h,r,n,p,w){if(h.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Pt(n)&&(n=w?0:h.length-1),n<0&&(n=h.length+n),n>=h.length){if(w)return-1;n=h.length-1}else if(n<0)if(w)n=0;else return-1;if(typeof r=="string"&&(r=a.from(r,p)),a.isBuffer(r))return r.length===0?-1:k(h,r,n,p,w);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?w?Uint8Array.prototype.indexOf.call(h,r,n):Uint8Array.prototype.lastIndexOf.call(h,r,n):k(h,[r],n,p,w);throw new TypeError("val must be string, number or Buffer")}function k(h,r,n,p,w){let v=1,T=h.length,V=r.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(h.length<2||r.length<2)return-1;v=2,T/=2,V/=2,n/=2}function J(nt,et){return v===1?nt[et]:nt.readUInt16BE(et*v)}let Z;if(w){let nt=-1;for(Z=n;Z<T;Z++)if(J(h,Z)===J(r,nt===-1?0:Z-nt)){if(nt===-1&&(nt=Z),Z-nt+1===V)return nt*v}else nt!==-1&&(Z-=Z-nt),nt=-1}else for(n+V>T&&(n=T-V),Z=n;Z>=0;Z--){let nt=!0;for(let et=0;et<V;et++)if(J(h,Z+et)!==J(r,et)){nt=!1;break}if(nt)return Z}return-1}a.prototype.includes=function(r,n,p){return this.indexOf(r,n,p)!==-1},a.prototype.indexOf=function(r,n,p){return O(this,r,n,p,!0)},a.prototype.lastIndexOf=function(r,n,p){return O(this,r,n,p,!1)};function L(h,r,n,p){n=Number(n)||0;const w=h.length-n;p?(p=Number(p),p>w&&(p=w)):p=w;const v=r.length;p>v/2&&(p=v/2);let T;for(T=0;T<p;++T){const V=parseInt(r.substr(T*2,2),16);if(Pt(V))return T;h[n+T]=V}return T}function g(h,r,n,p){return rt(j(r,h.length-n),h,n,p)}function q(h,r,n,p){return rt($(r),h,n,p)}function Y(h,r,n,p){return rt(ut(r),h,n,p)}function G(h,r,n,p){return rt(ct(r,h.length-n),h,n,p)}a.prototype.write=function(r,n,p,w){if(n===void 0)w="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")w=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,w===void 0&&(w="utf8")):(w=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const v=this.length-n;if((p===void 0||p>v)&&(p=v),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");w||(w="utf8");let T=!1;for(;;)switch(w){case"hex":return L(this,r,n,p);case"utf8":case"utf-8":return g(this,r,n,p);case"ascii":case"latin1":case"binary":return q(this,r,n,p);case"base64":return Y(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,r,n,p);default:if(T)throw new TypeError("Unknown encoding: "+w);w=(""+w).toLowerCase(),T=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function st(h,r,n){return r===0&&n===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(r,n))}function ft(h,r,n){n=Math.min(h.length,n);const p=[];let w=r;for(;w<n;){const v=h[w];let T=null,V=v>239?4:v>223?3:v>191?2:1;if(w+V<=n){let J,Z,nt,et;switch(V){case 1:v<128&&(T=v);break;case 2:J=h[w+1],(J&192)===128&&(et=(v&31)<<6|J&63,et>127&&(T=et));break;case 3:J=h[w+1],Z=h[w+2],(J&192)===128&&(Z&192)===128&&(et=(v&15)<<12|(J&63)<<6|Z&63,et>2047&&(et<55296||et>57343)&&(T=et));break;case 4:J=h[w+1],Z=h[w+2],nt=h[w+3],(J&192)===128&&(Z&192)===128&&(nt&192)===128&&(et=(v&15)<<18|(J&63)<<12|(Z&63)<<6|nt&63,et>65535&&et<1114112&&(T=et))}}T===null?(T=65533,V=1):T>65535&&(T-=65536,p.push(T>>>10&1023|55296),T=56320|T&1023),p.push(T),w+=V}return ot(p)}const at=4096;function ot(h){const r=h.length;if(r<=at)return String.fromCharCode.apply(String,h);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,h.slice(p,p+=at));return n}function K(h,r,n){let p="";n=Math.min(h.length,n);for(let w=r;w<n;++w)p+=String.fromCharCode(h[w]&127);return p}function gt(h,r,n){let p="";n=Math.min(h.length,n);for(let w=r;w<n;++w)p+=String.fromCharCode(h[w]);return p}function xt(h,r,n){const p=h.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let w="";for(let v=r;v<n;++v)w+=jt[h[v]];return w}function mt(h,r,n){const p=h.slice(r,n);let w="";for(let v=0;v<p.length-1;v+=2)w+=String.fromCharCode(p[v]+p[v+1]*256);return w}a.prototype.slice=function(r,n){const p=this.length;r=~~r,n=n===void 0?p:~~n,r<0?(r+=p,r<0&&(r=0)):r>p&&(r=p),n<0?(n+=p,n<0&&(n=0)):n>p&&(n=p),n<r&&(n=r);const w=this.subarray(r,n);return Object.setPrototypeOf(w,a.prototype),w};function W(h,r,n){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+r>n)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=this[r],v=1,T=0;for(;++T<n&&(v*=256);)w+=this[r+T]*v;return w},a.prototype.readUintBE=a.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=this[r+--n],v=1;for(;n>0&&(v*=256);)w+=this[r+--n]*v;return w},a.prototype.readUint8=a.prototype.readUInt8=function(r,n){return r=r>>>0,n||W(r,1,this.length),this[r]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||W(r,2,this.length),this[r]|this[r+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||W(r,2,this.length),this[r]<<8|this[r+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||W(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(r,n){return r=r>>>0,n||W(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},a.prototype.readBigUInt64LE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,v=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(w)+(BigInt(v)<<BigInt(32))}),a.prototype.readBigUInt64BE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],v=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(w)<<BigInt(32))+BigInt(v)}),a.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=this[r],v=1,T=0;for(;++T<n&&(v*=256);)w+=this[r+T]*v;return v*=128,w>=v&&(w-=Math.pow(2,8*n)),w},a.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||W(r,n,this.length);let w=n,v=1,T=this[r+--w];for(;w>0&&(v*=256);)T+=this[r+--w]*v;return v*=128,T>=v&&(T-=Math.pow(2,8*n)),T},a.prototype.readInt8=function(r,n){return r=r>>>0,n||W(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},a.prototype.readInt16LE=function(r,n){r=r>>>0,n||W(r,2,this.length);const p=this[r]|this[r+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(r,n){r=r>>>0,n||W(r,2,this.length);const p=this[r+1]|this[r]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(r,n){return r=r>>>0,n||W(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},a.prototype.readInt32BE=function(r,n){return r=r>>>0,n||W(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},a.prototype.readBigInt64LE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(w)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),a.prototype.readBigInt64BE=wt(function(r){r=r>>>0,it(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&U(r,this.length-8);const w=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(w)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),a.prototype.readFloatLE=function(r,n){return r=r>>>0,n||W(r,4,this.length),e.read(this,r,!0,23,4)},a.prototype.readFloatBE=function(r,n){return r=r>>>0,n||W(r,4,this.length),e.read(this,r,!1,23,4)},a.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||W(r,8,this.length),e.read(this,r,!0,52,8)},a.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||W(r,8,this.length),e.read(this,r,!1,52,8)};function tt(h,r,n,p,w,v){if(!a.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>w||r<v)throw new RangeError('"value" argument is out of bounds');if(n+p>h.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(r,n,p,w){if(r=+r,n=n>>>0,p=p>>>0,!w){const V=Math.pow(2,8*p)-1;tt(this,r,n,p,V,0)}let v=1,T=0;for(this[n]=r&255;++T<p&&(v*=256);)this[n+T]=r/v&255;return n+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(r,n,p,w){if(r=+r,n=n>>>0,p=p>>>0,!w){const V=Math.pow(2,8*p)-1;tt(this,r,n,p,V,0)}let v=p-1,T=1;for(this[n+v]=r&255;--v>=0&&(T*=256);)this[n+v]=r/T&255;return n+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,1,255,0),this[n]=r&255,n+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,65535,0),this[n]=r&255,this[n+1]=r>>>8,n+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,65535,0),this[n]=r>>>8,this[n+1]=r&255,n+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,4,4294967295,0),this[n+3]=r>>>24,this[n+2]=r>>>16,this[n+1]=r>>>8,this[n]=r&255,n+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,4,4294967295,0),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4};function Tt(h,r,n,p,w){lt(r,p,w,h,n,7);let v=Number(r&BigInt(4294967295));h[n++]=v,v=v>>8,h[n++]=v,v=v>>8,h[n++]=v,v=v>>8,h[n++]=v;let T=Number(r>>BigInt(32)&BigInt(4294967295));return h[n++]=T,T=T>>8,h[n++]=T,T=T>>8,h[n++]=T,T=T>>8,h[n++]=T,n}function vt(h,r,n,p,w){lt(r,p,w,h,n,7);let v=Number(r&BigInt(4294967295));h[n+7]=v,v=v>>8,h[n+6]=v,v=v>>8,h[n+5]=v,v=v>>8,h[n+4]=v;let T=Number(r>>BigInt(32)&BigInt(4294967295));return h[n+3]=T,T=T>>8,h[n+2]=T,T=T>>8,h[n+1]=T,T=T>>8,h[n]=T,n+8}a.prototype.writeBigUInt64LE=wt(function(r,n=0){return Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=wt(function(r,n=0){return vt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(r,n,p,w){if(r=+r,n=n>>>0,!w){const J=Math.pow(2,8*p-1);tt(this,r,n,p,J-1,-J)}let v=0,T=1,V=0;for(this[n]=r&255;++v<p&&(T*=256);)r<0&&V===0&&this[n+v-1]!==0&&(V=1),this[n+v]=(r/T>>0)-V&255;return n+p},a.prototype.writeIntBE=function(r,n,p,w){if(r=+r,n=n>>>0,!w){const J=Math.pow(2,8*p-1);tt(this,r,n,p,J-1,-J)}let v=p-1,T=1,V=0;for(this[n+v]=r&255;--v>=0&&(T*=256);)r<0&&V===0&&this[n+v+1]!==0&&(V=1),this[n+v]=(r/T>>0)-V&255;return n+p},a.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,1,127,-128),r<0&&(r=255+r+1),this[n]=r&255,n+1},a.prototype.writeInt16LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,32767,-32768),this[n]=r&255,this[n+1]=r>>>8,n+2},a.prototype.writeInt16BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,2,32767,-32768),this[n]=r>>>8,this[n+1]=r&255,n+2},a.prototype.writeInt32LE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,4,2147483647,-2147483648),this[n]=r&255,this[n+1]=r>>>8,this[n+2]=r>>>16,this[n+3]=r>>>24,n+4},a.prototype.writeInt32BE=function(r,n,p){return r=+r,n=n>>>0,p||tt(this,r,n,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[n]=r>>>24,this[n+1]=r>>>16,this[n+2]=r>>>8,this[n+3]=r&255,n+4},a.prototype.writeBigInt64LE=wt(function(r,n=0){return Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=wt(function(r,n=0){return vt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ft(h,r,n,p,w,v){if(n+p>h.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Rt(h,r,n,p,w){return r=+r,n=n>>>0,w||Ft(h,r,n,4),e.write(h,r,n,p,23,4),n+4}a.prototype.writeFloatLE=function(r,n,p){return Rt(this,r,n,!0,p)},a.prototype.writeFloatBE=function(r,n,p){return Rt(this,r,n,!1,p)};function d(h,r,n,p,w){return r=+r,n=n>>>0,w||Ft(h,r,n,8),e.write(h,r,n,p,52,8),n+8}a.prototype.writeDoubleLE=function(r,n,p){return d(this,r,n,!0,p)},a.prototype.writeDoubleBE=function(r,n,p){return d(this,r,n,!1,p)},a.prototype.copy=function(r,n,p,w){if(!a.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!w&&w!==0&&(w=this.length),n>=r.length&&(n=r.length),n||(n=0),w>0&&w<p&&(w=p),w===p||r.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(w<0)throw new RangeError("sourceEnd out of bounds");w>this.length&&(w=this.length),r.length-n<w-p&&(w=r.length-n+p);const v=w-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,w):Uint8Array.prototype.set.call(r,this.subarray(p,w),n),v},a.prototype.fill=function(r,n,p,w){if(typeof r=="string"){if(typeof n=="string"?(w=n,n=0,p=this.length):typeof p=="string"&&(w=p,p=this.length),w!==void 0&&typeof w!="string")throw new TypeError("encoding must be a string");if(typeof w=="string"&&!a.isEncoding(w))throw new TypeError("Unknown encoding: "+w);if(r.length===1){const T=r.charCodeAt(0);(w==="utf8"&&T<128||w==="latin1")&&(r=T)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(n<0||this.length<n||this.length<p)throw new RangeError("Out of range index");if(p<=n)return this;n=n>>>0,p=p===void 0?this.length:p>>>0,r||(r=0);let v;if(typeof r=="number")for(v=n;v<p;++v)this[v]=r;else{const T=a.isBuffer(r)?r:a.from(r,w),V=T.length;if(V===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(v=0;v<p-n;++v)this[v+n]=T[v%V]}return this};const l={};function M(h,r,n){l[h]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(w){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:w,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}M("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(h,r){return`The "${h}" argument must be of type number. Received type ${typeof r}`},TypeError),M("ERR_OUT_OF_RANGE",function(h,r,n){let p=`The value of "${h}" is out of range.`,w=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?w=E(String(n)):typeof n=="bigint"&&(w=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(w=E(w)),w+="n"),p+=` It must be ${r}. Received ${w}`,p},RangeError);function E(h){let r="",n=h.length;const p=h[0]==="-"?1:0;for(;n>=p+4;n-=3)r=`_${h.slice(n-3,n)}${r}`;return`${h.slice(0,n)}${r}`}function Q(h,r,n){it(r,"offset"),(h[r]===void 0||h[r+n]===void 0)&&U(r,h.length-(n+1))}function lt(h,r,n,p,w,v){if(h>n||h<r){const T=typeof r=="bigint"?"n":"";let V;throw r===0||r===BigInt(0)?V=`>= 0${T} and < 2${T} ** ${(v+1)*8}${T}`:V=`>= -(2${T} ** ${(v+1)*8-1}${T}) and < 2 ** ${(v+1)*8-1}${T}`,new l.ERR_OUT_OF_RANGE("value",V,h)}Q(p,w,v)}function it(h,r){if(typeof h!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",h)}function U(h,r,n){throw Math.floor(h)!==h?(it(h,n),new l.ERR_OUT_OF_RANGE("offset","an integer",h)):r<0?new l.ERR_BUFFER_OUT_OF_BOUNDS:new l.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,h)}const z=/[^+/0-9A-Za-z-_]/g;function X(h){if(h=h.split("=")[0],h=h.trim().replace(z,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function j(h,r){r=r||1/0;let n;const p=h.length;let w=null;const v=[];for(let T=0;T<p;++T){if(n=h.charCodeAt(T),n>55295&&n<57344){if(!w){if(n>56319){(r-=3)>-1&&v.push(239,191,189);continue}else if(T+1===p){(r-=3)>-1&&v.push(239,191,189);continue}w=n;continue}if(n<56320){(r-=3)>-1&&v.push(239,191,189),w=n;continue}n=(w-55296<<10|n-56320)+65536}else w&&(r-=3)>-1&&v.push(239,191,189);if(w=null,n<128){if((r-=1)<0)break;v.push(n)}else if(n<2048){if((r-=2)<0)break;v.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;v.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;v.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return v}function $(h){const r=[];for(let n=0;n<h.length;++n)r.push(h.charCodeAt(n)&255);return r}function ct(h,r){let n,p,w;const v=[];for(let T=0;T<h.length&&!((r-=2)<0);++T)n=h.charCodeAt(T),p=n>>8,w=n%256,v.push(w),v.push(p);return v}function ut(h){return t.toByteArray(X(h))}function rt(h,r,n,p){let w;for(w=0;w<p&&!(w+n>=r.length||w>=h.length);++w)r[w+n]=h[w];return w}function ht(h,r){return h instanceof r||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===r.name}function Pt(h){return h!==h}const jt=(function(){const h="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let w=0;w<16;++w)r[p+w]=h[n]+h[w]}return r})();function wt(h){return typeof BigInt>"u"?Wt:h}function Wt(){throw new Error("BigInt not supported")}})(de)),de}var Ke;function zi(){return Ke||(Ke=1,(function(u,t){var e=je(),i=e.Buffer;function s(o,a){for(var y in o)a[y]=o[y]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?u.exports=e:(s(e,t),t.Buffer=c);function c(o,a,y){return i(o,a,y)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(o,a,y){if(typeof o=="number")throw new TypeError("Argument must not be a number");return i(o,a,y)},c.alloc=function(o,a,y){if(typeof o!="number")throw new TypeError("Argument must be a number");var C=i(o);return a!==void 0?typeof y=="string"?C.fill(a,y):C.fill(a):C.fill(0),C},c.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return i(o)},c.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(ie,ie.exports)),ie.exports}var qe;function ji(){if(qe)return fe;qe=1;var u=zi().Buffer,t=u.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(m){if(!m)return"utf8";for(var x;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(x)return;m=(""+m).toLowerCase(),x=!0}}function i(m){var x=e(m);if(typeof x!="string"&&(u.isEncoding===t||!t(m)))throw new Error("Unknown encoding: "+m);return x||m}fe.StringDecoder=s;function s(m){this.encoding=i(m);var x;switch(this.encoding){case"utf16le":this.text=B,this.end=A,x=4;break;case"utf8":this.fillLast=y,x=4;break;case"base64":this.text=D,this.end=F,x=3;break;default:this.write=R,this.end=N;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=u.allocUnsafe(x)}s.prototype.write=function(m){if(m.length===0)return"";var x,_;if(this.lastNeed){if(x=this.fillLast(m),x===void 0)return"";_=this.lastNeed,this.lastNeed=0}else _=0;return _<m.length?x?x+this.text(m,_):this.text(m,_):x||""},s.prototype.end=S,s.prototype.text=C,s.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function c(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function o(m,x,_){var f=x.length-1;if(f<_)return 0;var b=c(x[f]);return b>=0?(b>0&&(m.lastNeed=b-1),b):--f<_||b===-2?0:(b=c(x[f]),b>=0?(b>0&&(m.lastNeed=b-2),b):--f<_||b===-2?0:(b=c(x[f]),b>=0?(b>0&&(b===2?b=0:m.lastNeed=b-3),b):0))}function a(m,x,_){if((x[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&x.length>1){if((x[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&x.length>2&&(x[2]&192)!==128)return m.lastNeed=2,"�"}}function y(m){var x=this.lastTotal-this.lastNeed,_=a(this,m);if(_!==void 0)return _;if(this.lastNeed<=m.length)return m.copy(this.lastChar,x,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,x,0,m.length),this.lastNeed-=m.length}function C(m,x){var _=o(this,m,x);if(!this.lastNeed)return m.toString("utf8",x);this.lastTotal=_;var f=m.length-(_-this.lastNeed);return m.copy(this.lastChar,0,f),m.toString("utf8",x,f)}function S(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+"�":x}function B(m,x){if((m.length-x)%2===0){var _=m.toString("utf16le",x);if(_){var f=_.charCodeAt(_.length-1);if(f>=55296&&f<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],_.slice(0,-1)}return _}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",x,m.length-1)}function A(m){var x=m&&m.length?this.write(m):"";if(this.lastNeed){var _=this.lastTotal-this.lastNeed;return x+this.lastChar.toString("utf16le",0,_)}return x}function D(m,x){var _=(m.length-x)%3;return _===0?m.toString("base64",x):(this.lastNeed=3-_,this.lastTotal=3,_===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",x,m.length-_))}function F(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+this.lastChar.toString("base64",0,3-this.lastNeed):x}function R(m){return m.toString(this.encoding)}function N(m){return m&&m.length?this.write(m):""}return fe}var We;function Ki(){return We||(We=1,(function(u){(function(t){t.parser=function(d,l){return new i(d,l)},t.SAXParser=i,t.SAXStream=S,t.createStream=C,t.MAX_BUFFER_LENGTH=65536;var e=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function i(d,l){if(!(this instanceof i))return new i(d,l);var M=this;c(M),M.q=M.c="",M.bufferCheckPosition=t.MAX_BUFFER_LENGTH,M.opt=l||{},M.opt.lowercase=M.opt.lowercase||M.opt.lowercasetags,M.looseCase=M.opt.lowercase?"toLowerCase":"toUpperCase",M.tags=[],M.closed=M.closedRoot=M.sawRoot=!1,M.tag=M.error=null,M.strict=!!d,M.noscript=!!(d||M.opt.noscript),M.state=g.BEGIN,M.strictEntities=M.opt.strictEntities,M.ENTITIES=M.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),M.attribList=[],M.opt.xmlns&&(M.ns=Object.create(R)),M.opt.unquotedAttributeValues===void 0&&(M.opt.unquotedAttributeValues=!d),M.trackPosition=M.opt.position!==!1,M.trackPosition&&(M.position=M.line=M.column=0),Y(M,"onready")}Object.create||(Object.create=function(d){function l(){}l.prototype=d;var M=new l;return M}),Object.keys||(Object.keys=function(d){var l=[];for(var M in d)d.hasOwnProperty(M)&&l.push(M);return l});function s(d){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),M=0,E=0,Q=e.length;E<Q;E++){var lt=d[e[E]].length;if(lt>l)switch(e[E]){case"textNode":st(d);break;case"cdata":G(d,"oncdata",d.cdata),d.cdata="";break;case"script":G(d,"onscript",d.script),d.script="";break;default:at(d,"Max buffer length exceeded: "+e[E])}M=Math.max(M,lt)}var it=t.MAX_BUFFER_LENGTH-M;d.bufferCheckPosition=it+d.position}function c(d){for(var l=0,M=e.length;l<M;l++)d[e[l]]=""}function o(d){st(d),d.cdata!==""&&(G(d,"oncdata",d.cdata),d.cdata=""),d.script!==""&&(G(d,"onscript",d.script),d.script="")}i.prototype={end:function(){ot(this)},write:Rt,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){o(this)}};var a;try{a=Vi.Stream}catch{a=function(){}}a||(a=function(){});var y=t.EVENTS.filter(function(d){return d!=="error"&&d!=="end"});function C(d,l){return new S(d,l)}function S(d,l){if(!(this instanceof S))return new S(d,l);a.apply(this),this._parser=new i(d,l),this.writable=!0,this.readable=!0;var M=this;this._parser.onend=function(){M.emit("end")},this._parser.onerror=function(E){M.emit("error",E),M._parser.error=null},this._decoder=null,y.forEach(function(E){Object.defineProperty(M,"on"+E,{get:function(){return M._parser["on"+E]},set:function(Q){if(!Q)return M.removeAllListeners(E),M._parser["on"+E]=Q,Q;M.on(E,Q)},enumerable:!0,configurable:!1})})}S.prototype=Object.create(a.prototype,{constructor:{value:S}}),S.prototype.write=function(d){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(d)){if(!this._decoder){var l=ji().StringDecoder;this._decoder=new l("utf8")}d=this._decoder.write(d)}return this._parser.write(d.toString()),this.emit("data",d),!0},S.prototype.end=function(d){return d&&d.length&&this.write(d),this._parser.end(),!0},S.prototype.on=function(d,l){var M=this;return!M._parser["on"+d]&&y.indexOf(d)!==-1&&(M._parser["on"+d]=function(){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);E.splice(0,0,d),M.emit.apply(M,E)}),a.prototype.on.call(M,d,l)};var B="[CDATA[",A="DOCTYPE",D="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",R={xml:D,xmlns:F},N=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,x=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(d){return d===" "||d===`
|
|
87
|
+
`||d==="\r"||d===" "}function b(d){return d==='"'||d==="'"}function O(d){return d===">"||f(d)}function k(d,l){return d.test(l)}function L(d,l){return!k(d,l)}var g=0;t.STATE={BEGIN:g++,BEGIN_WHITESPACE:g++,TEXT:g++,TEXT_ENTITY:g++,OPEN_WAKA:g++,SGML_DECL:g++,SGML_DECL_QUOTED:g++,DOCTYPE:g++,DOCTYPE_QUOTED:g++,DOCTYPE_DTD:g++,DOCTYPE_DTD_QUOTED:g++,COMMENT_STARTING:g++,COMMENT:g++,COMMENT_ENDING:g++,COMMENT_ENDED:g++,CDATA:g++,CDATA_ENDING:g++,CDATA_ENDING_2:g++,PROC_INST:g++,PROC_INST_BODY:g++,PROC_INST_ENDING:g++,OPEN_TAG:g++,OPEN_TAG_SLASH:g++,ATTRIB:g++,ATTRIB_NAME:g++,ATTRIB_NAME_SAW_WHITE:g++,ATTRIB_VALUE:g++,ATTRIB_VALUE_QUOTED:g++,ATTRIB_VALUE_CLOSED:g++,ATTRIB_VALUE_UNQUOTED:g++,ATTRIB_VALUE_ENTITY_Q:g++,ATTRIB_VALUE_ENTITY_U:g++,CLOSE_TAG:g++,CLOSE_TAG_SAW_WHITE:g++,SCRIPT:g++,SCRIPT_ENDING:g++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(d){var l=t.ENTITIES[d],M=typeof l=="number"?String.fromCharCode(l):l;t.ENTITIES[d]=M});for(var q in t.STATE)t.STATE[t.STATE[q]]=q;g=t.STATE;function Y(d,l,M){d[l]&&d[l](M)}function G(d,l,M){d.textNode&&st(d),Y(d,l,M)}function st(d){d.textNode=ft(d.opt,d.textNode),d.textNode&&Y(d,"ontext",d.textNode),d.textNode=""}function ft(d,l){return d.trim&&(l=l.trim()),d.normalize&&(l=l.replace(/\s+/g," ")),l}function at(d,l){return st(d),d.trackPosition&&(l+=`
|
|
88
|
+
Line: `+d.line+`
|
|
89
|
+
Column: `+d.column+`
|
|
90
|
+
Char: `+d.c),l=new Error(l),d.error=l,Y(d,"onerror",l),d}function ot(d){return d.sawRoot&&!d.closedRoot&&K(d,"Unclosed root tag"),d.state!==g.BEGIN&&d.state!==g.BEGIN_WHITESPACE&&d.state!==g.TEXT&&at(d,"Unexpected end"),st(d),d.c="",d.closed=!0,Y(d,"onend"),i.call(d,d.strict,d.opt),d}function K(d,l){if(typeof d!="object"||!(d instanceof i))throw new Error("bad call to strictFail");d.strict&&at(d,l)}function gt(d){d.strict||(d.tagName=d.tagName[d.looseCase]());var l=d.tags[d.tags.length-1]||d,M=d.tag={name:d.tagName,attributes:{}};d.opt.xmlns&&(M.ns=l.ns),d.attribList.length=0,G(d,"onopentagstart",M)}function xt(d,l){var M=d.indexOf(":"),E=M<0?["",d]:d.split(":"),Q=E[0],lt=E[1];return l&&d==="xmlns"&&(Q="xmlns",lt=""),{prefix:Q,local:lt}}function mt(d){if(d.strict||(d.attribName=d.attribName[d.looseCase]()),d.attribList.indexOf(d.attribName)!==-1||d.tag.attributes.hasOwnProperty(d.attribName)){d.attribName=d.attribValue="";return}if(d.opt.xmlns){var l=xt(d.attribName,!0),M=l.prefix,E=l.local;if(M==="xmlns")if(E==="xml"&&d.attribValue!==D)K(d,"xml: prefix must be bound to "+D+`
|
|
91
|
+
Actual: `+d.attribValue);else if(E==="xmlns"&&d.attribValue!==F)K(d,"xmlns: prefix must be bound to "+F+`
|
|
92
|
+
Actual: `+d.attribValue);else{var Q=d.tag,lt=d.tags[d.tags.length-1]||d;Q.ns===lt.ns&&(Q.ns=Object.create(lt.ns)),Q.ns[E]=d.attribValue}d.attribList.push([d.attribName,d.attribValue])}else d.tag.attributes[d.attribName]=d.attribValue,G(d,"onattribute",{name:d.attribName,value:d.attribValue});d.attribName=d.attribValue=""}function W(d,l){if(d.opt.xmlns){var M=d.tag,E=xt(d.tagName);M.prefix=E.prefix,M.local=E.local,M.uri=M.ns[E.prefix]||"",M.prefix&&!M.uri&&(K(d,"Unbound namespace prefix: "+JSON.stringify(d.tagName)),M.uri=E.prefix);var Q=d.tags[d.tags.length-1]||d;M.ns&&Q.ns!==M.ns&&Object.keys(M.ns).forEach(function(ht){G(d,"onopennamespace",{prefix:ht,uri:M.ns[ht]})});for(var lt=0,it=d.attribList.length;lt<it;lt++){var U=d.attribList[lt],z=U[0],X=U[1],j=xt(z,!0),$=j.prefix,ct=j.local,ut=$===""?"":M.ns[$]||"",rt={name:z,value:X,prefix:$,local:ct,uri:ut};$&&$!=="xmlns"&&!ut&&(K(d,"Unbound namespace prefix: "+JSON.stringify($)),rt.uri=$),d.tag.attributes[z]=rt,G(d,"onattribute",rt)}d.attribList.length=0}d.tag.isSelfClosing=!!l,d.sawRoot=!0,d.tags.push(d.tag),G(d,"onopentag",d.tag),l||(!d.noscript&&d.tagName.toLowerCase()==="script"?d.state=g.SCRIPT:d.state=g.TEXT,d.tag=null,d.tagName=""),d.attribName=d.attribValue="",d.attribList.length=0}function tt(d){if(!d.tagName){K(d,"Weird empty close tag."),d.textNode+="</>",d.state=g.TEXT;return}if(d.script){if(d.tagName!=="script"){d.script+="</"+d.tagName+">",d.tagName="",d.state=g.SCRIPT;return}G(d,"onscript",d.script),d.script=""}var l=d.tags.length,M=d.tagName;d.strict||(M=M[d.looseCase]());for(var E=M;l--;){var Q=d.tags[l];if(Q.name!==E)K(d,"Unexpected close tag");else break}if(l<0){K(d,"Unmatched closing tag: "+d.tagName),d.textNode+="</"+d.tagName+">",d.state=g.TEXT;return}d.tagName=M;for(var lt=d.tags.length;lt-- >l;){var it=d.tag=d.tags.pop();d.tagName=d.tag.name,G(d,"onclosetag",d.tagName);var U={};for(var z in it.ns)U[z]=it.ns[z];var X=d.tags[d.tags.length-1]||d;d.opt.xmlns&&it.ns!==X.ns&&Object.keys(it.ns).forEach(function(j){var $=it.ns[j];G(d,"onclosenamespace",{prefix:j,uri:$})})}l===0&&(d.closedRoot=!0),d.tagName=d.attribValue=d.attribName="",d.attribList.length=0,d.state=g.TEXT}function Tt(d){var l=d.entity,M=l.toLowerCase(),E,Q="";return d.ENTITIES[l]?d.ENTITIES[l]:d.ENTITIES[M]?d.ENTITIES[M]:(l=M,l.charAt(0)==="#"&&(l.charAt(1)==="x"?(l=l.slice(2),E=parseInt(l,16),Q=E.toString(16)):(l=l.slice(1),E=parseInt(l,10),Q=E.toString(10))),l=l.replace(/^0+/,""),isNaN(E)||Q.toLowerCase()!==l?(K(d,"Invalid character entity"),"&"+d.entity+";"):String.fromCodePoint(E))}function vt(d,l){l==="<"?(d.state=g.OPEN_WAKA,d.startTagPosition=d.position):f(l)||(K(d,"Non-whitespace before first tag."),d.textNode=l,d.state=g.TEXT)}function Ft(d,l){var M="";return l<d.length&&(M=d.charAt(l)),M}function Rt(d){var l=this;if(this.error)throw this.error;if(l.closed)return at(l,"Cannot write after close. Assign an onready handler.");if(d===null)return ot(l);typeof d=="object"&&(d=d.toString());for(var M=0,E="";E=Ft(d,M++),l.c=E,!!E;)switch(l.trackPosition&&(l.position++,E===`
|
|
93
|
+
`?(l.line++,l.column=0):l.column++),l.state){case g.BEGIN:if(l.state=g.BEGIN_WHITESPACE,E==="\uFEFF")continue;vt(l,E);continue;case g.BEGIN_WHITESPACE:vt(l,E);continue;case g.TEXT:if(l.sawRoot&&!l.closedRoot){for(var Q=M-1;E&&E!=="<"&&E!=="&";)E=Ft(d,M++),E&&l.trackPosition&&(l.position++,E===`
|
|
94
|
+
`?(l.line++,l.column=0):l.column++);l.textNode+=d.substring(Q,M-1)}E==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):(!f(E)&&(!l.sawRoot||l.closedRoot)&&K(l,"Text data outside of root node."),E==="&"?l.state=g.TEXT_ENTITY:l.textNode+=E);continue;case g.SCRIPT:E==="<"?l.state=g.SCRIPT_ENDING:l.script+=E;continue;case g.SCRIPT_ENDING:E==="/"?l.state=g.CLOSE_TAG:(l.script+="<"+E,l.state=g.SCRIPT);continue;case g.OPEN_WAKA:if(E==="!")l.state=g.SGML_DECL,l.sgmlDecl="";else if(!f(E))if(k(N,E))l.state=g.OPEN_TAG,l.tagName=E;else if(E==="/")l.state=g.CLOSE_TAG,l.tagName="";else if(E==="?")l.state=g.PROC_INST,l.procInstName=l.procInstBody="";else{if(K(l,"Unencoded <"),l.startTagPosition+1<l.position){var lt=l.position-l.startTagPosition;E=new Array(lt).join(" ")+E}l.textNode+="<"+E,l.state=g.TEXT}continue;case g.SGML_DECL:if(l.sgmlDecl+E==="--"){l.state=g.COMMENT,l.comment="",l.sgmlDecl="";continue}l.doctype&&l.doctype!==!0&&l.sgmlDecl?(l.state=g.DOCTYPE_DTD,l.doctype+="<!"+l.sgmlDecl+E,l.sgmlDecl=""):(l.sgmlDecl+E).toUpperCase()===B?(G(l,"onopencdata"),l.state=g.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+E).toUpperCase()===A?(l.state=g.DOCTYPE,(l.doctype||l.sawRoot)&&K(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):E===">"?(G(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=g.TEXT):(b(E)&&(l.state=g.SGML_DECL_QUOTED),l.sgmlDecl+=E);continue;case g.SGML_DECL_QUOTED:E===l.q&&(l.state=g.SGML_DECL,l.q=""),l.sgmlDecl+=E;continue;case g.DOCTYPE:E===">"?(l.state=g.TEXT,G(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=E,E==="["?l.state=g.DOCTYPE_DTD:b(E)&&(l.state=g.DOCTYPE_QUOTED,l.q=E));continue;case g.DOCTYPE_QUOTED:l.doctype+=E,E===l.q&&(l.q="",l.state=g.DOCTYPE);continue;case g.DOCTYPE_DTD:E==="]"?(l.doctype+=E,l.state=g.DOCTYPE):E==="<"?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):b(E)?(l.doctype+=E,l.state=g.DOCTYPE_DTD_QUOTED,l.q=E):l.doctype+=E;continue;case g.DOCTYPE_DTD_QUOTED:l.doctype+=E,E===l.q&&(l.state=g.DOCTYPE_DTD,l.q="");continue;case g.COMMENT:E==="-"?l.state=g.COMMENT_ENDING:l.comment+=E;continue;case g.COMMENT_ENDING:E==="-"?(l.state=g.COMMENT_ENDED,l.comment=ft(l.opt,l.comment),l.comment&&G(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+E,l.state=g.COMMENT);continue;case g.COMMENT_ENDED:E!==">"?(K(l,"Malformed comment"),l.comment+="--"+E,l.state=g.COMMENT):l.doctype&&l.doctype!==!0?l.state=g.DOCTYPE_DTD:l.state=g.TEXT;continue;case g.CDATA:E==="]"?l.state=g.CDATA_ENDING:l.cdata+=E;continue;case g.CDATA_ENDING:E==="]"?l.state=g.CDATA_ENDING_2:(l.cdata+="]"+E,l.state=g.CDATA);continue;case g.CDATA_ENDING_2:E===">"?(l.cdata&&G(l,"oncdata",l.cdata),G(l,"onclosecdata"),l.cdata="",l.state=g.TEXT):E==="]"?l.cdata+="]":(l.cdata+="]]"+E,l.state=g.CDATA);continue;case g.PROC_INST:E==="?"?l.state=g.PROC_INST_ENDING:f(E)?l.state=g.PROC_INST_BODY:l.procInstName+=E;continue;case g.PROC_INST_BODY:if(!l.procInstBody&&f(E))continue;E==="?"?l.state=g.PROC_INST_ENDING:l.procInstBody+=E;continue;case g.PROC_INST_ENDING:E===">"?(G(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=g.TEXT):(l.procInstBody+="?"+E,l.state=g.PROC_INST_BODY);continue;case g.OPEN_TAG:k(m,E)?l.tagName+=E:(gt(l),E===">"?W(l):E==="/"?l.state=g.OPEN_TAG_SLASH:(f(E)||K(l,"Invalid character in tag name"),l.state=g.ATTRIB));continue;case g.OPEN_TAG_SLASH:E===">"?(W(l,!0),tt(l)):(K(l,"Forward-slash in opening tag not followed by >"),l.state=g.ATTRIB);continue;case g.ATTRIB:if(f(E))continue;E===">"?W(l):E==="/"?l.state=g.OPEN_TAG_SLASH:k(N,E)?(l.attribName=E,l.attribValue="",l.state=g.ATTRIB_NAME):K(l,"Invalid attribute name");continue;case g.ATTRIB_NAME:E==="="?l.state=g.ATTRIB_VALUE:E===">"?(K(l,"Attribute without value"),l.attribValue=l.attribName,mt(l),W(l)):f(E)?l.state=g.ATTRIB_NAME_SAW_WHITE:k(m,E)?l.attribName+=E:K(l,"Invalid attribute name");continue;case g.ATTRIB_NAME_SAW_WHITE:if(E==="=")l.state=g.ATTRIB_VALUE;else{if(f(E))continue;K(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",G(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",E===">"?W(l):k(N,E)?(l.attribName=E,l.state=g.ATTRIB_NAME):(K(l,"Invalid attribute name"),l.state=g.ATTRIB)}continue;case g.ATTRIB_VALUE:if(f(E))continue;b(E)?(l.q=E,l.state=g.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||at(l,"Unquoted attribute value"),l.state=g.ATTRIB_VALUE_UNQUOTED,l.attribValue=E);continue;case g.ATTRIB_VALUE_QUOTED:if(E!==l.q){E==="&"?l.state=g.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=E;continue}mt(l),l.q="",l.state=g.ATTRIB_VALUE_CLOSED;continue;case g.ATTRIB_VALUE_CLOSED:f(E)?l.state=g.ATTRIB:E===">"?W(l):E==="/"?l.state=g.OPEN_TAG_SLASH:k(N,E)?(K(l,"No whitespace between attributes"),l.attribName=E,l.attribValue="",l.state=g.ATTRIB_NAME):K(l,"Invalid attribute name");continue;case g.ATTRIB_VALUE_UNQUOTED:if(!O(E)){E==="&"?l.state=g.ATTRIB_VALUE_ENTITY_U:l.attribValue+=E;continue}mt(l),E===">"?W(l):l.state=g.ATTRIB;continue;case g.CLOSE_TAG:if(l.tagName)E===">"?tt(l):k(m,E)?l.tagName+=E:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=g.SCRIPT):(f(E)||K(l,"Invalid tagname in closing tag"),l.state=g.CLOSE_TAG_SAW_WHITE);else{if(f(E))continue;L(N,E)?l.script?(l.script+="</"+E,l.state=g.SCRIPT):K(l,"Invalid tagname in closing tag."):l.tagName=E}continue;case g.CLOSE_TAG_SAW_WHITE:if(f(E))continue;E===">"?tt(l):K(l,"Invalid characters in closing tag");continue;case g.TEXT_ENTITY:case g.ATTRIB_VALUE_ENTITY_Q:case g.ATTRIB_VALUE_ENTITY_U:var it,U;switch(l.state){case g.TEXT_ENTITY:it=g.TEXT,U="textNode";break;case g.ATTRIB_VALUE_ENTITY_Q:it=g.ATTRIB_VALUE_QUOTED,U="attribValue";break;case g.ATTRIB_VALUE_ENTITY_U:it=g.ATTRIB_VALUE_UNQUOTED,U="attribValue";break}if(E===";"){var z=Tt(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(z)?(l.entity="",l.state=it,l.write(z)):(l[U]+=z,l.entity="",l.state=it)}else k(l.entity.length?_:x,E)?l.entity+=E:(K(l,"Invalid character in entity name"),l[U]+="&"+l.entity+E,l.entity="",l.state=it);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}String.fromCodePoint||(function(){var d=String.fromCharCode,l=Math.floor,M=function(){var E=16384,Q=[],lt,it,U=-1,z=arguments.length;if(!z)return"";for(var X="";++U<z;){var j=Number(arguments[U]);if(!isFinite(j)||j<0||j>1114111||l(j)!==j)throw RangeError("Invalid code point: "+j);j<=65535?Q.push(j):(j-=65536,lt=(j>>10)+55296,it=j%1024+56320,Q.push(lt,it)),(U+1===z||Q.length>E)&&(X+=d.apply(null,Q),Q.length=0)}return X};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:M,configurable:!0,writable:!0}):String.fromCodePoint=M})()})(u)})(he)),he}var pe,He;function me(){return He||(He=1,pe={isArray:function(u){return Array.isArray?Array.isArray(u):Object.prototype.toString.call(u)==="[object Array]"}}),pe}var _e,Xe;function ye(){if(Xe)return _e;Xe=1;var u=me().isArray;return _e={copyOptions:function(t){var e,i={};for(e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i},ensureFlagExists:function(t,e){(!(t in e)||typeof e[t]!="boolean")&&(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||typeof t.spaces!="number"&&typeof t.spaces!="string")&&(t.spaces=0)},ensureAlwaysArrayExists:function(t){(!("alwaysArray"in t)||typeof t.alwaysArray!="boolean"&&!u(t.alwaysArray))&&(t.alwaysArray=!1)},ensureKeyExists:function(t,e){(!(t+"Key"in e)||typeof e[t+"Key"]!="string")&&(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}},_e}var ge,$e;function Qe(){if($e)return ge;$e=1;var u=Ki(),t=ye(),e=me().isArray,i,s;function c(m){return i=t.copyOptions(m),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function o(m){var x=Number(m);if(!isNaN(x))return x;var _=m.toLowerCase();return _==="true"?!0:_==="false"?!1:m}function a(m,x){var _;if(i.compact){if(!s[i[m+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[m+"Key"])!==-1:i.alwaysArray)&&(s[i[m+"Key"]]=[]),s[i[m+"Key"]]&&!e(s[i[m+"Key"]])&&(s[i[m+"Key"]]=[s[i[m+"Key"]]]),m+"Fn"in i&&typeof x=="string"&&(x=i[m+"Fn"](x,s)),m==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(_ in x)if(x.hasOwnProperty(_))if("instructionFn"in i)x[_]=i.instructionFn(x[_],_,s);else{var f=x[_];delete x[_],x[i.instructionNameFn(_,f,s)]=f}}e(s[i[m+"Key"]])?s[i[m+"Key"]].push(x):s[i[m+"Key"]]=x}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=m,m==="instruction"){for(_ in x)if(x.hasOwnProperty(_))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(_,x,s):_,i.instructionHasAttributes?(b[i.attributesKey]=x[_][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],_,s))):("instructionFn"in i&&(x[_]=i.instructionFn(x[_],_,s)),b[i.instructionKey]=x[_])}else m+"Fn"in i&&(x=i[m+"Fn"](x,s)),b[i[m+"Key"]]=x;i.addParent&&(b[i.parentKey]=s),s[i.elementsKey].push(b)}}function y(m){if("attributesFn"in i&&m&&(m=i.attributesFn(m,s)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&m){var x;for(x in m)if(m.hasOwnProperty(x)&&(i.trim&&(m[x]=m[x].trim()),i.nativeTypeAttributes&&(m[x]=o(m[x])),"attributeValueFn"in i&&(m[x]=i.attributeValueFn(m[x],x,s)),"attributeNameFn"in i)){var _=m[x];delete m[x],m[i.attributeNameFn(x,m[x],s)]=_}}return m}function C(m){var x={};if(m.body&&(m.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var _=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,f;(f=_.exec(m.body))!==null;)x[f[1]]=f[2]||f[3]||f[4];x=y(x)}if(m.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(x).length&&(s[i.declarationKey][i.attributesKey]=x),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(m.body=m.body.trim());var b={};i.instructionHasAttributes&&Object.keys(x).length?(b[m.name]={},b[m.name][i.attributesKey]=x):b[m.name]=m.body,a("instruction",b)}}function S(m,x){var _;if(typeof m=="object"&&(x=m.attributes,m=m.name),x=y(x),"elementNameFn"in i&&(m=i.elementNameFn(m,s)),i.compact){if(_={},!i.ignoreAttributes&&x&&Object.keys(x).length){_[i.attributesKey]={};var f;for(f in x)x.hasOwnProperty(f)&&(_[i.attributesKey][f]=x[f])}!(m in s)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(m)!==-1:i.alwaysArray)&&(s[m]=[]),s[m]&&!e(s[m])&&(s[m]=[s[m]]),e(s[m])?s[m].push(_):s[m]=_}else s[i.elementsKey]||(s[i.elementsKey]=[]),_={},_[i.typeKey]="element",_[i.nameKey]=m,!i.ignoreAttributes&&x&&Object.keys(x).length&&(_[i.attributesKey]=x),i.alwaysChildren&&(_[i.elementsKey]=[]),s[i.elementsKey].push(_);_[i.parentKey]=s,s=_}function B(m){i.ignoreText||!m.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(m=m.trim()),i.nativeType&&(m=o(m)),i.sanitize&&(m=m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),a("text",m))}function A(m){i.ignoreComment||(i.trim&&(m=m.trim()),a("comment",m))}function D(m){var x=s[i.parentKey];i.addParent||delete s[i.parentKey],s=x}function F(m){i.ignoreCdata||(i.trim&&(m=m.trim()),a("cdata",m))}function R(m){i.ignoreDoctype||(m=m.replace(/^ /,""),i.trim&&(m=m.trim()),a("doctype",m))}function N(m){m.note=m}return ge=function(m,x){var _=u.parser(!0,{}),f={};if(s=f,i=c(x),_.opt={strictEntities:!0},_.onopentag=S,_.ontext=B,_.oncomment=A,_.onclosetag=D,_.onerror=N,_.oncdata=F,_.ondoctype=R,_.onprocessinginstruction=C,_.write(m).close(),f[i.elementsKey]){var b=f[i.elementsKey];delete f[i.elementsKey],f[i.elementsKey]=b,delete f.text}return f},ge}var xe,Je;function qi(){if(Je)return xe;Je=1;var u=ye(),t=Qe();function e(i){var s=u.copyOptions(i);return u.ensureSpacesExists(s),s}return xe=function(i,s){var c,o,a,y;return c=e(s),o=t(i,c),y="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?a=JSON.stringify(o,function(C,S){return C===y?"_":S},c.spaces):a=JSON.stringify(o,null,c.spaces),a.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},xe}var we,Ze;function ti(){if(Ze)return we;Ze=1;var u=ye(),t=me().isArray,e,i;function s(_){var f=u.copyOptions(_);return u.ensureFlagExists("ignoreDeclaration",f),u.ensureFlagExists("ignoreInstruction",f),u.ensureFlagExists("ignoreAttributes",f),u.ensureFlagExists("ignoreText",f),u.ensureFlagExists("ignoreComment",f),u.ensureFlagExists("ignoreCdata",f),u.ensureFlagExists("ignoreDoctype",f),u.ensureFlagExists("compact",f),u.ensureFlagExists("indentText",f),u.ensureFlagExists("indentCdata",f),u.ensureFlagExists("indentAttributes",f),u.ensureFlagExists("indentInstruction",f),u.ensureFlagExists("fullTagEmptyElement",f),u.ensureFlagExists("noQuotesForNativeAttributes",f),u.ensureSpacesExists(f),typeof f.spaces=="number"&&(f.spaces=Array(f.spaces+1).join(" ")),u.ensureKeyExists("declaration",f),u.ensureKeyExists("instruction",f),u.ensureKeyExists("attributes",f),u.ensureKeyExists("text",f),u.ensureKeyExists("comment",f),u.ensureKeyExists("cdata",f),u.ensureKeyExists("doctype",f),u.ensureKeyExists("type",f),u.ensureKeyExists("name",f),u.ensureKeyExists("elements",f),u.checkFnExists("doctype",f),u.checkFnExists("instruction",f),u.checkFnExists("cdata",f),u.checkFnExists("comment",f),u.checkFnExists("text",f),u.checkFnExists("instructionName",f),u.checkFnExists("elementName",f),u.checkFnExists("attributeName",f),u.checkFnExists("attributeValue",f),u.checkFnExists("attributes",f),u.checkFnExists("fullTagEmptyElement",f),f}function c(_,f,b){return(!b&&_.spaces?`
|
|
95
|
+
`:"")+Array(f+1).join(_.spaces)}function o(_,f,b){if(f.ignoreAttributes)return"";"attributesFn"in f&&(_=f.attributesFn(_,i,e));var O,k,L,g,q=[];for(O in _)_.hasOwnProperty(O)&&_[O]!==null&&_[O]!==void 0&&(g=f.noQuotesForNativeAttributes&&typeof _[O]!="string"?"":'"',k=""+_[O],k=k.replace(/"/g,"""),L="attributeNameFn"in f?f.attributeNameFn(O,k,i,e):O,q.push(f.spaces&&f.indentAttributes?c(f,b+1,!1):" "),q.push(L+"="+g+("attributeValueFn"in f?f.attributeValueFn(k,O,i,e):k)+g));return _&&Object.keys(_).length&&f.spaces&&f.indentAttributes&&q.push(c(f,b,!1)),q.join("")}function a(_,f,b){return e=_,i="xml",f.ignoreDeclaration?"":"<?xml"+o(_[f.attributesKey],f,b)+"?>"}function y(_,f,b){if(f.ignoreInstruction)return"";var O;for(O in _)if(_.hasOwnProperty(O))break;var k="instructionNameFn"in f?f.instructionNameFn(O,_[O],i,e):O;if(typeof _[O]=="object")return e=_,i=k,"<?"+k+o(_[O][f.attributesKey],f,b)+"?>";var L=_[O]?_[O]:"";return"instructionFn"in f&&(L=f.instructionFn(L,O,i,e)),"<?"+k+(L?" "+L:"")+"?>"}function C(_,f){return f.ignoreComment?"":"<!--"+("commentFn"in f?f.commentFn(_,i,e):_)+"-->"}function S(_,f){return f.ignoreCdata?"":"<![CDATA["+("cdataFn"in f?f.cdataFn(_,i,e):_.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function B(_,f){return f.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in f?f.doctypeFn(_,i,e):_)+">"}function A(_,f){return f.ignoreText?"":(_=""+_,_=_.replace(/&/g,"&"),_=_.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"textFn"in f?f.textFn(_,i,e):_)}function D(_,f){var b;if(_.elements&&_.elements.length)for(b=0;b<_.elements.length;++b)switch(_.elements[b][f.typeKey]){case"text":if(f.indentText)return!0;break;case"cdata":if(f.indentCdata)return!0;break;case"instruction":if(f.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function F(_,f,b){e=_,i=_.name;var O=[],k="elementNameFn"in f?f.elementNameFn(_.name,_):_.name;O.push("<"+k),_[f.attributesKey]&&O.push(o(_[f.attributesKey],f,b));var L=_[f.elementsKey]&&_[f.elementsKey].length||_[f.attributesKey]&&_[f.attributesKey]["xml:space"]==="preserve";return L||("fullTagEmptyElementFn"in f?L=f.fullTagEmptyElementFn(_.name,_):L=f.fullTagEmptyElement),L?(O.push(">"),_[f.elementsKey]&&_[f.elementsKey].length&&(O.push(R(_[f.elementsKey],f,b+1)),e=_,i=_.name),O.push(f.spaces&&D(_,f)?`
|
|
96
|
+
`+Array(b+1).join(f.spaces):""),O.push("</"+k+">")):O.push("/>"),O.join("")}function R(_,f,b,O){return _.reduce(function(k,L){var g=c(f,b,O&&!k);switch(L.type){case"element":return k+g+F(L,f,b);case"comment":return k+g+C(L[f.commentKey],f);case"doctype":return k+g+B(L[f.doctypeKey],f);case"cdata":return k+(f.indentCdata?g:"")+S(L[f.cdataKey],f);case"text":return k+(f.indentText?g:"")+A(L[f.textKey],f);case"instruction":var q={};return q[L[f.nameKey]]=L[f.attributesKey]?L:L[f.instructionKey],k+(f.indentInstruction?g:"")+y(q,f,b)}},"")}function N(_,f,b){var O;for(O in _)if(_.hasOwnProperty(O))switch(O){case f.parentKey:case f.attributesKey:break;case f.textKey:if(f.indentText||b)return!0;break;case f.cdataKey:if(f.indentCdata||b)return!0;break;case f.instructionKey:if(f.indentInstruction||b)return!0;break;case f.doctypeKey:case f.commentKey:return!0;default:return!0}return!1}function m(_,f,b,O,k){e=_,i=f;var L="elementNameFn"in b?b.elementNameFn(f,_):f;if(typeof _>"u"||_===null||_==="")return"fullTagEmptyElementFn"in b&&b.fullTagEmptyElementFn(f,_)||b.fullTagEmptyElement?"<"+L+"></"+L+">":"<"+L+"/>";var g=[];if(f){if(g.push("<"+L),typeof _!="object")return g.push(">"+A(_,b)+"</"+L+">"),g.join("");_[b.attributesKey]&&g.push(o(_[b.attributesKey],b,O));var q=N(_,b,!0)||_[b.attributesKey]&&_[b.attributesKey]["xml:space"]==="preserve";if(q||("fullTagEmptyElementFn"in b?q=b.fullTagEmptyElementFn(f,_):q=b.fullTagEmptyElement),q)g.push(">");else return g.push("/>"),g.join("")}return g.push(x(_,b,O+1,!1)),e=_,i=f,f&&g.push((k?c(b,O,!1):"")+"</"+L+">"),g.join("")}function x(_,f,b,O){var k,L,g,q=[];for(L in _)if(_.hasOwnProperty(L))for(g=t(_[L])?_[L]:[_[L]],k=0;k<g.length;++k){switch(L){case f.declarationKey:q.push(a(g[k],f,b));break;case f.instructionKey:q.push((f.indentInstruction?c(f,b,O):"")+y(g[k],f,b));break;case f.attributesKey:case f.parentKey:break;case f.textKey:q.push((f.indentText?c(f,b,O):"")+A(g[k],f));break;case f.cdataKey:q.push((f.indentCdata?c(f,b,O):"")+S(g[k],f));break;case f.doctypeKey:q.push(c(f,b,O)+B(g[k],f));break;case f.commentKey:q.push(c(f,b,O)+C(g[k],f));break;default:q.push(c(f,b,O)+m(g[k],L,f,b,N(g[k],f)))}O=O&&!q.length}return q.join("")}return we=function(_,f){f=s(f);var b=[];return e=_,i="_root_",f.compact?b.push(x(_,f,0,!0)):(_[f.declarationKey]&&b.push(a(_[f.declarationKey],f,0)),_[f.elementsKey]&&_[f.elementsKey].length&&b.push(R(_[f.elementsKey],f,0,!b.length))),b.join("")},we}var Ee,ei;function Wi(){if(ei)return Ee;ei=1;var u=ti();return Ee=function(t,e){t instanceof Buffer&&(t=t.toString());var i=null;if(typeof t=="string")try{i=JSON.parse(t)}catch{throw new Error("The JSON structure is invalid")}else i=t;return u(i,e)},Ee}var ve,ii;function Hi(){if(ii)return ve;ii=1;var u=Qe(),t=qi(),e=ti(),i=Wi();return ve={xml2js:u,xml2json:t,js2xml:e,json2xml:i},ve}var Se=Hi(),Xi=je();const bt=class bt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let o={...s,...c,...bt.propToNumber(c,["version","width","height","tilewidth","tileheight","nextlayerid","nextobjectid","hexsidelength","opacity","x","y","offsetx","offsety","startx","starty","id","firstgid","imageheight","imagewidth","margin","columns","rows","tilecount","rotation","gid","tileid","duration","parallaxx","parallaxy","repeatx","repeaty","pixelsize"]),...bt.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(o.properties){const y=bt.toArray(o.properties.property),C={};for(let S of y){const B=S._attributes;if(!B)continue;let A;switch(B.type){case"file":A=this.getImagePath(B.value);break;case"object":case"float":case"int":A=+B.value;break;case"bool":A=B.value=="true";break;case"class":A={...this.transform(S)?.properties??{},_classname:B.propertytype};break;default:A=B.value}C[B.name]=A}o.properties=C}o.polygon&&(o.polygon=this.transform(o.polygon)),o.polyline&&(o.polyline=this.transform(o.polyline)),o.points&&(o=o.points.split(" ").map(y=>{const C=y.split(",");return{x:+C[0],y:+C[1]}})),o.point&&(o.point=!0),o.ellipse&&(o.ellipse=!0),o.text&&(o.text={text:o.text._text,...this.transform(o.text)},delete o.text._text),o.image&&(o.image=this.transform(o.image)),o.source&&(this.isTilesetSource(o)||(o.source=this.getImagePath(o.source)));const a=o.object||o.objectgroup?.object;return a&&(o.objects=bt.toArray(a).map(y=>this.transform(y))),delete o._attributes,delete o.attributes,delete o.object,delete o.objectgroup,o}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:Ve(this.basePath,t)}isTilesetSource(t){return t.firstgid!==void 0||t.tilewidth!==void 0||t.tileheight!==void 0||t.tilecount!==void 0||t.columns!==void 0}static unpackTileBytes(t,e){const i=e*4;if(t.length!==i)throw new Error("Expected "+i+" bytes of tile data; received "+t.length);let s=0;const c=[];for(let o=0;o<i;o+=4)c[s]=t.readUInt32LE(o),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?bt.unpackTileBytes(Xi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=Se.xml2js(this.xml,{compact:!0}),e=Se.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=C=>{const{objectgroup:S,group:B,layer:A,imagelayer:D}=C,F=R=>{R&&bt.toArray(R).forEach(N=>{if(this.layers.has(+N._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${N._attributes.id} already exists`);this.layers.set(+N._attributes.id,N)})};F(S),F(A),F(B),F(D),B&&s(B)};s(t.map);const c=(C,S=[])=>{if(!C)return S;for(let B of C){const{name:A}=B;if(!["layer","group","imagelayer","objectgroup"].includes(A))continue;const D=B.elements?.find(R=>R.name=="data");B.layer=this.layers.get(+B.attributes.id);const F={...this.transform(D)??{},...this.transform(B),...this.transform(B.layer),layers:c(B.elements),data:D?D.elements[0].text:void 0,type:A=="layer"?"tilelayer":A};delete F.elements,delete F.layer,F.data&&(F.data=bt.decode(F,F.width*F.height)),S.push(F)}return S},o=c(e.elements[0].elements),a=bt.toArray(i).map(C=>this.transform(C)),y={...this.transform(t.map),layers:o,tilesets:a};return delete y.layer,delete y.tileset,delete y.group,delete y.imagelayer,y}parseTileset(){const t=Se.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:bt.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=bt.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};bt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},bt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let Te=bt;class be{constructor(t){this.properties={},this.properties=t?.properties??{}}getProperty(t,e){const i=this.properties[t];return i===void 0?e:i}hasProperty(t){return!!this.properties[t]}setProperty(t,e){this.properties[t]=e}getType(){return this.class||this.type}}const $i=2147483648,Qi=1073741824,Ji=536870912,Zi=268435456;class $t extends be{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&$i)}get verticalFlip(){return!!(this._gid&Qi)}get diagonalFlip(){return!!(this._gid&Ji)}get rotatedHex120(){return!!(this._gid&Zi)}get gid(){return $t.getRealGid(this._gid)}set gid(t){this._gid=t}}let Ae=class extends $t{constructor(t){super(t),this.tile=t;const e=this.properties;Reflect.deleteProperty(t,"gid"),Object.assign(this,t),e&&Object.keys(e).length>0&&(this.properties={...e,...this.properties})}};class tr extends $t{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class Ce extends be{constructor(t,e,i){super(t),this.tilesets=e,this.parent=i,this.cacheTiles=!1,this.tiles=[],Object.assign(this,t),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty("cache-tiles",!1),this.cacheTiles&&this.propertiesTiles()}get size(){return this.data.length}createTile(t,e,i){if(t==0)return;const s=$t.getRealGid(t),c=Ce.findTileSet(s,this.tilesets);if(!c)return;const o=c.getTile(s-c.firstgid);return o?new Ae({...o.tile,gid:t,index:e,layerIndex:i}):new Ae({gid:t,index:e,layerIndex:i})}mergePropertiesWithParent(){const t=this.getLayerParent();if(this.properties||(this.properties={}),!!t){for(let e in t.properties){const i=t.properties[e];if(this.properties[e]===void 0)this.properties[e]=i;else if(e=="z")this.properties[e]+=i;else continue}this.opacity=Math.round((t.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(t.offsetx??0)+(this.offsetx??0),this.offsety=(t.offsety??0)+(this.offsety??0),this.locked=t.locked??!1}}propertiesTiles(){if(!this.data)return;const t=this.data;for(let e=0;e<t.length;e++){const i=t[e];this.tiles.push(this.createTile(i,e))}}mapObjects(){this.objects&&(this.objects=this.objects.map(t=>{const e=new tr(t);return e.layerName=this.name,e}))}getTileByIndex(t){return this.cacheTiles?this.tiles[t]:this.createTile(this.data[t],t)}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}getLayerParent(){return this.parent}tilesForEach(t){for(let e=0;e<this.data.length;e++){if(this.cacheTiles){t(this.tiles[e],e);continue}t(this.createTile(this.data[e],e),e)}}setData(t,e){this.data[t]=e}}class er extends be{constructor(t){super(t),this.tileset=t,this.cacheTileId=new Map,Object.assign(this,t),this.margin=this.margin??0,this.spacing=this.spacing??0;const e=t.tiles||t.tile||[];for(let i of e)this.addTile(i);Reflect.deleteProperty(this,"tiles"),Reflect.deleteProperty(this,"tile")}addTile(t){const e=new Ae(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class kt{constructor(t,{basePath:e="",staticDir:i="",relativePath:s=""}={}){this.file=t,this.basePath=e}static isBrowser(){return typeof window<"u"&&!window.useFileSystem}static typeOfFile(t){t=t.trim();const e=typeof t=="string",i={isXml:e&&t.startsWith("<?xml"),isObject:!!t.version,isHttp:e&&t.startsWith("http")};return{...i,isPath:!i.isXml&&!i.isObject&&!i.isHttp}}_parseFile(t,e,i){const s=a=>kt.typeOfFile(a).isXml,c=a=>{if(!a)return i(null);if(s(a)){const y=new Te(a,t,this.basePath);if(e=="map"){const C=y.parseMap();return i(C)}else if(e=="tileset"){const C=y.parseTileset();return i(C)}}return i(JSON.parse(a))};if(kt.typeOfFile(t).isObject)return i(t);const{isHttp:o}=kt.typeOfFile(t);if(s(t))c(t);else if(o||kt.isBrowser()){let a=o?t:Ve(this.basePath,t);kt.isBrowser()&&window.urlCache&&(a=window.urlCache[t]),fetch(a,{headers:{"Content-Type":"application/xml"}}).then(y=>y.text()).then(c).catch(y=>i(null,y))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,s=c=>c.substring(c.lastIndexOf("/")+1);i&&kt.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,o)=>{let a=!1;if(o)return t(null,o);if(c.tilesets){const y=[],C=()=>{S++,S==c.tilesets.length&&!a&&(c.tilesets=y,t(c))};let S=0;for(let B=0;B<c.tilesets.length;B++){const A=c.tilesets[B];if(!A.source||A.tiles||A.image||A.tile){y[B]=A,C();continue}i&&kt.typeOfFile(A.source).isPath&&(A.source=s(A.source)),this._parseFile(A.source,"tileset",(D,F)=>{if(F)return a=!0,t(null,F);y[B]={...D,firstgid:A.firstgid},C()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const Ut={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var ir=Object.defineProperty,rr=(u,t,e)=>t in u?ir(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Lt=(u,t,e)=>(rr(u,typeof t!="symbol"?t+"":t,e),e);const Qt=class Zt extends P.Geometry{constructor(t){const e=new P.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:P.BufferUsage.VERTEX|P.BufferUsage.COPY_DST,shrinkToFit:!1}),i=Zt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:8},aFrame:{buffer:e,format:"float32x4",stride:i,offset:16},aAnim:{buffer:e,format:"float32x2",stride:i,offset:32},aTextureId:{buffer:e,format:"sint32",stride:i,offset:40},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:44},aAlpha:{buffer:e,format:"float32",stride:i,offset:48}}}),Lt(this,"lastTimeAccess",0),Lt(this,"vertSize",Zt.vertSize),Lt(this,"vertPerQuad",Zt.vertPerQuad),Lt(this,"stride",Zt.stride),Lt(this,"buf"),this.buf=e}};Lt(Qt,"vertSize",13),Lt(Qt,"vertPerQuad",4),Lt(Qt,"stride",Qt.vertSize*4);let nr=Qt;var sr=Object.defineProperty,ar=(u,t,e)=>t in u?sr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Vt=(u,t,e)=>(ar(u,typeof t!="symbol"?t+"":t,e),e);class ri{constructor(){Vt(this,"pipe_uniforms",new P.UniformGroup({u_proj_trans:{value:new P.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class ni{constructor(t,e){Vt(this,"renderer"),Vt(this,"tileAnim",[0,0]),Vt(this,"ibLen",0),Vt(this,"indexBuffer",null),Vt(this,"shader"),Vt(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new P.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:P.BufferUsage.INDEX|P.BufferUsage.COPY_DST}),this.indexBuffer.destroy=P.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new nr(this.indexBuffer);return t.lastTimeAccess=Date.now(),t}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(t){const e=t*6;e<=this.ibLen||(this.ibLen=e,this.indexBuffer.data=or(t,Ut.use32bitIndex?new Uint32Array(e):new Uint16Array(e)))}destroyRenderable(t){t.vb.destroy(!0),t.vb=null}addRenderable(t,e){const i=this.renderer.renderPipes.batch;t.updateBuffer(this),t.checkValid(),t.getTileset().update(),t.is_valid&&(i.break(e),e.add(t._instruction))}updateRenderable(t,e){t.updateBuffer(this),t.getTileset().update()}validateRenderable(t){return t.checkValid()}execute({tilemap:t}){if(!t.isRenderable)return;t.state.blendMode=t.groupBlendMode;const{pipe_uniforms:e}=this.adaptor,i=e.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let c=this.tileAnim;const{u_anim_frame:o}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),o[0]=c[0],o[1]=c[1],e.update(),this.adaptor.execute(this,t)}}Vt(ni,"extension",{type:[P.ExtensionType.WebGLPipes,P.ExtensionType.WebGPUPipes],name:"tilemap"});function or(u,t){const e=u*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}var lr=Object.defineProperty,cr=(u,t,e)=>t in u?lr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Ot=(u,t,e)=>(cr(u,typeof t!="symbol"?t+"":t,e),e);class zt{constructor(t){Ot(this,"max_textures"),Ot(this,"arr",[]),Ot(this,"count",0),Ot(this,"dirty",!1),Ot(this,"dirty_gpu",!1),Ot(this,"bind_group",null),Ot(this,"bind_group_resources",{}),Ot(this,"tex_sizes",null),Ot(this,"null_color",new Float32Array([0,0,0,.5])),Ot(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new P.Buffer({usage:P.BufferUsage.UNIFORM|P.BufferUsage.COPY_DST})}get length(){return this.count}push(t){this.arr[this.count++]=t,this.dirty=!0}at(t){return this.arr[t]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:t,arr:e,count:i,max_textures:s,null_color:c}=this;for(let o=0;o<i;o++){const a=e[o];a&&(t[o*4]=a.pixelWidth,t[o*4+1]=a.pixelHeight,t[o*4+2]=1/a.pixelWidth,t[o*4+3]=1/a.pixelHeight)}t[s*4]=c[0],t[s*4+1]=c[1],t[s*4+2]=c[2],t[s*4+3]=c[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;const{bind_group_resources:t,max_textures:e,arr:i,count:s}=this;let c=0;t[c++]=new P.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:e},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let o=0;o<e;o++){const a=(o<s?i[o]:null)||P.Texture.EMPTY.source;t[c++]=a.source,t[c++]=a.style}return this.bind_group||(this.bind_group=new P.BindGroup(t)),this.bind_group}static generate_gpu_textures(t){const e=[];e.push("struct TextureArrayFields {"),e.push(` u_texture_size: array<vec4f, ${t}>,`),e.push(" u_null_color: vec4f"),e.push("}"),e.push("@group(1) @binding(0) var<uniform> taf: TextureArrayFields;");for(let i=0;i<t;i++)e.push(`@group(1) @binding(${i*2+1}) var u_texture_${i}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i*2+2}) var u_sampler_${i}: sampler;`);e.push("fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {"),e.push("switch texture_id {");for(let i=0;i<t;i++)e.push(` case ${i}: { return textureSampleGrad(u_texture_${i}, u_sampler_${i}, uv, dx, dy); }`);return e.push(" default: { return taf.u_null_color; }"),e.push("} }"),e.join(`
|
|
93
97
|
`)}static generate_gl_textures(t){const e=[];e.push(`uniform vec4 u_texture_size[${t+1}];`),e.push(`uniform sampler2D u_textures[${t}];`),e.push("uniform vec4 u_null_color;"),e.push("vec4 sampleMultiTexture(float texture_id, vec2 uv) {"),e.push(`if(texture_id < -0.5) return u_texture_size[${t}];`);for(let i=0;i<t;i++)e.push(`if(texture_id < ${i}.5) return texture(u_textures[${i}], uv * u_texture_size[${i}].zw);`);return e.push(`return u_texture_size[${t}];`),e.push("}"),e.join(`
|
|
94
|
-
`)}static gl_gen_resources(t){const e=[];for(let s=0;s<t;s++)e[s]=s;const i=[];for(let s=0;s<t;s++)i.push(2048),i.push(2048),i.push(.00048828125),i.push(.00048828125);return{u_textures:{value:e,type:"i32",size:t},u_texture_size:{value:i,type:"vec4<f32>",size:t}}}}var
|
|
98
|
+
`)}static gl_gen_resources(t){const e=[];for(let s=0;s<t;s++)e[s]=s;const i=[];for(let s=0;s<t;s++)i.push(2048),i.push(2048),i.push(.00048828125),i.push(.00048828125);return{u_textures:{value:e,type:"i32",size:t},u_texture_size:{value:i,type:"vec4<f32>",size:t}}}}var ur=Object.defineProperty,hr=(u,t,e)=>t in u?ur(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Me=(u,t,e)=>(hr(u,typeof t!="symbol"?t+"":t,e),e);const fr=`
|
|
95
99
|
in vec2 aVertexPosition;
|
|
96
100
|
in vec2 aTextureCoord;
|
|
97
101
|
in vec4 aFrame;
|
|
@@ -122,7 +126,7 @@ void main(void)
|
|
|
122
126
|
vTextureId = aTextureId;
|
|
123
127
|
vAlpha = aAlpha;
|
|
124
128
|
}
|
|
125
|
-
`,
|
|
129
|
+
`,dr=`
|
|
126
130
|
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
127
131
|
precision highp float;
|
|
128
132
|
#else
|
|
@@ -142,7 +146,7 @@ void main(void)
|
|
|
142
146
|
vec4 color = sampleMultiTexture(textureId, textureCoord);
|
|
143
147
|
finalColor = color * vAlpha;
|
|
144
148
|
}
|
|
145
|
-
`;class
|
|
149
|
+
`;class si extends ri{constructor(){super(...arguments),Me(this,"_shader",null),Me(this,"max_textures",Ut.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader,c=e.getTileset(),o=s.resources.texture_uniforms;o.uniforms.u_texture_size!==c.tex_sizes&&(o.uniforms.u_texture_size=c.tex_sizes,o.update());for(let a=0;a<c.length;a++)i.texture.bind(c.arr[a],a);i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({glProgram:P.GlProgram.from({vertex:fr,fragment:dr.replace("//include_textures",zt.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new P.UniformGroup(zt.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}Me(si,"extension",{type:[P.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var pr=Object.defineProperty,mr=(u,t,e)=>t in u?pr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,ne=(u,t,e)=>(mr(u,typeof t!="symbol"?t+"":t,e),e);const _r=`
|
|
146
150
|
struct GlobalUniforms {
|
|
147
151
|
uProjectionMatrix:mat3x3f,
|
|
148
152
|
uWorldTransformMatrix:mat3x3f,
|
|
@@ -188,7 +192,7 @@ fn mainVert(
|
|
|
188
192
|
|
|
189
193
|
return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
|
|
190
194
|
};
|
|
191
|
-
`,
|
|
195
|
+
`,yr=`
|
|
192
196
|
//include_textures
|
|
193
197
|
|
|
194
198
|
@fragment
|
|
@@ -205,21 +209,23 @@ fn mainFrag(
|
|
|
205
209
|
var color = sampleMultiTexture(vTextureId, uv, dx, dy);
|
|
206
210
|
return color * vAlpha;
|
|
207
211
|
};
|
|
208
|
-
`;class Je extends $e{constructor(){super(...arguments),Jt(this,"_shader",null),Jt(this,"max_textures",Ft.TEXTURES_PER_TILEMAP),Jt(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader;s.groups[0]=i.globalUniforms.bindGroup,s.groups[1]=e.getTileset().getBindGroup(),s.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({gpuProgram:P.GpuProgram.from({vertex:{source:ir,entryPoint:"mainVert"},fragment:{source:rr.replace("//include_textures",kt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new P.BindGroup({ut:this.pipe_uniforms})}}Jt(Je,"extension",{type:[P.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var sr=Object.defineProperty,nr=(h,t,e)=>t in h?sr(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,lt=(h,t,e)=>(nr(h,typeof t!="symbol"?t+"":t,e),e),Ze=(h=>(h[h.U=0]="U",h[h.V=1]="V",h[h.X=2]="X",h[h.Y=3]="Y",h[h.TILE_WIDTH=4]="TILE_WIDTH",h[h.TILE_HEIGHT=5]="TILE_HEIGHT",h[h.ROTATE=6]="ROTATE",h[h.ANIM_X=7]="ANIM_X",h[h.ANIM_Y=8]="ANIM_Y",h[h.TEXTURE_INDEX=9]="TEXTURE_INDEX",h[h.ANIM_COUNT_X=10]="ANIM_COUNT_X",h[h.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",h[h.ANIM_DIVISOR=12]="ANIM_DIVISOR",h[h.ALPHA=13]="ALPHA",h))(Ze||{});const bt=Object.keys(Ze).length/2;class ti extends P.ViewContainer{constructor(t){super({}),lt(this,"shadowColor",new Float32Array([0,0,0,.5])),lt(this,"state",P.State.for2d()),lt(this,"is_valid",!1),lt(this,"renderPipeId","tilemap"),lt(this,"canBundle",!0),lt(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),lt(this,"tileAnim",null),lt(this,"rects_count",0),lt(this,"compositeParent",!1),lt(this,"tileset",new kt(Ft.TEXTURES_PER_TILEMAP)),lt(this,"tilemapBounds",new P.Bounds),lt(this,"hasAnimatedTile",!1),lt(this,"pointsBuf",[]),lt(this,"batched"),lt(this,"vbId",0),lt(this,"vb",null),lt(this,"vbBuffer",null),lt(this,"vbArray",null),lt(this,"vbInts",null),this.setTileset(t)}checkValid(){const t=this.tileset.count>0&&this.pointsBuf.length>0,e=this.is_valid!==t;return this.is_valid=t,e!==t}updateBounds(){const t=this.tilemapBounds;this._bounds.minX=t.minX,this._bounds.maxX=t.maxX,this._bounds.minY=t.minY,this._bounds.maxY=t.maxY}getTileset(){return this.tileset}setTileset(t=[]){let e=this.tileset;if(t instanceof kt)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof P.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new kt(Ft.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let i=!0;for(let s=0;s<t.length;s++)if(t[s]?.source!==e.arr[s]){i=!1;break}if(i)return this}e=this.tileset=new kt(Ft.TEXTURES_PER_TILEMAP);for(let i=0;i<t.length;i++)e.push(t[i]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(t,e,i,s={}){this.didViewUpdate=!0;let c,l=-1,o=!1;if(typeof t=="number")l=t,o=!0,c=this.tileset.arr[l];else{let d;typeof t=="string"?d=P.Texture.from(t):d=t;const b=this.tileset;for(let R=0;R<b.count;R++)if(b.arr[R]===d.source){l=R;break}"frame"in d&&(s.u=s.u??d.frame.x,s.v=s.v??d.frame.y,s.tileWidth=s.tileWidth??d.orig.width,s.tileHeight=s.tileHeight??d.orig.height),c=d.source}if(!o&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:y=0,v:C=0,tileWidth:v=c.width,tileHeight:B=c.height,animX:A=0,animY:I=0,rotate:M=0,animCountX:N=1024,animCountY:O=1024,animDivisor:_=1,alpha:E=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||A>0||I>0,m.push(y),m.push(C),m.push(e),m.push(i),m.push(v),m.push(B),m.push(M),m.push(A|0),m.push(I|0),m.push(l),m.push(N),m.push(O),m.push(_),m.push(E),this.tilemapBounds.addFrame(e,i,e+v,i+B),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(bt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(bt-7)]=t,i[i.length-(bt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(bt-8)]=t,i[i.length-(bt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(bt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(bt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/bt;let s=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&s)return;this.rects_count=i,s||(s=t.createVb(),this.vb=s,this.vbId=s.id,this.vbBuffer=null);const c=i*s.vertPerQuad;t.checkIndexBuffer(i);const l=s.getBuffer("aVertexPosition"),o=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<o){let A=s.stride;for(;A<o;)A*=2;this.vbBuffer=new ArrayBuffer(A),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const y=this.vbArray,C=this.vbInts;let v=0,B=0;for(let A=0;A<e.length;A+=bt){this.compositeParent&&(B=e[A+9]);const M=e[A+2],N=e[A+3],O=e[A+4],_=e[A+5],E=e[A+0],m=e[A+1];let d=e[A+6];const b=e[A+7],R=e[A+8],U=e[A+10]||1024,k=e[A+11]||1024,g=b+U*2048,V=R+k*2048,j=e[A+12],z=e[A+13];let Q,ut,tt,ht,L,nt,dt,yt;if(d===0)Q=E,ut=m,tt=E+O,ht=m,L=E+O,nt=m+_,dt=E,yt=m+_;else{let K=O/2,W=_/2;d%4!==0&&(K=_/2,W=O/2);const ft=E+K,ct=m+W;d=P.groupD8.add(d,P.groupD8.NW),Q=ft+K*P.groupD8.uX(d),ut=ct+W*P.groupD8.uY(d),d=P.groupD8.add(d,2),tt=ft+K*P.groupD8.uX(d),ht=ct+W*P.groupD8.uY(d),d=P.groupD8.add(d,2),L=ft+K*P.groupD8.uX(d),nt=ct+W*P.groupD8.uY(d),d=P.groupD8.add(d,2),dt=ft+K*P.groupD8.uX(d),yt=ct+W*P.groupD8.uY(d)}y[v++]=M,y[v++]=N,y[v++]=Q,y[v++]=ut,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z,y[v++]=M+O,y[v++]=N,y[v++]=tt,y[v++]=ht,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z,y[v++]=M+O,y[v++]=N+_,y[v++]=L,y[v++]=nt,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z,y[v++]=M,y[v++]=N+_,y[v++]=dt,y[v++]=yt,y[v++]=E+.5,y[v++]=m+.5,y[v++]=E+O-.5,y[v++]=m+_-.5,y[v++]=g,y[v++]=V,C[v++]=B,y[v++]=j,y[v++]=z}l.data=y}isModified(t){return!!(this.rects_count*bt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/bt}addBounds(t){const e=this.tilemapBounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}get bounds(){return this.tilemapBounds}destroy(t){super.destroy(t),this.destroyVb()}addFrame(t,e,i,s,c){return this.tile(t,e,i,{animX:s,animY:c}),!0}addRect(t,e,i,s,c,l,o,y=0,C=0,v=0,B=1024,A=1024,I=1,M=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:l,tileHeight:o,animX:y,animY:C,rotate:v,animCountX:B,animCountY:A,animDivisor:I,alpha:M})}}var ar=Object.defineProperty,or=(h,t,e)=>t in h?ar(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,qt=(h,t,e)=>(or(h,typeof t!="symbol"?t+"":t,e),e);class lr extends P.Container{constructor(t){super(),qt(this,"texturesPerTilemap"),qt(this,"tileAnim",null),qt(this,"lastModifiedTilemap",null),qt(this,"modificationMarker",0),qt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=Ft.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,s=Math.ceil(t.length/e);for(let c=0;c<Math.min(i,s);c++)this.children[c].setTileset(t.slice(c*e,(c+1)*e));for(let c=i;c<s;c++){const l=new ti(t.slice(c*e,(c+1)*e));l.compositeParent=!0,this.addChild(l)}return this}clear(){for(let t=0;t<this.children.length;t++)this.children[t].clear();return this.modificationMarker=0,this}tileRotate(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(t),this}tileAnimX(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(t,e),this}tileAnimY(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(t,e),this}tileAnimDivisor(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(t),this}tile(t,e,i,s={}){let c=null;const l=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const o=t/this.texturesPerTilemap>>0;let y=0;if(c=l[o],c)y=t%this.texturesPerTilemap;else{if(c=l[0],!c)return this;y=0}c.tile(y,e,i,s)}else{typeof t=="string"&&(t=P.Texture.from(t));for(let o=0;o<l.length;o++){const y=l[o],C=y.getTileset().arr;for(let v=0;v<C.length;v++)if(C[v]===t.source){c=y;break}if(c)break}if(!c){for(let o=l.length-1;o>=0;o--){const y=l[o];if(y.getTileset().count<this.texturesPerTilemap){c=y,y.getTileset().push(t.source);break}}c||(c=new ti(t.source),c.compositeParent=!0,this.addChild(c))}c.tile(t,e,i,s)}return this.lastModifiedTilemap=c,this}isModified(t){const e=this.children;if(this.modificationMarker!==e.length)return!0;for(let i=0;i<e.length;i++)if(e[i].isModified(t))return!0;return!1}clearModify(){const t=this.children;this.modificationMarker=t.length;for(let e=0;e<t.length;e++)t[e].clearModify()}addFrame(t,e,i,s,c,l,o,y,C){return this.tile(t,e,i,{animX:s,animY:c,animCountX:l,animCountY:o,animDivisor:y,alpha:C})}addRect(t,e,i,s,c,l,o,y,C,v,B,A){const I=t/this.texturesPerTilemap>>0,M=t%this.texturesPerTilemap;return this.children[I]&&this.children[I].getTileset().count>0?(this.lastModifiedTilemap=this.children[I],this.lastModifiedTilemap.addRect(M,e,i,s,c,l,o,y,C,v,B,A)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}P.extensions.add(Xe),P.extensions.add(Qe),P.extensions.add(Je);class Zt extends P.AnimatedSprite{constructor(t,e){super(Zt.getTextures(t,e)),this.tile=t,this.tileSet=e,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=Zt.getTextures(t,e),this.texture=this.textures[0],this.flip()}static getTextures(t,e){const i=[];return t.animations&&t.animations.length?t.animations.forEach(s=>{i.push(e.textures[s.tileid])}):i.push(e.textures[t.gid-e.firstgid]),i}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(t){const e=this.animations.length;if(e>1){const i=(this.animations[1].tileid-this.animations[0].tileid)*this.width;t.tileAnimX(i,e)}}flip(){let t,e=0;const i=s=>{e++,t?t=P.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(P.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(P.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(P.groupD8.MAIN_DIAGONAL):i(P.groupD8.REVERSE_DIAGONAL))}}Ft.use32bitIndex=!0;class be extends D.DisplayObject(lr){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}createTile(t,e,i={}){const{real:s,filter:c}=i,{tilewidth:l,tileheight:o,width:y}=this._layer;s&&(t=Math.floor(t/l),e=Math.floor(e/o));const C=t+e*y,v=this._layer.getTileByIndex(C);if(!v||v&&v.gid==0)return;const B=be.findTileSet(v.gid,this.tileSets);if(!B)return;const A=new Zt(v,B);if(A.x=t*l,A.y=e*o+(o-A.texture.height),A._x=t,A._y=e,B.tileoffset&&(A.x+=B.tileoffset.x??0,A.y+=B.tileoffset.y??0),!(c&&!c(A)))return A}_addFrame(t,e,i){const s=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(s),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new we({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",be);function cr(h){return D.createComponent("CompositeTileLayer",h)}class ur extends Yi{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await P.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let s=this.margin;s<this.image.width;s+=this.tilewidth+this.spacing)this.textures.push(new P.Texture({source:e.source,frame:new P.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function hr(h,t,e){const i=[];for(const s of h){if(s.type!==Vt.Tile){i.push(s);continue}const c=new Map;let l;if(Array.isArray(s.data))l=s.data.map(y=>typeof y=="number"?y:parseInt(String(y),10));else{i.push(s);continue}for(let y=0;y<l.length;y++){const C=l[y];if(C===0)continue;let v;for(let M=t.length-1;M>=0;M--)if(t[M].firstgid&&t[M].firstgid<=C){v=t[M];break}if(!v){c.has(0)||c.set(0,new Array(l.length).fill(0)),c.get(0)[y]=C;continue}const B=C-v.firstgid,A=v.tileset.tiles?.[B]?.properties,I=A?.z??0;A?.z,c.has(I)||c.set(I,new Array(l.length).fill(0)),c.get(I)[y]=C}const o=Array.from(c.keys()).sort((y,C)=>y-C);for(const y of o){const C=c.get(y);if(C.some(v=>v!==0)){const v={...s,name:`${s.name}_z${y}`,data:C,properties:{...s.properties,z:y}};i.push(v)}}}return i.sort((s,c)=>{const l=s.properties?.z??.5,o=c.properties?.z??.5;return l-o}),i}function fr(h){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(h,{createLayersPerTilesZ:!1,basePath:""}),s=D.signal([]),c=h.objectLayer;let l=[],o={};const y=async(v,B="")=>typeof v!="string"?v:await new Mt(v,{basePath:B}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const v=t();if(v){o=await y(v,e()),l=[];for(let A of o.tilesets)A.tile&&(A.tiles=A.tile),A.tiles||(A.tiles=[]),l.push(await new ur(A).load(A.image.source));let B=o.layers;i()&&(B=hr(o.layers,l)),s.set(B)}});const C=(v,B={})=>D.h(D.Container,B,D.loop(v,A=>{switch(A.type){case Vt.Tile:return D.h(cr,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...A,tilesets:l});case Vt.Image:const{width:I,height:M,source:N}=A.image;return D.h(D.TilingSprite,{image:N,...A,width:A.repeatx?A.width*A.tilewidth:I,height:A.repeaty?A.height*A.tileheight:M});case Vt.Group:return C(D.signal(A.layers),A);case Vt.ObjectGroup:const O=c?.(A);return D.h(D.Container,A,O);default:return D.h(D.Container)}}));return D.h(D.Container,h,C(s))}function dr(){const h=`
|
|
212
|
+
`;class ai extends ri{constructor(){super(...arguments),ne(this,"_shader",null),ne(this,"max_textures",Ut.TEXTURES_PER_TILEMAP),ne(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader;s.groups[0]=i.globalUniforms.bindGroup,s.groups[1]=e.getTileset().getBindGroup(),s.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:s,state:e.state,size:e.rects_count*6})}init(){this._shader=new P.Shader({gpuProgram:P.GpuProgram.from({vertex:{source:_r,entryPoint:"mainVert"},fragment:{source:yr.replace("//include_textures",zt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new P.BindGroup({ut:this.pipe_uniforms})}}ne(ai,"extension",{type:[P.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var gr=Object.defineProperty,xr=(u,t,e)=>t in u?gr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,yt=(u,t,e)=>(xr(u,typeof t!="symbol"?t+"":t,e),e),oi=(u=>(u[u.U=0]="U",u[u.V=1]="V",u[u.X=2]="X",u[u.Y=3]="Y",u[u.TILE_WIDTH=4]="TILE_WIDTH",u[u.TILE_HEIGHT=5]="TILE_HEIGHT",u[u.ROTATE=6]="ROTATE",u[u.ANIM_X=7]="ANIM_X",u[u.ANIM_Y=8]="ANIM_Y",u[u.TEXTURE_INDEX=9]="TEXTURE_INDEX",u[u.ANIM_COUNT_X=10]="ANIM_COUNT_X",u[u.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",u[u.ANIM_DIVISOR=12]="ANIM_DIVISOR",u[u.ALPHA=13]="ALPHA",u))(oi||{});const Bt=Object.keys(oi).length/2;class li extends P.ViewContainer{constructor(t){super({}),yt(this,"shadowColor",new Float32Array([0,0,0,.5])),yt(this,"state",P.State.for2d()),yt(this,"is_valid",!1),yt(this,"renderPipeId","tilemap"),yt(this,"canBundle",!0),yt(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),yt(this,"tileAnim",null),yt(this,"rects_count",0),yt(this,"compositeParent",!1),yt(this,"tileset",new zt(Ut.TEXTURES_PER_TILEMAP)),yt(this,"tilemapBounds",new P.Bounds),yt(this,"hasAnimatedTile",!1),yt(this,"pointsBuf",[]),yt(this,"batched"),yt(this,"vbId",0),yt(this,"vb",null),yt(this,"vbBuffer",null),yt(this,"vbArray",null),yt(this,"vbInts",null),this.setTileset(t)}checkValid(){const t=this.tileset.count>0&&this.pointsBuf.length>0,e=this.is_valid!==t;return this.is_valid=t,e!==t}updateBounds(){const t=this.tilemapBounds;this._bounds.minX=t.minX,this._bounds.maxX=t.maxX,this._bounds.minY=t.minY,this._bounds.maxY=t.maxY}getTileset(){return this.tileset}setTileset(t=[]){let e=this.tileset;if(t instanceof zt)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof P.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new zt(Ut.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let i=!0;for(let s=0;s<t.length;s++)if(t[s]?.source!==e.arr[s]){i=!1;break}if(i)return this}e=this.tileset=new zt(Ut.TEXTURES_PER_TILEMAP);for(let i=0;i<t.length;i++)e.push(t[i]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(t,e,i,s={}){this.didViewUpdate=!0;let c,o=-1,a=!1;if(typeof t=="number")o=t,a=!0,c=this.tileset.arr[o];else{let f;typeof t=="string"?f=P.Texture.from(t):f=t;const b=this.tileset;for(let O=0;O<b.count;O++)if(b.arr[O]===f.source){o=O;break}"frame"in f&&(s.u=s.u??f.frame.x,s.v=s.v??f.frame.y,s.tileWidth=s.tileWidth??f.orig.width,s.tileHeight=s.tileHeight??f.orig.height),c=f.source}if(!a&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:y=0,v:C=0,tileWidth:S=c.width,tileHeight:B=c.height,animX:A=0,animY:D=0,rotate:F=0,animCountX:R=1024,animCountY:N=1024,animDivisor:m=1,alpha:x=1}=s,_=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||A>0||D>0,_.push(y),_.push(C),_.push(e),_.push(i),_.push(S),_.push(B),_.push(F),_.push(A|0),_.push(D|0),_.push(o),_.push(R),_.push(N),_.push(m),_.push(x),this.tilemapBounds.addFrame(e,i,e+S,i+B),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(Bt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(Bt-7)]=t,i[i.length-(Bt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(Bt-8)]=t,i[i.length-(Bt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(Bt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(Bt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/Bt;let s=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&s)return;this.rects_count=i,s||(s=t.createVb(),this.vb=s,this.vbId=s.id,this.vbBuffer=null);const c=i*s.vertPerQuad;t.checkIndexBuffer(i);const o=s.getBuffer("aVertexPosition"),a=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<a){let A=s.stride;for(;A<a;)A*=2;this.vbBuffer=new ArrayBuffer(A),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const y=this.vbArray,C=this.vbInts;let S=0,B=0;for(let A=0;A<e.length;A+=Bt){this.compositeParent&&(B=e[A+9]);const F=e[A+2],R=e[A+3],N=e[A+4],m=e[A+5],x=e[A+0],_=e[A+1];let f=e[A+6];const b=e[A+7],O=e[A+8],k=e[A+10]||1024,L=e[A+11]||1024,g=b+k*2048,q=O+L*2048,Y=e[A+12],G=e[A+13];let st,ft,at,ot,K,gt,xt,mt;if(f===0)st=x,ft=_,at=x+N,ot=_,K=x+N,gt=_+m,xt=x,mt=_+m;else{let W=N/2,tt=m/2;f%4!==0&&(W=m/2,tt=N/2);const Tt=x+W,vt=_+tt;f=P.groupD8.add(f,P.groupD8.NW),st=Tt+W*P.groupD8.uX(f),ft=vt+tt*P.groupD8.uY(f),f=P.groupD8.add(f,2),at=Tt+W*P.groupD8.uX(f),ot=vt+tt*P.groupD8.uY(f),f=P.groupD8.add(f,2),K=Tt+W*P.groupD8.uX(f),gt=vt+tt*P.groupD8.uY(f),f=P.groupD8.add(f,2),xt=Tt+W*P.groupD8.uX(f),mt=vt+tt*P.groupD8.uY(f)}y[S++]=F,y[S++]=R,y[S++]=st,y[S++]=ft,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G,y[S++]=F+N,y[S++]=R,y[S++]=at,y[S++]=ot,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G,y[S++]=F+N,y[S++]=R+m,y[S++]=K,y[S++]=gt,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G,y[S++]=F,y[S++]=R+m,y[S++]=xt,y[S++]=mt,y[S++]=x+.5,y[S++]=_+.5,y[S++]=x+N-.5,y[S++]=_+m-.5,y[S++]=g,y[S++]=q,C[S++]=B,y[S++]=Y,y[S++]=G}o.data=y}isModified(t){return!!(this.rects_count*Bt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/Bt}addBounds(t){const e=this.tilemapBounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}get bounds(){return this.tilemapBounds}destroy(t){super.destroy(t),this.destroyVb()}addFrame(t,e,i,s,c){return this.tile(t,e,i,{animX:s,animY:c}),!0}addRect(t,e,i,s,c,o,a,y=0,C=0,S=0,B=1024,A=1024,D=1,F=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:o,tileHeight:a,animX:y,animY:C,rotate:S,animCountX:B,animCountY:A,animDivisor:D,alpha:F})}}var wr=Object.defineProperty,Er=(u,t,e)=>t in u?wr(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Jt=(u,t,e)=>(Er(u,typeof t!="symbol"?t+"":t,e),e);class vr extends P.Container{constructor(t){super(),Jt(this,"texturesPerTilemap"),Jt(this,"tileAnim",null),Jt(this,"lastModifiedTilemap",null),Jt(this,"modificationMarker",0),Jt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=Ut.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,s=Math.ceil(t.length/e);for(let c=0;c<Math.min(i,s);c++)this.children[c].setTileset(t.slice(c*e,(c+1)*e));for(let c=i;c<s;c++){const o=new li(t.slice(c*e,(c+1)*e));o.compositeParent=!0,this.addChild(o)}return this}clear(){for(let t=0;t<this.children.length;t++)this.children[t].clear();return this.modificationMarker=0,this}tileRotate(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(t),this}tileAnimX(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(t,e),this}tileAnimY(t,e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(t,e),this}tileAnimDivisor(t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(t),this}tile(t,e,i,s={}){let c=null;const o=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const a=t/this.texturesPerTilemap>>0;let y=0;if(c=o[a],c)y=t%this.texturesPerTilemap;else{if(c=o[0],!c)return this;y=0}c.tile(y,e,i,s)}else{typeof t=="string"&&(t=P.Texture.from(t));for(let a=0;a<o.length;a++){const y=o[a],C=y.getTileset().arr;for(let S=0;S<C.length;S++)if(C[S]===t.source){c=y;break}if(c)break}if(!c){for(let a=o.length-1;a>=0;a--){const y=o[a];if(y.getTileset().count<this.texturesPerTilemap){c=y,y.getTileset().push(t.source);break}}c||(c=new li(t.source),c.compositeParent=!0,this.addChild(c))}c.tile(t,e,i,s)}return this.lastModifiedTilemap=c,this}isModified(t){const e=this.children;if(this.modificationMarker!==e.length)return!0;for(let i=0;i<e.length;i++)if(e[i].isModified(t))return!0;return!1}clearModify(){const t=this.children;this.modificationMarker=t.length;for(let e=0;e<t.length;e++)t[e].clearModify()}addFrame(t,e,i,s,c,o,a,y,C){return this.tile(t,e,i,{animX:s,animY:c,animCountX:o,animCountY:a,animDivisor:y,alpha:C})}addRect(t,e,i,s,c,o,a,y,C,S,B,A){const D=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[D]&&this.children[D].getTileset().count>0?(this.lastModifiedTilemap=this.children[D],this.lastModifiedTilemap.addRect(F,e,i,s,c,o,a,y,C,S,B,A)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}P.extensions.add(ni),P.extensions.add(si),P.extensions.add(ai);class se extends P.AnimatedSprite{constructor(t,e){super(se.getTextures(t,e)),this.tile=t,this.tileSet=e,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=se.getTextures(t,e),this.texture=this.textures[0],this.flip()}static getTextures(t,e){const i=[];return t.animations&&t.animations.length?t.animations.forEach(s=>{i.push(e.textures[s.tileid])}):i.push(e.textures[t.gid-e.firstgid]),i}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(t){const e=this.animations.length;if(e>1){const i=(this.animations[1].tileid-this.animations[0].tileid)*this.width;t.tileAnimX(i,e)}}flip(){let t,e=0;const i=s=>{e++,t?t=P.groupD8.add(t,s):t=s};this.tile.horizontalFlip&&i(P.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(P.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(P.groupD8.MAIN_DIAGONAL):i(P.groupD8.REVERSE_DIAGONAL))}}Ut.use32bitIndex=!0;class Fe extends I.DisplayObject(vr){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let s=e.length-1;s>=0&&(i=e[s],!(i.firstgid&&i.firstgid<=t));s--);return i}createTile(t,e,i={}){const{real:s,filter:c}=i,{tilewidth:o,tileheight:a,width:y}=this._layer;s&&(t=Math.floor(t/o),e=Math.floor(e/a));const C=t+e*y,S=this._layer.getTileByIndex(C);if(!S||S&&S.gid==0)return;const B=Fe.findTileSet(S.gid,this.tileSets);if(!B)return;const A=new se(S,B);if(A.x=t*o,A.y=e*a+(a-A.texture.height),A._x=t,A._y=e,B.tileoffset&&(A.x+=B.tileoffset.x??0,A.y+=B.tileoffset.y??0),!(c&&!c(A)))return A}_addFrame(t,e,i){const s=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(s),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new Ce({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:s})=>{s.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(t)}onUpdate(t){if(super.onUpdate(t),!!this.isMounted){t.tileheight&&(this._layer.tileheight=t.tileheight),t.tilewidth&&(this._layer.tilewidth=t.tilewidth),t.width&&(this._layer.width=t.width),t.height&&(this._layer.height=t.height),t.parallaxX&&(this._layer.parallaxX=t.parallaxx),t.parallaxY&&(this._layer.parallaxY=t.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let i=0;i<this._layer.width;i++){const s=this.createTile(i,e);s&&this._addFrame(s,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}I.registerComponent("CompositeTileLayer",Fe);function Sr(u){return I.createComponent("CompositeTileLayer",u)}class Tr extends er{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await P.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let s=this.margin;s<this.image.width;s+=this.tilewidth+this.spacing)this.textures.push(new P.Texture({source:e.source,frame:new P.Rectangle(+s,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function br(u,t,e){const i=[];for(const s of u){if(s.type!==qt.Tile){i.push(s);continue}const c=new Map;let o;if(Array.isArray(s.data))o=s.data.map(y=>typeof y=="number"?y:parseInt(String(y),10));else{i.push(s);continue}for(let y=0;y<o.length;y++){const C=o[y];if(C===0)continue;let S;for(let F=t.length-1;F>=0;F--)if(t[F].firstgid&&t[F].firstgid<=C){S=t[F];break}if(!S){c.has(0)||c.set(0,new Array(o.length).fill(0)),c.get(0)[y]=C;continue}const B=C-S.firstgid,A=S.tileset.tiles?.[B]?.properties,D=A?.z??0;A?.z,c.has(D)||c.set(D,new Array(o.length).fill(0)),c.get(D)[y]=C}const a=Array.from(c.keys()).sort((y,C)=>y-C);for(const y of a){const C=c.get(y);if(C.some(S=>S!==0)){const S={...s,name:`${s.name}_z${y}`,data:C,properties:{...s.properties,z:y}};i.push(S)}}}return i.sort((s,c)=>{const o=s.properties?.z??.5,a=c.properties?.z??.5;return o-a}),i}function Ar(u){const{map:t,basePath:e,createLayersPerTilesZ:i}=I.useProps(u,{createLayersPerTilesZ:!1,basePath:""}),s=I.signal([]),c=u.objectLayer;let o=[],a={};const y=async(S,B="")=>typeof S!="string"?S:await new kt(S,{basePath:B}).parseFilePromise({getOnlyBasename:!1});I.effect(async()=>{const S=t();if(S){a=await y(S,e()),o=[];for(let A of a.tilesets)A.tile&&(A.tiles=A.tile),A.tiles||(A.tiles=[]),o.push(await new Tr(A).load(A.image.source));let B=a.layers;i()&&(B=br(a.layers,o)),s.set(B)}});const C=(S,B={})=>I.h(I.Container,B,I.loop(S,A=>{switch(A.type){case qt.Tile:return I.h(Sr,{tilewidth:a.tilewidth,tileheight:a.tileheight,width:a.width,height:a.height,...A,tilesets:o});case qt.Image:const{width:D,height:F,source:R}=A.image;return I.h(I.TilingSprite,{image:R,...A,width:A.repeatx?A.width*A.tilewidth:D,height:A.repeaty?A.height*A.tileheight:F});case qt.Group:return C(I.signal(A.layers),A);case qt.ObjectGroup:const N=c?.(A);return I.h(I.Container,A,N);default:return I.h(I.Container)}}));return I.h(I.Container,u,C(s))}function Cr(){const u=`
|
|
209
213
|
precision mediump float;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
uniform mat3
|
|
214
|
-
uniform mat3
|
|
215
|
-
|
|
214
|
+
in vec2 aPosition;
|
|
215
|
+
in vec2 aUV;
|
|
216
|
+
out vec2 vUV;
|
|
217
|
+
uniform mat3 uProjectionMatrix;
|
|
218
|
+
uniform mat3 uWorldTransformMatrix;
|
|
219
|
+
uniform mat3 uTransformMatrix;
|
|
220
|
+
void main(void) {
|
|
216
221
|
vUV = aUV;
|
|
217
|
-
|
|
218
|
-
gl_Position = vec4(
|
|
222
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
|
|
223
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
219
224
|
}
|
|
220
225
|
`,t=`
|
|
221
226
|
precision mediump float;
|
|
222
|
-
|
|
227
|
+
in vec2 vUV;
|
|
228
|
+
out vec4 finalColor;
|
|
223
229
|
|
|
224
230
|
uniform float uTime;
|
|
225
231
|
uniform vec2 uResolution;
|
|
@@ -246,7 +252,7 @@ fn mainFrag(
|
|
|
246
252
|
vec2 dir = normalize(vec2(slant, 1.0));
|
|
247
253
|
vec2 perp = vec2(-dir.y, dir.x);
|
|
248
254
|
|
|
249
|
-
float along = dot(uv, dir) * scale
|
|
255
|
+
float along = dot(uv, dir) * scale - t * speed;
|
|
250
256
|
float across = dot(uv, perp) * scale;
|
|
251
257
|
|
|
252
258
|
vec2 p = vec2(across, along);
|
|
@@ -260,7 +266,7 @@ fn mainFrag(
|
|
|
260
266
|
float dropWidth = width * (0.7 + rnd2 * 0.6);
|
|
261
267
|
float dropLength = length * (0.5 + rnd * 0.6);
|
|
262
268
|
|
|
263
|
-
float line = smoothstep(
|
|
269
|
+
float line = 1.0 - smoothstep(0.0, dropWidth, abs(f.x - x));
|
|
264
270
|
float segment = smoothstep(0.0, 0.03, f.y)
|
|
265
271
|
* (1.0 - smoothstep(dropLength, dropLength + 0.03, f.y));
|
|
266
272
|
|
|
@@ -270,46 +276,50 @@ fn mainFrag(
|
|
|
270
276
|
}
|
|
271
277
|
|
|
272
278
|
void main() {
|
|
273
|
-
vec2
|
|
274
|
-
|
|
279
|
+
vec2 safeResolution = max(uResolution, vec2(1.0));
|
|
280
|
+
vec2 uv = vUV;
|
|
281
|
+
float aspect = safeResolution.x / safeResolution.y;
|
|
275
282
|
uv.x *= aspect;
|
|
276
283
|
|
|
277
|
-
float pixelCount =
|
|
278
|
-
float resolutionFactor = clamp(pixelCount / 700000.0, 0.
|
|
284
|
+
float pixelCount = safeResolution.x * safeResolution.y;
|
|
285
|
+
float resolutionFactor = clamp(pixelCount / 700000.0, 0.7, 1.1);
|
|
279
286
|
|
|
280
|
-
float densityFactor = clamp(uRainDensity /
|
|
281
|
-
float maxDropFactor = clamp(uMaxDrops /
|
|
282
|
-
float density = clamp(densityFactor * maxDropFactor * resolutionFactor, 0.
|
|
287
|
+
float densityFactor = clamp(uRainDensity / 180.0, 0.35, 1.4);
|
|
288
|
+
float maxDropFactor = clamp(uMaxDrops / 90.0, 0.45, 1.1);
|
|
289
|
+
float density = clamp(densityFactor * maxDropFactor * resolutionFactor, 0.15, 1.0);
|
|
283
290
|
|
|
284
291
|
float slant = uWindDirection * uWindStrength * 0.6;
|
|
285
292
|
float speed = 1.3 * uRainSpeed + 0.4;
|
|
286
293
|
|
|
287
294
|
float rain = 0.0;
|
|
288
|
-
rain += rainLayer(uv, uTime, 24.0, speed * 1.2, slant, density, 0.
|
|
289
|
-
rain += rainLayer(uv, uTime, 36.0, speed * 1.5, slant * 1.2, density * 0.
|
|
290
|
-
rain += rainLayer(uv, uTime, 52.0, speed * 1.8, slant * 1.4, density * 0.
|
|
295
|
+
rain += rainLayer(uv, uTime, 24.0, speed * 1.2, slant, density, 0.026, 0.9);
|
|
296
|
+
rain += rainLayer(uv, uTime, 36.0, speed * 1.5, slant * 1.2, density * 0.85, 0.02, 0.72);
|
|
297
|
+
rain += rainLayer(uv, uTime, 52.0, speed * 1.8, slant * 1.4, density * 0.7, 0.016, 0.58);
|
|
291
298
|
|
|
292
299
|
float heightFade = mix(0.65, 1.0, uv.y);
|
|
293
300
|
rain *= heightFade;
|
|
294
301
|
|
|
295
302
|
vec3 rainColor = vec3(0.75, 0.85, 1.0);
|
|
296
|
-
|
|
303
|
+
float alpha = clamp(rain * 1.15, 0.0, 0.95);
|
|
304
|
+
finalColor = vec4(rainColor * alpha, alpha);
|
|
297
305
|
}
|
|
298
|
-
`;return new P.GlProgram({vertex:
|
|
306
|
+
`;return new P.GlProgram({vertex:u,fragment:t})}function Mr(){const u=`
|
|
299
307
|
precision mediump float;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
uniform mat3
|
|
304
|
-
uniform mat3
|
|
305
|
-
|
|
308
|
+
in vec2 aPosition;
|
|
309
|
+
in vec2 aUV;
|
|
310
|
+
out vec2 vUV;
|
|
311
|
+
uniform mat3 uProjectionMatrix;
|
|
312
|
+
uniform mat3 uWorldTransformMatrix;
|
|
313
|
+
uniform mat3 uTransformMatrix;
|
|
314
|
+
void main(void) {
|
|
306
315
|
vUV = aUV;
|
|
307
|
-
|
|
308
|
-
gl_Position = vec4(
|
|
316
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
|
|
317
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
309
318
|
}
|
|
310
319
|
`,t=`
|
|
311
320
|
precision mediump float;
|
|
312
|
-
|
|
321
|
+
in vec2 vUV;
|
|
322
|
+
out vec4 finalColor;
|
|
313
323
|
|
|
314
324
|
uniform float uTime;
|
|
315
325
|
uniform vec2 uResolution;
|
|
@@ -341,8 +351,8 @@ fn mainFrag(
|
|
|
341
351
|
float sizeMax
|
|
342
352
|
) {
|
|
343
353
|
vec2 p = uv;
|
|
344
|
-
p.x
|
|
345
|
-
p.y
|
|
354
|
+
p.x -= wind * t;
|
|
355
|
+
p.y -= t * speed;
|
|
346
356
|
|
|
347
357
|
p *= scale;
|
|
348
358
|
vec2 cell = floor(p);
|
|
@@ -367,47 +377,50 @@ fn mainFrag(
|
|
|
367
377
|
}
|
|
368
378
|
|
|
369
379
|
void main() {
|
|
370
|
-
vec2
|
|
371
|
-
|
|
380
|
+
vec2 safeResolution = max(uResolution, vec2(1.0));
|
|
381
|
+
vec2 uv = vUV;
|
|
382
|
+
float aspect = safeResolution.x / safeResolution.y;
|
|
372
383
|
uv.x *= aspect;
|
|
373
384
|
|
|
374
|
-
float pixelCount =
|
|
375
|
-
float resolutionFactor = clamp(pixelCount / 900000.0, 0.
|
|
385
|
+
float pixelCount = safeResolution.x * safeResolution.y;
|
|
386
|
+
float resolutionFactor = clamp(pixelCount / 900000.0, 0.6, 1.1);
|
|
376
387
|
|
|
377
|
-
float densityFactor = clamp(uSnowDensity /
|
|
378
|
-
float maxFlakeFactor = clamp(uMaxFlakes /
|
|
379
|
-
float density = clamp(densityFactor * maxFlakeFactor * resolutionFactor, 0.
|
|
388
|
+
float densityFactor = clamp(uSnowDensity / 180.0, 0.25, 1.3);
|
|
389
|
+
float maxFlakeFactor = clamp(uMaxFlakes / 90.0, 0.4, 1.1);
|
|
390
|
+
float density = clamp(densityFactor * maxFlakeFactor * resolutionFactor, 0.08, 1.0);
|
|
380
391
|
|
|
381
392
|
float wind = uWindDirection * uWindStrength * 0.45;
|
|
382
393
|
float speed = uSnowSpeed * 0.9 + 0.15;
|
|
383
394
|
|
|
384
395
|
float snow = 0.0;
|
|
385
|
-
snow += snowLayer(uv, uTime, 18.0, speed * 0.5, wind * 0.6, density, 0.
|
|
386
|
-
snow += snowLayer(uv, uTime, 28.0, speed * 0.75, wind * 0.9, density * 0.
|
|
387
|
-
snow += snowLayer(uv, uTime, 40.0, speed, wind, density * 0.
|
|
396
|
+
snow += snowLayer(uv, uTime, 18.0, speed * 0.5, wind * 0.6, density, 0.1, 0.22) * 0.65;
|
|
397
|
+
snow += snowLayer(uv, uTime, 28.0, speed * 0.75, wind * 0.9, density * 0.9, 0.075, 0.16) * 0.8;
|
|
398
|
+
snow += snowLayer(uv, uTime, 40.0, speed, wind, density * 0.75, 0.05, 0.12);
|
|
388
399
|
|
|
389
400
|
float heightFade = mix(0.7, 1.0, uv.y);
|
|
390
401
|
snow *= heightFade;
|
|
391
402
|
|
|
392
403
|
vec3 snowColor = vec3(0.92, 0.95, 1.0);
|
|
393
|
-
float alpha = clamp(snow, 0.0, 0.
|
|
394
|
-
|
|
404
|
+
float alpha = clamp(snow * 1.1, 0.0, 0.92);
|
|
405
|
+
finalColor = vec4(snowColor * alpha, alpha);
|
|
395
406
|
}
|
|
396
|
-
`;return new P.GlProgram({vertex:
|
|
407
|
+
`;return new P.GlProgram({vertex:u,fragment:t})}function Fr(){const u=`
|
|
397
408
|
precision mediump float;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
uniform mat3
|
|
402
|
-
uniform mat3
|
|
403
|
-
|
|
409
|
+
in vec2 aPosition;
|
|
410
|
+
in vec2 aUV;
|
|
411
|
+
out vec2 vUV;
|
|
412
|
+
uniform mat3 uProjectionMatrix;
|
|
413
|
+
uniform mat3 uWorldTransformMatrix;
|
|
414
|
+
uniform mat3 uTransformMatrix;
|
|
415
|
+
void main(void) {
|
|
404
416
|
vUV = aUV;
|
|
405
|
-
|
|
406
|
-
gl_Position = vec4(
|
|
417
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
|
|
418
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
407
419
|
}
|
|
408
420
|
`,t=`
|
|
409
421
|
precision mediump float;
|
|
410
|
-
|
|
422
|
+
in vec2 vUV;
|
|
423
|
+
out vec4 finalColor;
|
|
411
424
|
|
|
412
425
|
uniform float uTime;
|
|
413
426
|
uniform vec2 uResolution;
|
|
@@ -415,6 +428,7 @@ fn mainFrag(
|
|
|
415
428
|
uniform float uScale;
|
|
416
429
|
uniform float uDensity;
|
|
417
430
|
uniform float uHeight;
|
|
431
|
+
uniform vec2 uViewportOrigin;
|
|
418
432
|
|
|
419
433
|
float hash(vec2 p) {
|
|
420
434
|
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
|
@@ -432,61 +446,89 @@ fn mainFrag(
|
|
|
432
446
|
}
|
|
433
447
|
|
|
434
448
|
float fbm(vec2 p) {
|
|
435
|
-
float
|
|
436
|
-
float
|
|
437
|
-
|
|
438
|
-
p
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
p
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
449
|
+
float value = 0.0;
|
|
450
|
+
float amp = 0.5;
|
|
451
|
+
value += amp * noise(p);
|
|
452
|
+
p = p * 2.03 + vec2(17.13, 9.37);
|
|
453
|
+
amp *= 0.55;
|
|
454
|
+
value += amp * noise(p);
|
|
455
|
+
p = p * 2.01 + vec2(31.71, 4.23);
|
|
456
|
+
amp *= 0.55;
|
|
457
|
+
value += amp * noise(p);
|
|
458
|
+
p = p * 2.02 + vec2(15.41, 27.19);
|
|
459
|
+
amp *= 0.55;
|
|
460
|
+
value += amp * noise(p);
|
|
461
|
+
return value;
|
|
445
462
|
}
|
|
446
463
|
|
|
447
464
|
void main() {
|
|
448
|
-
vec2
|
|
449
|
-
|
|
465
|
+
vec2 safeResolution = max(uResolution, vec2(1.0));
|
|
466
|
+
vec2 rawUv = vUV;
|
|
467
|
+
vec2 uv = rawUv;
|
|
468
|
+
float aspect = safeResolution.x / safeResolution.y;
|
|
450
469
|
uv.x *= aspect;
|
|
470
|
+
vec2 viewportShift = vec2(
|
|
471
|
+
(uViewportOrigin.x / safeResolution.x) * aspect,
|
|
472
|
+
uViewportOrigin.y / safeResolution.y
|
|
473
|
+
);
|
|
474
|
+
vec2 worldUv = uv + viewportShift;
|
|
451
475
|
|
|
452
476
|
float normalizedDensity = uDensity;
|
|
453
477
|
if (normalizedDensity > 4.0) {
|
|
454
|
-
normalizedDensity = normalizedDensity /
|
|
478
|
+
normalizedDensity = normalizedDensity / 120.0;
|
|
455
479
|
}
|
|
456
|
-
float density = clamp(normalizedDensity, 0.0, 2.
|
|
480
|
+
float density = clamp(normalizedDensity, 0.0, 2.4);
|
|
481
|
+
float scale = clamp(uScale, 0.25, 4.0);
|
|
482
|
+
float speed = max(uSpeed * 8.0, 0.18);
|
|
483
|
+
|
|
484
|
+
vec2 driftA = vec2(uTime * 0.06 * speed, uTime * 0.02 * speed);
|
|
485
|
+
vec2 driftB = vec2(-uTime * 0.042 * speed, uTime * 0.016 * speed);
|
|
486
|
+
vec2 wobble = vec2(
|
|
487
|
+
sin(uTime * 0.23 * speed + worldUv.y * 4.0) * 0.03,
|
|
488
|
+
cos(uTime * 0.17 * speed + worldUv.x * 3.2) * 0.018
|
|
489
|
+
);
|
|
490
|
+
vec2 flowUv = worldUv + wobble;
|
|
491
|
+
|
|
492
|
+
float layerA = fbm(flowUv * scale + driftA);
|
|
493
|
+
float layerB = fbm(flowUv * (scale * 1.7) + driftB);
|
|
494
|
+
float layerC = fbm(vec2(flowUv.x * 0.75, flowUv.y * 1.35) * (scale * 1.2) + vec2(driftA.x * 0.6, -driftA.y * 0.8));
|
|
457
495
|
|
|
458
|
-
float
|
|
459
|
-
|
|
460
|
-
float
|
|
496
|
+
float wisps = smoothstep(0.2, 0.82, layerA);
|
|
497
|
+
float detail = smoothstep(0.28, 0.9, layerB);
|
|
498
|
+
float fogPattern = clamp(wisps * 0.55 + detail * 0.3 + layerC * 0.35, 0.0, 1.2);
|
|
461
499
|
|
|
462
|
-
float softness = smoothstep(0.35, 1.0, fogNoise);
|
|
463
500
|
float heightControl = clamp(uHeight, 0.0, 1.0);
|
|
464
501
|
float fullScreen = step(0.99, heightControl);
|
|
465
|
-
float
|
|
466
|
-
float heightFactor = mix(
|
|
502
|
+
float groundFog = pow(clamp(rawUv.y, 0.0, 1.0), 0.42);
|
|
503
|
+
float heightFactor = mix(groundFog, 1.0, heightControl);
|
|
467
504
|
heightFactor = mix(heightFactor, 1.0, fullScreen);
|
|
468
505
|
|
|
469
|
-
float
|
|
470
|
-
float
|
|
506
|
+
float breathing = 0.9 + 0.1 * sin(uTime * 0.25 * speed);
|
|
507
|
+
float fog = fogPattern * density * heightFactor * breathing;
|
|
508
|
+
float alpha = clamp(fog * 0.82, 0.0, 0.82);
|
|
471
509
|
|
|
472
|
-
vec3
|
|
473
|
-
|
|
510
|
+
vec3 baseColor = vec3(0.84, 0.88, 0.94);
|
|
511
|
+
vec3 brightColor = vec3(0.95, 0.97, 1.0);
|
|
512
|
+
vec3 fogColor = mix(baseColor, brightColor, detail * 0.45);
|
|
513
|
+
finalColor = vec4(fogColor * alpha, alpha);
|
|
474
514
|
}
|
|
475
|
-
`;return new P.GlProgram({vertex:
|
|
515
|
+
`;return new P.GlProgram({vertex:u,fragment:t})}function Br(){const u=`
|
|
476
516
|
precision mediump float;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
uniform mat3
|
|
481
|
-
uniform mat3
|
|
482
|
-
|
|
517
|
+
in vec2 aPosition;
|
|
518
|
+
in vec2 aUV;
|
|
519
|
+
out vec2 vUV;
|
|
520
|
+
uniform mat3 uProjectionMatrix;
|
|
521
|
+
uniform mat3 uWorldTransformMatrix;
|
|
522
|
+
uniform mat3 uTransformMatrix;
|
|
523
|
+
void main(void) {
|
|
483
524
|
vUV = aUV;
|
|
484
|
-
|
|
485
|
-
gl_Position = vec4(
|
|
525
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
|
|
526
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
|
|
486
527
|
}
|
|
487
528
|
`,t=`
|
|
488
529
|
precision mediump float;
|
|
489
|
-
|
|
530
|
+
in vec2 vUV;
|
|
531
|
+
out vec4 finalColor;
|
|
490
532
|
|
|
491
533
|
uniform float uTime;
|
|
492
534
|
uniform vec2 uResolution;
|
|
@@ -494,6 +536,12 @@ fn mainFrag(
|
|
|
494
536
|
uniform float uScale;
|
|
495
537
|
uniform float uDensity;
|
|
496
538
|
uniform float uHeight;
|
|
539
|
+
uniform vec2 uViewportOrigin;
|
|
540
|
+
uniform float uSunIntensity;
|
|
541
|
+
uniform vec2 uSunDirection;
|
|
542
|
+
uniform float uRaySpread;
|
|
543
|
+
uniform float uRayTwinkle;
|
|
544
|
+
uniform float uRayTwinkleSpeed;
|
|
497
545
|
|
|
498
546
|
float hash(vec2 p) {
|
|
499
547
|
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
|
@@ -524,35 +572,81 @@ fn mainFrag(
|
|
|
524
572
|
}
|
|
525
573
|
|
|
526
574
|
void main() {
|
|
575
|
+
vec2 safeResolution = max(uResolution, vec2(1.0));
|
|
527
576
|
vec2 uv = vUV;
|
|
528
|
-
float aspect =
|
|
577
|
+
float aspect = safeResolution.x / safeResolution.y;
|
|
529
578
|
uv.x *= aspect;
|
|
579
|
+
vec2 viewportShift = vec2(
|
|
580
|
+
(uViewportOrigin.x / safeResolution.x) * aspect,
|
|
581
|
+
uViewportOrigin.y / safeResolution.y
|
|
582
|
+
);
|
|
583
|
+
vec2 worldUv = uv + viewportShift;
|
|
530
584
|
|
|
531
585
|
float normalizedDensity = uDensity;
|
|
532
586
|
if (normalizedDensity > 4.0) {
|
|
533
587
|
normalizedDensity = normalizedDensity / 100.0;
|
|
534
588
|
}
|
|
535
589
|
float density = clamp(normalizedDensity, 0.0, 2.0);
|
|
590
|
+
float scale = clamp(uScale, 0.2, 4.0);
|
|
591
|
+
float speed = max(uSpeed * 6.0, 0.12);
|
|
592
|
+
vec2 driftMain = vec2(uTime * 0.04 * speed, uTime * 0.012 * speed);
|
|
593
|
+
vec2 driftDetail = vec2(-uTime * 0.028 * speed, uTime * 0.01 * speed);
|
|
594
|
+
vec2 wobble = vec2(
|
|
595
|
+
sin(uTime * 0.18 * speed + worldUv.y * 4.8) * 0.035,
|
|
596
|
+
cos(uTime * 0.16 * speed + worldUv.x * 3.7) * 0.02
|
|
597
|
+
);
|
|
598
|
+
vec2 flowUv = worldUv + wobble;
|
|
536
599
|
|
|
537
|
-
float
|
|
538
|
-
|
|
539
|
-
float cloudNoise = fbm(uv * scale + drift);
|
|
540
|
-
float detailNoise = fbm(uv * (scale * 2.4) + drift * 1.7);
|
|
600
|
+
float cloudNoise = fbm(flowUv * scale + driftMain);
|
|
601
|
+
float detailNoise = fbm(flowUv * (scale * 2.4) + driftDetail);
|
|
541
602
|
|
|
542
|
-
float shape = smoothstep(0.
|
|
543
|
-
float detail = smoothstep(0.
|
|
544
|
-
float puff = shape * (0.
|
|
603
|
+
float shape = smoothstep(0.4, 0.93, cloudNoise);
|
|
604
|
+
float detail = smoothstep(0.36, 0.9, detailNoise);
|
|
605
|
+
float puff = shape * (0.55 + 0.45 * detail);
|
|
545
606
|
|
|
546
607
|
float heightControl = clamp(uHeight, 0.0, 1.0);
|
|
547
608
|
float fullScreen = step(0.99, heightControl);
|
|
548
|
-
float
|
|
549
|
-
float heightFactor = mix(
|
|
609
|
+
float skyHeight = pow(clamp(1.0 - vUV.y, 0.0, 1.0), 0.68);
|
|
610
|
+
float heightFactor = mix(skyHeight, 1.0, heightControl);
|
|
550
611
|
heightFactor = mix(heightFactor, 1.0, fullScreen);
|
|
551
|
-
float cloud = puff * density * 0.
|
|
552
|
-
float
|
|
612
|
+
float cloud = puff * density * 0.72 * heightFactor;
|
|
613
|
+
float cloudAlpha = clamp(cloud, 0.0, 0.68);
|
|
553
614
|
|
|
554
|
-
|
|
555
|
-
|
|
615
|
+
vec2 sunDir = uSunDirection;
|
|
616
|
+
if (length(sunDir) < 0.0001) {
|
|
617
|
+
sunDir = vec2(0.55, 1.0);
|
|
618
|
+
}
|
|
619
|
+
sunDir = normalize(sunDir);
|
|
620
|
+
vec2 rayUv = worldUv;
|
|
621
|
+
float spread = clamp(uRaySpread, 0.35, 2.5);
|
|
622
|
+
float rayCoord = dot(rayUv, sunDir) * (6.5 / spread);
|
|
623
|
+
float rayNoise = fbm(vec2(rayCoord, rayUv.y * 0.55));
|
|
624
|
+
float shafts = smoothstep(0.5, 0.9, rayNoise);
|
|
625
|
+
float skyFade = pow(clamp(1.0 - vUV.y, 0.0, 1.0), 1.25);
|
|
626
|
+
float cloudGap = clamp(1.0 - cloudAlpha * 1.05, 0.0, 1.0);
|
|
627
|
+
float twinkleAmount = clamp(uRayTwinkle, 0.0, 1.5);
|
|
628
|
+
float twinkleSpeed = max(uRayTwinkleSpeed, 0.01);
|
|
629
|
+
float twinklePulse = 0.5 + 0.5 * sin(uTime * 1.9 * twinkleSpeed + rayCoord * 1.8);
|
|
630
|
+
float twinkleNoise = fbm(vec2(rayCoord * 1.35 + 13.7, uTime * 0.1 * twinkleSpeed));
|
|
631
|
+
float twinkle = mix(
|
|
632
|
+
1.0,
|
|
633
|
+
clamp(0.7 + 0.35 * twinklePulse + 0.25 * twinkleNoise, 0.35, 1.55),
|
|
634
|
+
twinkleAmount
|
|
635
|
+
);
|
|
636
|
+
float rayAlpha = shafts * skyFade * cloudGap * clamp(uSunIntensity, 0.0, 2.0) * twinkle * 0.58;
|
|
637
|
+
|
|
638
|
+
vec3 cloudDark = vec3(0.82, 0.87, 0.94);
|
|
639
|
+
vec3 cloudBright = vec3(0.98, 0.99, 1.0);
|
|
640
|
+
vec3 cloudColor = mix(cloudDark, cloudBright, detail * 0.55);
|
|
641
|
+
vec3 rayColor = vec3(1.0, 0.95, 0.8);
|
|
642
|
+
|
|
643
|
+
float totalAlpha = cloudAlpha + rayAlpha;
|
|
644
|
+
float alpha = clamp(totalAlpha, 0.0, 0.86);
|
|
645
|
+
vec3 premulColor = cloudColor * cloudAlpha + rayColor * rayAlpha;
|
|
646
|
+
if (totalAlpha > 0.0001) {
|
|
647
|
+
premulColor *= (alpha / totalAlpha);
|
|
648
|
+
}
|
|
649
|
+
finalColor = vec4(premulColor, alpha);
|
|
556
650
|
}
|
|
557
|
-
`;return new P.GlProgram({vertex:h,fragment:t})}const ei=h=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:s=D.signal(.2),density:c=D.signal(120),maxDrops:l=D.signal(80),height:o=D.signal(1),scale:y=D.signal(2),resolution:C}=D.useProps(h),v=D.signal([1e3,1e3]),B=D.signal(0),A=D.signal(0),I=D.signal(0),M=D.signal(0);let N;const O=C?typeof C=="function"?C:D.signal(C):v;D.mount(ft=>{const ct=ft.props.context;if(N=ct?.viewport,N?.getVisibleBounds){const J=N.getVisibleBounds();J&&(v.set([J.width,J.height]),B.set(J.width),A.set(J.height),I.set(J.x),M.set(J.y))}ct?.canvasSize&&t(()=>{const J=ct.canvasSize();J&&J.width>0&&J.height>0&&(N?.getVisibleBounds||(v.set([J.width,J.height]),B.set(J.width),A.set(J.height),I.set(0),M.set(0)))})});const _=typeof e=="function"?e:D.signal(e),E=typeof i=="function"?i:D.signal(i),m=typeof s=="function"?s:D.signal(s),d=typeof c=="function"?c:D.signal(c),b=typeof l=="function"?l:D.signal(l),R=typeof o=="function"?o:D.signal(o),U=typeof y=="function"?y:D.signal(y),k=ft=>typeof ft=="number"&&Number.isFinite(ft)?ft:1;let g,V;if(t()==="rain")g=dr(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uRainSpeed:{value:_(),type:"f32"},uWindDirection:{value:E(),type:"f32"},uWindStrength:{value:m(),type:"f32"},uRainDensity:{value:d(),type:"f32"},uMaxDrops:{value:b(),type:"f32"}};else if(t()==="snow")g=pr(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uSnowSpeed:{value:_(),type:"f32"},uWindDirection:{value:E(),type:"f32"},uWindStrength:{value:m(),type:"f32"},uSnowDensity:{value:d(),type:"f32"},uMaxFlakes:{value:b(),type:"f32"}};else if(t()==="fog")g=mr(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uSpeed:{value:_(),type:"f32"},uScale:{value:U(),type:"f32"},uDensity:{value:d(),type:"f32"},uHeight:{value:k(R()),type:"f32"}};else if(t()==="cloud")g=_r(),V={uTime:{value:0,type:"f32"},uResolution:{value:O(),type:"vec2<f32>"},uSpeed:{value:_(),type:"f32"},uScale:{value:U(),type:"f32"},uDensity:{value:d(),type:"f32"},uHeight:{value:k(R()),type:"f32"}};else throw new Error(`Unknown weather effect: ${t()}. Supported: rain, snow, fog, cloud`);const j=new P.UniformGroup(V),z=new P.Shader({glProgram:g,resources:{uniforms:j}}),Q=new P.Geometry({attributes:{aPosition:[0,0,1,0,1,1,0,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let ut=Math.random()*10,tt=[...O()],ht=E(),L=m(),nt=_(),dt=d(),yt=b(),K=R(),W=U();return D.tick(({deltaTime:ft})=>{if(N?.getVisibleBounds){const $=N.getVisibleBounds();if($){const f=$.width,a=$.height,S=$.x,w=$.y;f!==B()&&B.set(f),a!==A()&&A.set(a),S!==I()&&I.set(S),w!==M()&&M.set(w);const q=v();(q[0]!==f||q[1]!==a)&&v.set([f,a])}}ut+=ft/600,j.uniforms.uTime=ut;const ct=O();(ct[0]!==tt[0]||ct[1]!==tt[1])&&(j.uniforms.uResolution=ct,tt=[...ct]);const J=E();if(J!==ht&&(j.uniforms.uWindDirection=J,ht=J),t()==="rain"||t()==="snow"){const $=m();$!==L&&(j.uniforms.uWindStrength=$,L=$)}if(t()==="rain"){const $=_();$!==nt&&(j.uniforms.uRainSpeed=$,nt=$);const f=d();f!==dt&&(j.uniforms.uRainDensity=f,dt=f);const a=b();a!==yt&&(j.uniforms.uMaxDrops=a,yt=a)}else if(t()==="snow"){const $=_();$!==nt&&(j.uniforms.uSnowSpeed=$,nt=$);const f=d();f!==dt&&(j.uniforms.uSnowDensity=f,dt=f);const a=b();a!==yt&&(j.uniforms.uMaxFlakes=a,yt=a)}else if(t()==="fog"||t()==="cloud"){const $=_();$!==nt&&(j.uniforms.uSpeed=$,nt=$);const f=U();f!==W&&(j.uniforms.uScale=f,W=f);const a=d();a!==dt&&(j.uniforms.uDensity=a,dt=a);const S=k(R());S!==K&&(j.uniforms.uHeight=S,K=S)}}),D.h(D.Mesh,{geometry:Q,shader:z,width:B,height:A,x:I,y:M})},gr=ei;return At.Bar=si,At.Loading=Ti,At.NightAmbiant=bi,At.Particle=di,At.TiledMap=fr,At.Weather=gr,At.WeatherEffect=ei,At.createNightFilter=Fe,Object.defineProperty(At,Symbol.toStringTag,{value:"Module"}),At})({},CanvasEngine,PIXI);
|
|
651
|
+
`;return new P.GlProgram({vertex:u,fragment:t})}const ci={lightRain:{effect:"rain",speed:.35,windDirection:.1,windStrength:.15,density:110,maxDrops:90},steadyRain:{effect:"rain",speed:.6,windDirection:.2,windStrength:.3,density:180,maxDrops:120},stormRain:{effect:"rain",speed:1.4,windDirection:.7,windStrength:.75,density:300,maxDrops:150}},ui={lightSnow:{effect:"snow",speed:.35,windDirection:.1,windStrength:.18,density:90,maxDrops:100},winterSnow:{effect:"snow",speed:.5,windDirection:.2,windStrength:.28,density:150,maxDrops:130},blizzardSnow:{effect:"snow",speed:1.1,windDirection:.8,windStrength:.75,density:290,maxDrops:160}},hi={rpgMorningMist:{effect:"fog",speed:.16,density:.75,height:.45,scale:1.35},rpgForestFog:{effect:"fog",speed:.22,density:1,height:.62,scale:1.75},rpgSwampFog:{effect:"fog",speed:.14,density:1.3,height:.55,scale:2.1},rpgNightFog:{effect:"fog",speed:.12,density:1.15,height:.58,scale:1.9},rpgHeavyFog:{effect:"fog",speed:.1,density:1.7,height:.72,scale:2.3}},fi={lightClouds:{effect:"cloud",speed:.16,density:.55,height:.72,scale:1.35,sunIntensity:1,sunAngle:.84,raySpread:.92,rayTwinkle:.25,rayTwinkleSpeed:.9},overcastClouds:{effect:"cloud",speed:.12,density:.95,height:.86,scale:1.85,sunIntensity:.4,sunAngle:.95,raySpread:1.15,rayTwinkle:.18,rayTwinkleSpeed:.7},stormClouds:{effect:"cloud",speed:.2,density:1.25,height:.94,scale:2.2,sunIntensity:.12,sunAngle:1.08,raySpread:1.35,rayTwinkle:.12,rayTwinkleSpeed:.6},goldenHourRays:{effect:"cloud",speed:.14,density:.72,height:.82,scale:1.5,sunIntensity:1.3,sunAngle:.72,raySpread:.78,rayTwinkle:.78,rayTwinkleSpeed:1.4},sunnySoftRays:{effect:"cloud",speed:.13,density:.62,height:.76,scale:1.4,sunIntensity:1.05,sunAngle:.8,raySpread:.95,rayTwinkle:.35,rayTwinkleSpeed:.95},sunsetTwinkleRays:{effect:"cloud",speed:.1,density:.74,height:.84,scale:1.55,sunIntensity:1.35,sunAngle:.64,raySpread:.8,rayTwinkle:1,rayTwinkleSpeed:1.6},dramaticCrepuscularRays:{effect:"cloud",speed:.11,density:.9,height:.9,scale:1.9,sunIntensity:1.5,sunAngle:.7,raySpread:.68,rayTwinkle:.6,rayTwinkleSpeed:1.2},morningHazeRays:{effect:"cloud",speed:.09,density:.52,height:.7,scale:1.3,sunIntensity:.9,sunAngle:.9,raySpread:1.05,rayTwinkle:.42,rayTwinkleSpeed:.8}},Ir={rain:ci,snow:ui,fog:hi,cloud:fi},di=u=>{const{effect:t=I.signal("rain"),speed:e=I.signal(.5),windDirection:i=I.signal(0),windStrength:s=I.signal(.2),density:c=I.signal(120),maxDrops:o=I.signal(80),height:a=I.signal(1),scale:y=I.signal(2),sunIntensity:C=I.signal(.85),sunAngle:S=I.signal(.85),raySpread:B=I.signal(1),rayTwinkle:A=I.signal(.45),rayTwinkleSpeed:D=I.signal(1),resolution:F,...R}=I.useProps(u),N=I.signal([1e3,1e3]),m=I.signal(N()[0]),x=I.signal(N()[1]),_=I.signal(0),f=I.signal(0);let b;const O=typeof t=="function"?t:I.signal(t),k=F?typeof F=="function"?F:I.signal(F):N;I.mount(n=>{const p=n.props.context;let w=n.parent,v=!1;for(;w;){if(w.tag==="Viewport"){v=!0;break}w=w.parent}if(b=v?p?.viewport:void 0,b?.getVisibleBounds){const T=b.getVisibleBounds();T&&T.width>0&&T.height>0&&(N.set([T.width,T.height]),m.set(T.width),x.set(T.height),_.set(T.x),f.set(T.y))}p?.canvasSize&&I.effect(()=>{const T=p.canvasSize();T&&T.width>0&&T.height>0&&(b?.getVisibleBounds||(N.set([T.width,T.height]),m.set(T.width),x.set(T.height),_.set(0),f.set(0)))})});const L=typeof e=="function"?e:I.signal(e),g=typeof i=="function"?i:I.signal(i),q=typeof s=="function"?s:I.signal(s),Y=typeof c=="function"?c:I.signal(c),G=typeof o=="function"?o:I.signal(o),st=typeof a=="function"?a:I.signal(a),ft=typeof y=="function"?y:I.signal(y),at=typeof C=="function"?C:I.signal(C),ot=typeof S=="function"?S:I.signal(S),K=typeof B=="function"?B:I.signal(B),gt=typeof A=="function"?A:I.signal(A),xt=typeof D=="function"?D:I.signal(D),mt=n=>typeof n=="number"&&Number.isFinite(n)?n:1,W=n=>typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):.85,tt=n=>typeof n=="number"&&Number.isFinite(n)?n:.85,Tt=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?n:1,vt=n=>typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):.45,Ft=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?n:1,Rt=n=>[Math.cos(n),Math.sin(n)],d=n=>{if(!Array.isArray(n))return[1,1];const p=typeof n[0]=="number"&&Number.isFinite(n[0])&&n[0]>0?n[0]:1,w=typeof n[1]=="number"&&Number.isFinite(n[1])&&n[1]>0?n[1]:1;return[p,w]};let l,M;if(O()==="rain")l=Cr(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uRainSpeed:{value:L(),type:"f32"},uWindDirection:{value:g(),type:"f32"},uWindStrength:{value:q(),type:"f32"},uRainDensity:{value:Y(),type:"f32"},uMaxDrops:{value:G(),type:"f32"}};else if(O()==="snow")l=Mr(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uSnowSpeed:{value:L(),type:"f32"},uWindDirection:{value:g(),type:"f32"},uWindStrength:{value:q(),type:"f32"},uSnowDensity:{value:Y(),type:"f32"},uMaxFlakes:{value:G(),type:"f32"}};else if(O()==="fog")l=Fr(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uSpeed:{value:L(),type:"f32"},uScale:{value:ft(),type:"f32"},uDensity:{value:Y(),type:"f32"},uHeight:{value:mt(st()),type:"f32"},uViewportOrigin:{value:[_(),f()],type:"vec2<f32>"}};else if(O()==="cloud"){const n=tt(ot());l=Br(),M={uTime:{value:0,type:"f32"},uResolution:{value:d(k()),type:"vec2<f32>"},uSpeed:{value:L(),type:"f32"},uScale:{value:ft(),type:"f32"},uDensity:{value:Y(),type:"f32"},uHeight:{value:mt(st()),type:"f32"},uViewportOrigin:{value:[_(),f()],type:"vec2<f32>"},uSunIntensity:{value:W(at()),type:"f32"},uSunDirection:{value:Rt(n),type:"vec2<f32>"},uRaySpread:{value:Tt(K()),type:"f32"},uRayTwinkle:{value:vt(gt()),type:"f32"},uRayTwinkleSpeed:{value:Ft(xt()),type:"f32"}}}else throw new Error(`Unknown weather effect: ${O()}. Supported: rain, snow, fog, cloud`);const E=new P.UniformGroup(M),Q=new P.Shader({glProgram:l,resources:{uniforms:E}}),lt=new P.Geometry({attributes:{aPosition:[0,0,1,0,1,1,0,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let it=Math.random()*10,U=[...d(k())],z=g(),X=q(),j=L(),$=Y(),ct=G(),ut=st(),rt=ft(),ht=W(at()),Pt=tt(ot()),jt=Tt(K()),wt=vt(gt()),Wt=Ft(xt()),h=_(),r=f();return I.tick(({deltaTime:n})=>{if(b?.getVisibleBounds){const v=b.getVisibleBounds();if(v&&v.width>0&&v.height>0){const T=v.width,V=v.height,J=v.x,Z=v.y;T!==m()&&m.set(T),V!==x()&&x.set(V),J!==_()&&_.set(J),Z!==f()&&f.set(Z);const nt=N();(nt[0]!==T||nt[1]!==V)&&N.set([T,V])}}it+=n/600,E.uniforms.uTime=it;const p=d(k());if((p[0]!==U[0]||p[1]!==U[1])&&(E.uniforms.uResolution=p,U=[...p]),O()==="fog"||O()==="cloud"){const v=_(),T=f();(v!==h||T!==r)&&(E.uniforms.uViewportOrigin=[v,T],h=v,r=T)}const w=g();if(w!==z&&(E.uniforms.uWindDirection=w,z=w),O()==="rain"||O()==="snow"){const v=q();v!==X&&(E.uniforms.uWindStrength=v,X=v)}if(O()==="rain"){const v=L();v!==j&&(E.uniforms.uRainSpeed=v,j=v);const T=Y();T!==$&&(E.uniforms.uRainDensity=T,$=T);const V=G();V!==ct&&(E.uniforms.uMaxDrops=V,ct=V)}else if(O()==="snow"){const v=L();v!==j&&(E.uniforms.uSnowSpeed=v,j=v);const T=Y();T!==$&&(E.uniforms.uSnowDensity=T,$=T);const V=G();V!==ct&&(E.uniforms.uMaxFlakes=V,ct=V)}else if(O()==="fog"||O()==="cloud"){const v=L();v!==j&&(E.uniforms.uSpeed=v,j=v);const T=ft();T!==rt&&(E.uniforms.uScale=T,rt=T);const V=Y();V!==$&&(E.uniforms.uDensity=V,$=V);const J=mt(st());if(J!==ut&&(E.uniforms.uHeight=J,ut=J),O()==="cloud"){const Z=W(at());Z!==ht&&(E.uniforms.uSunIntensity=Z,ht=Z);const nt=tt(ot());nt!==Pt&&(E.uniforms.uSunDirection=Rt(nt),Pt=nt);const et=Tt(K());et!==jt&&(E.uniforms.uRaySpread=et,jt=et);const De=vt(gt());De!==wt&&(E.uniforms.uRayTwinkle=De,wt=De);const Ne=Ft(xt());Ne!==Wt&&(E.uniforms.uRayTwinkleSpeed=Ne,Wt=Ne)}}}),I.h(I.Mesh,{...R,geometry:lt,shader:Q,width:m,height:x,x:_,y:f})},Dr=di,Nr=[0,0,0,1],Or=[0,0,0,.55],Be={clarity:0,explored:!1},Ie=()=>Be,pi=new WeakMap,It=(u,t,e)=>Math.max(t,Math.min(e,u)),Rr=(u,t,e)=>{if(t<=u)return e>=t?1:0;const i=It((e-u)/(t-u),0,1);return i*i*(3-2*i)},dt=u=>typeof u=="function"?u():u;function Pr(){const u=I.signal(0);let t=Ie;const e=(s,c)=>(u(),!Number.isFinite(s)||!Number.isFinite(c)?Be:t(s,c)),i={version:()=>u(),clarityAt:(s,c)=>It(e(s,c).clarity,0,1),isVisibleAt:(s,c,o=.65)=>e(s,c).clarity>=It(o,0,1),isExploredAt:(s,c)=>{const o=e(s,c);return o.explored||o.clarity>0},stateAt:(s,c,o=.65)=>{const a=e(s,c);return a.clarity>=It(o,0,1)?"visible":a.explored||a.clarity>0?"explored":"unknown"}};return pi.set(i,{setSampler(s){t=typeof s=="function"?s:Ie},notifyUpdate(){u.update(s=>s+1)}}),i}const mi=(u,t)=>{const e=Array.isArray(u)?u:t,[i,s,c,o]=e,a=(y,C=!1)=>Number.isFinite(y)?y>=0&&y<=1?Math.round(y*255):It(Math.round(y),0,255):C?255:0;return{r:a(i),g:a(s),b:a(c),a:a(o,!0)}},kr=u=>{const t=dt(u);return Array.isArray(t)?t:[]};function Ur(u){const{mapWidth:t,mapHeight:e,tileSize:i=I.signal(32),smooth:s=I.signal(!0),renderScale:c=I.signal(2),edgeSoftness:o=I.signal(22),visionSources:a=I.signal([]),colors:y=I.signal({}),updateHz:C=I.signal(15),initialExplored:S=I.signal(!1),controller:B=void 0,obstacleMap:A=void 0,...D}=I.useProps(u);let F,R=null,N=P.Texture.WHITE,m=null,x=null,_=new Float32Array(0),f=new Uint8Array(0),b=1,O=1,k=1,L=1,g=1,q=1,Y=1,G=1,st=0,ft=!0,at=null,ot=null,K=[];if(F=(()=>{if(typeof document>"u")throw new Error("FogOfWar: document is undefined, canvas cannot be created.");const U=document.createElement("canvas");return U.width=1,U.height=1,U})(),R=F.getContext("2d",{willReadFrequently:!0}),!R)throw new Error("FogOfWar: unable to create 2D context for fog canvas.");N=P.Texture.from(F);const xt=()=>{const z=dt(s)!==!1?2:1,X=Number(dt(c));return Number.isFinite(X)?It(Math.round(X),1,8):z},mt=()=>{if(dt(s)===!1)return 0;const U=Number(dt(o));return Number.isFinite(U)?Math.max(0,U):Math.max(Y*.9,2)},W=()=>{const U=dt(B);return U&&typeof U=="object"?U:void 0},tt=()=>{const U=kr(a),z=[];for(let X=0;X<U.length;X++){const j=U[X];z.push({x:Number(dt(j.x)),y:Number(dt(j.y)),radius:Number(dt(j.radius)),enabled:dt(j.enabled)!==!1})}return z},Tt=U=>{const z=new Array(U.length*4);let X=0;for(let $=0;$<U.length;$++){const ct=U[$];z[X++]=ct.x,z[X++]=ct.y,z[X++]=ct.radius,z[X++]=ct.enabled?1:0}let j=z.length!==K.length;if(!j)for(let $=0;$<z.length;$++){const ct=z[$],ut=K[$];if(Number.isNaN(ct)!==Number.isNaN(ut)||Math.abs(ct-ut)>.01){j=!0;break}}return K=z,j},vt=(U,z)=>{if(!Number.isFinite(U)||!Number.isFinite(z)||k<=0||b<=0||O<=0)return Be;const X=It(U,0,Math.max(0,L-1)),j=It(z,0,Math.max(0,g-1)),$=Math.min(b-1,Math.max(0,Math.floor(X/Y))),ut=Math.min(O-1,Math.max(0,Math.floor(j/Y)))*b+$;return{clarity:It(_[ut]??0,0,1),explored:f[ut]===1}},Ft=U=>{const z=W()??null;z!==at&&(ot&&ot.setSampler(Ie),at=z,ot=at?pi.get(at)??null:null,ot&&ot.setSampler(vt),U=!0),U&&ot&&ot.notifyUpdate()},Rt=()=>{const U=N.source;U&&(U.scaleMode=dt(s)===!1?"nearest":"linear")},d=(U,z,X,j)=>{L=Math.max(1,Math.floor(U)),g=Math.max(1,Math.floor(z)),q=Math.max(1,Math.floor(X)),G=It(j,1,8),Y=Math.max(1,q/G),b=Math.max(1,Math.ceil(L/Y)),O=Math.max(1,Math.ceil(g/Y)),k=b*O,"width"in F&&(F.width=b,F.height=O),_=new Float32Array(k),f=new Uint8Array(k),dt(S)&&f.fill(1),m=R?.createImageData(b,O)??null,x=m?.data??null,Rt(),ft=!0},l=(U,z)=>{if(U.enabled===!1||!Number.isFinite(U.x)||!Number.isFinite(U.y)||!Number.isFinite(U.radius)||U.radius<=0)return;const X=U.x,j=U.y,ct=U.radius/Y,ut=Math.max(0,ct-z),rt=Math.max(ct,ct+z),ht=ut*ut,Pt=rt*rt,jt=Math.max(0,Math.floor(X/Y-rt)),wt=Math.min(b-1,Math.ceil(X/Y+rt)),Wt=Math.max(0,Math.floor(j/Y-rt)),h=Math.min(O-1,Math.ceil(j/Y+rt));for(let r=Wt;r<=h;r++)for(let n=jt;n<=wt;n++){const p=(n+.5)*Y,w=(r+.5)*Y,v=p-X,T=w-j,V=(v*v+T*T)/(Y*Y);if(V>Pt)continue;let J=1;if(rt>ut&&V>ht){const nt=Math.sqrt(V);J=1-Rr(ut,rt,nt)}if(J<=.001)continue;const Z=r*b+n;J>_[Z]&&(_[Z]=J),J>.02&&(f[Z]=1)}},M=U=>{if(!m||!x||!R)return;const z=dt(y)||{},X=mi(z.unknown,Nr),j=mi(z.explored,Or);_.fill(0);const $=U??tt(),ct=mt()/Y;for(let rt=0;rt<$.length;rt++)l($[rt],ct);for(let rt=0;rt<k;rt++){const ht=rt*4,Pt=It(_[rt],0,1),wt=f[rt]===1?j:X;x[ht]=wt.r,x[ht+1]=wt.g,x[ht+2]=wt.b,x[ht+3]=Math.round(wt.a*(1-Pt))}R.putImageData(m,0,0);const ut=N.source;ut&&typeof ut.update=="function"?ut.update():typeof N.update=="function"&&N.update(),Ft(!0)},E=Number(dt(t))||1,Q=Number(dt(e))||1,lt=Number(dt(i))||32,it=xt();return d(E,Q,lt,it),M(),I.tick(({deltaTime:U})=>{if(!R)return;const z=Math.max(1,Number(dt(t))||1),X=Math.max(1,Number(dt(e))||1),j=Math.max(1,Number(dt(i))||32),$=xt();(z!==L||X!==g||j!==q||$!==G)&&d(z,X,j,$),Rt(),Ft(!1);const ct=tt(),ut=Tt(ct);ut&&(ft=!0);const ht=1e3/Math.max(1,Number(dt(C))||15);st+=U,(ft||ut||st>=ht)&&(st=0,ft=!1,M(ct))}),I.h(I.Sprite,{...D,texture:N,x:0,y:0,width:Math.max(1,Number(dt(t))||1),height:Math.max(1,Number(dt(e))||1),roundPixels:!0})}return Et.Bar=gi,Et.CLOUD_PRESETS=fi,Et.FOG_PRESETS=hi,Et.FogOfWar=Ur,Et.Loading=Ui,Et.NightAmbiant=ki,Et.Particle=Ci,Et.RAIN_PRESETS=ci,Et.SNOW_PRESETS=ui,Et.TiledMap=Ar,Et.WEATHER_PRESETS=Ir,Et.Weather=Dr,Et.WeatherEffect=di,Et.createFogOfWarController=Pr,Et.createNightFilter=Ue,Object.defineProperty(Et,Symbol.toStringTag,{value:"Module"}),Et})({},CanvasEngine,PIXI);
|
|
558
652
|
//# sourceMappingURL=index.global.js.map
|