@canvasengine/presets 2.0.0-beta.4 → 2.0.0-beta.41
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/Bar.d.ts +14 -0
- package/dist/Bar.d.ts.map +1 -0
- package/dist/Button.d.ts +1 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Loading.d.ts +94 -0
- package/dist/Loading.d.ts.map +1 -0
- package/dist/NightAmbiant.d.ts +3 -0
- package/dist/NightAmbiant.d.ts.map +1 -0
- package/dist/Particle.d.ts +2 -0
- package/dist/Particle.d.ts.map +1 -0
- package/dist/Tilemap/Tile.d.ts +23 -0
- package/dist/Tilemap/Tile.d.ts.map +1 -0
- package/dist/Tilemap/TileGroup.d.ts +62 -0
- package/dist/Tilemap/TileGroup.d.ts.map +1 -0
- package/dist/Tilemap/TileSet.d.ts +11 -0
- package/dist/Tilemap/TileSet.d.ts.map +1 -0
- package/dist/Tilemap/index.d.ts +2 -0
- package/dist/Tilemap/index.d.ts.map +1 -0
- package/dist/Weathers/fog.d.ts +3 -0
- package/dist/Weathers/fog.d.ts.map +1 -0
- package/dist/Weathers/index.d.ts +6 -0
- package/dist/Weathers/index.d.ts.map +1 -0
- package/dist/Weathers/rain.d.ts +20 -0
- package/dist/Weathers/rain.d.ts.map +1 -0
- package/dist/Weathers/snow.d.ts +12 -0
- package/dist/Weathers/snow.d.ts.map +1 -0
- package/dist/index.d.ts +7 -54
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +527 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +6248 -692
- package/dist/index.js.map +1 -1
- package/package.json +36 -11
- package/src/Bar.ts +0 -87
- package/src/Button.ts +0 -0
- package/src/DrawMap/index.ts +0 -60
- package/src/Joystick.ts +0 -284
- package/src/NightAmbiant.ts +0 -116
- package/src/Particle.ts +0 -50
- package/src/Tilemap/Tile.ts +0 -79
- package/src/Tilemap/TileGroup.ts +0 -207
- package/src/Tilemap/TileLayer.ts +0 -162
- package/src/Tilemap/TileSet.ts +0 -41
- package/src/Tilemap/index.ts +0 -75
- package/src/index.ts +0 -6
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
var CanvasEnginePresets=function(xt,D,P){"use strict";function He(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 dt=He(P);function Qt(h){var t=h.toString(16);return t.length==1?"0"+t:t}function Qe(h,t,e){return"#"+Qt(h)+Qt(t)+Qt(e)}function Je(h){const{width:t,height:e,value:i,maxValue:s,backgroundColor:c,foregroundColor:a,border:o,innerMargin:y,borderRadius:S}=D.useProps(h,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...h,width:t,height:e,draw(x){S()?x.roundRect(0,0,t(),e(),S()):x.rect(0,0,t(),e()),o&&x.stroke(o),x.fill(c())}},D.h(D.Graphics,{width:t,height:e,draw(x){const C=y(),T=S(),M=Math.max(0,Math.min(t()-2*C,i()/s()*(t()-2*C))),F=e()-2*C;S?x.roundRect(C,C,M,F,T):x.rect(C,C,M,F);const N=a();if(N.startsWith("rgba")){const[O,_,v,m]=N.match(/\d+(\.\d+)?/g).map(Number);x.fill({color:Qe(O,_,v),alpha:m})}else x.fill(N)}}))}class zt{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 Dt{constructor(t){this.data=t}update(t){}dispose(){}}class ve extends Dt{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 dt.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 Jt;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip"})(Jt||(Jt={}));class Zt{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 G{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 Ut;(function(h){h.Circle="circle",h.Box="box",h.Ring="ring"})(Ut||(Ut={}));class Ze extends Zt{constructor(){super(Ut.Box)}emit(t){const e=this._settings,i=this.emitter,s=e.width*.5*this.__scaleMod,c=e.height*.5*this.__scaleMod;let a=i.rotation;const o=G.float(-s,s),y=G.float(-c,c);a!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+o*Math.cos(a)-y*Math.sin(a),t.component.y=this.__y+this._t*(this.y-this.__y)+o*Math.sin(a)+y*Math.cos(a)):(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?(a+=Math.atan2(y,o),t.dx=Math.cos(a),t.dy=Math.sin(a)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=a,this._t+=this._posInterpolationStep}}class ti extends Zt{constructor(){super(Ut.Circle)}emit(t){const e=this._settings,i=this.emitter;let s;if(e.angle?s=G.float(-e.angle*.5,e.angle*.5)+i.rotation:s=G.float(0,6.28319)+i.rotation,e.radius>0){let c=G.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 Zt{constructor(){super(Ut.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=G.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 Et;(function(h){h[h.Sprite=0]="Sprite",h[h.MovieClip=1]="MovieClip",h[h.Emitter=2]="Emitter",h[h.Trigger=3]="Trigger"})(Et||(Et={}));class ii extends dt.AnimatedSprite{constructor(t,e,i,s){let c=[],a=e.length;for(let o=0;o<a;o++)c.push(dt.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 ri{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 be;(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"})(be||(be={}));class _t{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,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),-(c*Math.pow(2,10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a))+e}static easeOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s),a||(a=s*.3),c<Math.abs(i)?(c=i,o=a/4):o=a/(2*Math.PI)*Math.asin(i/c),c*Math.pow(2,-10*t)*Math.sin((t*s-o)*(2*Math.PI)/a)+i+e}static easeInOutElastic(t,e,i,s){let c,a,o;return o=1.70158,a=0,c=i,t===0||(t/=s/2),a||(a=s*.44999999999999996),c<Math.abs(i)?(c=i,o=a/4):o=a/(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)/a))+e:c*Math.pow(2,-10*(t-=1))*Math.sin((t*s-o)*(2*Math.PI)/a)*.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=_t.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=_t.easeInBounce(t*2,0,i,s),c*.5+e):(c=_t.easeOutBounce(t*2-s,0,i,s),c*.5+i*.5+e)}}class ut{constructor(){this.__hasCallback=!1,this._list=new zt}add(t,e,i){this._list.add(new Dt(new Ae(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Dt(new Ae(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 a=i.data;a.callRate&&a.calls%a.callRate!=0&&(c=!1),c&&(a.callback.apply(a.scope,t),a.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 Ae{constructor(t,e,i,s){this.callback=t,this.scope=e,this.once=i,this.callRate=s,this.calls=0}}let si=class extends Dt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new ut,bounced:new ut,updated:new ut},this._color=new ri}init(t,e,i){const s=this.component,c=this.__fx;this.emitter=t,this.settings=e;const a=this.duration=G.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=G.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-G.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const o=G.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=G.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=_t[e.distanceEase],this.useAlign=!1}else s.x=this.startX,s.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(s.rotation=G.float(0,6.28319)),e.useAlpha&&(this.alphaStart=s.alpha=G.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=G.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=_t[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=a*(1-e.fadeInDurationFac),this.fadeInDuration=a*e.fadeInDurationFac,this.fadeInEase=_t[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=_t[e.scaleEase],e.uniformScale?(this.scaleStart=s.scale.x=s.scale.y=G.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(G.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=s.scale.x=G.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(G.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=_t[e.scaleXEase],this.scaleYStart=s.scale.y=G.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(G.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=_t[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=a*(1-e.scaleInDurationFac),this.scaleInDuration=a*e.scaleInDurationFac,this.scaleInEase=_t[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=G.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=G.sign())),e.useTint&&(this.tintEase=_t[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],S=c.getParticleEmitterById(y.id);S.init(t.container,!0,(y.scale||1)*(i||1)),y.adoptRotation&&(S.rotation=s.rotation,S.__adoptRotation=!0),S.__parent=this,this._childEmitters.push(S)}}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 a=t/.0166666;if(s.x+=this.moveSpeedX*a,s.y+=this.moveSpeedY*a,this.moveSpeedY+=this.gravity*a,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 a=this._childEmitters;let o=a.length;for(;--o>-1;){const y=a[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 wt{static sanitizeBundle(t){for(let e of t.emitters){const i=wt._presetStructure.emitter;wt.parse(e,i,wt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=wt._presetStructure.sequence;wt.parse(e,i,wt._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 a=e[s];if(!c.hasOwnProperty("length"))wt.parse(c,a,i);else for(let o of c)for(let y in i)o[y]==null&&(o[y]=i[y])}}}wt._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 ni extends dt.Sprite{constructor(t,e,i,s){super(dt.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 Nt(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]=Nt(i)}return t}var ai=function(h,t,e,i){function s(c){return c instanceof e?c:new e(function(a){a(c)})}return new(e||(e=Promise))(function(c,a){function o(x){try{S(i.next(x))}catch(C){a(C)}}function y(x){try{S(i.throw(x))}catch(C){a(C)}}function S(x){x.done?c(x.value):s(x.value).then(o,y)}S((i=i.apply(h,t||[])).next())})};class pt{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 zt,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,a;for(;c;)a=c.next,c.update(i),c=a;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,a)=>ai(this,void 0,void 0,function*(){const o={rfx_spritesheet:e,rfx_bundleSettings:t};for(var y in s)o[y]=s[y];dt.Assets.addBundle("rfx_assets",o);const S=yield dt.Assets.loadBundle("rfx_assets");c(this.initBundle(S.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==pt._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=pt.settingsVersion)throw new Error("Settings version mismatch.");wt.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 Te(t),s.__fx=this):s=i.pop(),e&&(c=Nt(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,a=this._settingsCache.emitters[t];if(!a)throw new Error(`Settings not defined for '${t}'`);return s.length==0?(c=new te(t),c.__fx=this):c=s.pop(),i&&(a=Nt(a),a.__isClone=!0),c.autoRecycleOnComplete=e,c.__applySettings(a),c}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let s;return i.length==0?(s=new te(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 Te(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(dt.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 ni(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 ii(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 si;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 pt.__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 dt.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?pt._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 a=t;a.values();for(const[o,y]of a)y instanceof dt.Texture&&(i[o]=y)}else i=t;const s={},c={sprites:[],movieClips:[]};for(let a in i)if(!(e&&a.indexOf(e)==-1)&&(this.initSprite(a,{texture:a,anchorX:.5,anchorY:.5}),c.sprites.push(a),a.substr(0,3)=="mc_")){const y=a.split("_")[1];s[y]==null&&(s[y]=[]),s[y].push(a)}for(let a in s){let o=s[a];c.movieClips.push(a),this.initMovieClip(a,{textures:o,anchorX:.5,anchorY:.5})}return c}}pt.settingsVersion=0,pt.version="1.3.4",pt._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",pt.ComponentType=Jt,pt.EffectSequenceComponentType=Et,pt._blendModes=["normal","add","multiply","screen"],pt.__emitterCores={circle:ti,box:Ze,ring:ei};var Pt;(function(h){h[h.ParticleEmitter=0]="ParticleEmitter",h[h.EffectSequence=1]="EffectSequence"})(Pt||(Pt={}));class te extends ve{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new zt,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new ut,completed:new ut,exhausted:new ut,particleUpdated:new ut,particleSpawned:new ut,particleBounced:new ut,particleDied:new ut}}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],a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container;a.init(o,!0,(c.scale||1)*(this._scaleMod||1)),c.adoptRotation&&(a.rotation=this._rotation,a.__adoptRotation=!0),a.__parent=this,this._childEmitters.push(a)}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+G.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let c=this._particles.first,a;for(;c;)a=c.next,c.update(t),c=a;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=G.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 a;switch(s.componentType){case 0:c.componentId=s.componentId,a=e.__getSprite(c.componentId);break;case 1:c.componentId=s.componentId,a=e.__getMovieClip(c.componentId),s.componentParams&&(a.loop=!(s.componentParams.loop==null||!s.componentParams.loop),a.animationSpeed=G.float(s.componentParams.animationSpeedMin||1,s.componentParams.animationSpeedMax||1)),a.gotoAndPlay(0);break}a.anchor.set(s.componentParams.anchorX,s.componentParams.anchorY),c.component=a,this.core.emit(c),c.init(this,s,this._scaleMod),this._particles.add(c),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=G.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 a,o;switch(c.type){case 0:a=this.settings.__isClone?i.createParticleEmitterFrom(c.settings):i.getParticleEmitterById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,!0,(c.scale||1)*this._scaleMod),c.adoptRotation?(a.rotation=t.component.rotation+a.settings.rotation,a.__adoptRotation=!0):a.rotation=a.settings.rotation;break;case 1:a=this.settings.__isClone?i.createEffectSequenceEmitterFrom(c.settings):i.getEffectSequenceById(c.id),o=i.__containers[a.settings.containerId]||this.container,a.init(o,0,!0,(c.scale||1)*this._scaleMod),c.adoptRotation&&(a.rotation=t.component.rotation);break}a.x=t.component.x,a.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 a=i[c];for(const o of a){switch(o.type){case Pt.ParticleEmitter:o.settings=Nt(e.__getEmitterSettings(o.id));break;case Pt.EffectSequence:o.settings=Nt(e.__getSequenceSettings(o.id));break}o.settings.__isClone=!0}}const s=t.childs;for(const c of s){switch(c.type){case Pt.ParticleEmitter:c.settings=Nt(e.__getEmitterSettings(c.id));break;case Pt.EffectSequence:c.settings=Nt(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 Te extends ve{constructor(t){super(t),this._list=[],this._elements=new zt,this.__on={started:new ut,completed:new ut,exhausted:new ut,effectSpawned:new ut,triggerActivated:new ut}}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,a=this._nextEffectSettings;let o,y,S;switch(a.componentType){case Et.Sprite:o=c.__getSprite(a.componentId),S=c.__containers[a.containerId]||this.container,S.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=G.float(a.alphaMin,a.alphaMax),o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),y=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+G.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.Sprite,o);break;case Et.MovieClip:o=c.__getMovieClip(a.componentId),a.componentParams.loop?(o.animationSpeed=G.float(a.componentParams.animationSpeedMin||1,a.componentParams.animationSpeedMax||1),o.loop=a.componentParams.loop||!1):a.duration,o.anchor.set(a.componentParams.anchorX,a.componentParams.anchorY),o.gotoAndPlay(0),S=c.__containers[a.containerId]||this.container,S.addChild(o),o.blendMode=c.__getBlendMode(a.blendMode),o.tint=a.tint,o.scale.set(G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),o.alpha=G.float(a.alphaMin,a.alphaMax),y=new Dt({component:o,endTime:e+a.duration*1e3}),this._elements.add(y),o.x=this._x,o.y=this._y,o.rotation=this._rotation+G.float(a.rotationMin,a.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(Et.MovieClip,o);break;case Et.Emitter:o=c.getParticleEmitterById(a.componentId),S=c.__containers[a.containerId]||this.container,o.init(S,!0,G.float(a.scaleMin,a.scaleMax)*G.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),y=new Dt({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(Et.Emitter,o);break;case Et.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(a.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 te?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 oi(h){const{emit:t,settings:e={}}=h,{name:i}=D.useProps(h),s=new pt;let c;return dt.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),dt.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:a})=>{s.update(a)}),D.mount(async a=>{c=a;let y={...(await dt.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const x=e.emitters.map((C,T)=>({...C,id:1e4+T}));y.emitters=[...y.emitters,...x]}s.initBundle(y,!0)}),D.on(t,()=>{s.getParticleEmitter(i()).init(c.componentInstance)}),D.h(D.Container)}function li(h){const{radius:t}=D.useProps(h),e=D.animatedSignal(1),i=1,s=2,c=.001,a=()=>{const y=Date.now()*c,S=(Math.sin(y)+Math.sin(y*1.3)+Math.sin(y*.7))/3,x=i+(s-i)*(S*.5+.5);e.update(()=>x),requestAnimationFrame(a)};a();const o=y=>{const S=t()*2,x=new D.RadialGradient(S,S,0,S,S,0);x.addColorStop(0,"rgba(255, 255, 0, 1)"),x.addColorStop(.5,"rgba(255, 255, 0, 0.3)"),x.addColorStop(.8,"rgba(255, 255, 0, 0)");const C=S/2;y.rect(-C,-C,S,S).fill(x.render({translate:{x:C,y:C}}))};return D.h(D.Graphics,{draw:o,...h,scale:e})}function ci(h){const{children:t}=h,e=D.signal(0),i=D.signal(0);let s;const c=a=>{a.rect(-80,-80,e()+80*2,i()+80*2),a.fill(0);const y=S=>{const x=D.isSignal(S.propObservables.x)?S.propObservables.x():S.props.x,C=D.isSignal(S.propObservables.y)?S.propObservables.y():S.props.y,T=D.isSignal(S.propObservables.radius)?S.propObservables.radius():S.props.radius;a.circle(x,C,T),a.cut()};for(let S of t){if(D.isObservable(S)){s&&s.unsubscribe(),s=S.subscribe(x=>{for(let C of x.fullElements)y(C)});return}y(S)}};return D.mount(a=>{a.componentInstance.on("layout",o=>{e.update(()=>a.componentInstance.getWidth()),i.update(()=>a.componentInstance.getHeight())})}),D.h(D.Container,{width:"100%",height:"100%",...h},D.h(D.Graphics,{draw:c,alpha:.8,blur:80}),...t)}function ui(h={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:s=180,segments:c=8,segmentWidth:a=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:F})=>{const O=(typeof s=="function"?s():s)*F/1e3;y.set(y()+O)});const S=F=>{const N=typeof t=="function"?t():t,O=typeof e=="function"?e():e,_=i?typeof i=="function"?i():i:null,v=typeof c=="function"?c():c;typeof a=="function"&&a();const m=typeof o=="function"?o():o,d=y();_&&F.circle(0,0,N).fill(_);const b=360/v,R=N*.4,U=N;for(let k=0;k<v;k++){const g=k*b,V=(d%360+360)%360;let rt=Math.abs(V-g);rt>180&&(rt=360-rt);let W=rt/120;W=Math.min(1,W),W=W*W*W;const lt=m+(1-W)*(1-m),ot=g*(Math.PI/180),ht=b*(Math.PI/180),L=ot-ht/2,st=ot+ht/2;F.arc(0,0,R,L,st).arc(0,0,U,st,L,!0).fill({color:O,alpha:lt})}},C=(typeof t=="function"?t():t)*2,T=D.signal(C),M=D.signal(C);return typeof t=="function"&&D.effect(()=>{const F=t();T.set(F*2),M.set(F*2)}),D.h(D.Container,h,[D.h(D.Graphics,{draw:S})])}var Rt=(h=>(h.Tile="tilelayer",h.ObjectGroup="objectgroup",h.Image="imagelayer",h.Group="group",h))(Rt||{});function Se(...h){return h.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function hi(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 ee={};const fi=hi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ie={},jt={exports:{}},re={},kt={},Ce;function di(){if(Ce)return kt;Ce=1,kt.byteLength=o,kt.toByteArray=S,kt.fromByteArray=T;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 a(M){var F=M.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var N=M.indexOf("=");N===-1&&(N=F);var O=N===F?0:4-N%4;return[N,O]}function o(M){var F=a(M),N=F[0],O=F[1];return(N+O)*3/4-O}function y(M,F,N){return(F+N)*3/4-N}function S(M){var F,N=a(M),O=N[0],_=N[1],v=new e(y(M,O,_)),m=0,d=_>0?O-4:O,b;for(b=0;b<d;b+=4)F=t[M.charCodeAt(b)]<<18|t[M.charCodeAt(b+1)]<<12|t[M.charCodeAt(b+2)]<<6|t[M.charCodeAt(b+3)],v[m++]=F>>16&255,v[m++]=F>>8&255,v[m++]=F&255;return _===2&&(F=t[M.charCodeAt(b)]<<2|t[M.charCodeAt(b+1)]>>4,v[m++]=F&255),_===1&&(F=t[M.charCodeAt(b)]<<10|t[M.charCodeAt(b+1)]<<4|t[M.charCodeAt(b+2)]>>2,v[m++]=F>>8&255,v[m++]=F&255),v}function x(M){return h[M>>18&63]+h[M>>12&63]+h[M>>6&63]+h[M&63]}function C(M,F,N){for(var O,_=[],v=F;v<N;v+=3)O=(M[v]<<16&16711680)+(M[v+1]<<8&65280)+(M[v+2]&255),_.push(x(O));return _.join("")}function T(M){for(var F,N=M.length,O=N%3,_=[],v=16383,m=0,d=N-O;m<d;m+=v)_.push(C(M,m,m+v>d?d:m+v));return O===1?(F=M[N-1],_.push(h[F>>2]+h[F<<4&63]+"==")):O===2&&(F=(M[N-2]<<8)+M[N-1],_.push(h[F>>10]+h[F>>4&63]+h[F<<2&63]+"=")),_.join("")}return kt}var Wt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Ie;function pi(){return Ie||(Ie=1,Wt.read=function(h,t,e,i,s){var c,a,o=s*8-i-1,y=(1<<o)-1,S=y>>1,x=-7,C=e?s-1:0,T=e?-1:1,M=h[t+C];for(C+=T,c=M&(1<<-x)-1,M>>=-x,x+=o;x>0;c=c*256+h[t+C],C+=T,x-=8);for(a=c&(1<<-x)-1,c>>=-x,x+=i;x>0;a=a*256+h[t+C],C+=T,x-=8);if(c===0)c=1-S;else{if(c===y)return a?NaN:(M?-1:1)*(1/0);a=a+Math.pow(2,i),c=c-S}return(M?-1:1)*a*Math.pow(2,c-i)},Wt.write=function(h,t,e,i,s,c){var a,o,y,S=c*8-s-1,x=(1<<S)-1,C=x>>1,T=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=i?0:c-1,F=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,a=x):(a=Math.floor(Math.log(t)/Math.LN2),t*(y=Math.pow(2,-a))<1&&(a--,y*=2),a+C>=1?t+=T/y:t+=T*Math.pow(2,1-C),t*y>=2&&(a++,y/=2),a+C>=x?(o=0,a=x):a+C>=1?(o=(t*y-1)*Math.pow(2,s),a=a+C):(o=t*Math.pow(2,C-1)*Math.pow(2,s),a=0));s>=8;h[e+M]=o&255,M+=F,o/=256,s-=8);for(a=a<<s|o,S+=s;S>0;h[e+M]=a&255,M+=F,a/=256,S-=8);h[e+M-F]|=N*128}),Wt}/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/var Be;function Me(){return Be||(Be=1,function(h){const t=di(),e=pi(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=o,h.SlowBuffer=v,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 a(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 C(u)}return y(u,r,n)}o.poolSize=8192;function y(u,r,n){if(typeof u=="string")return T(u,r);if(ArrayBuffer.isView(u))return F(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(mt(u,ArrayBuffer)||u&&mt(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(mt(u,SharedArrayBuffer)||u&&mt(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 E=O(u);if(E)return E;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 S(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 x(u,r,n){return S(u),u<=0?a(u):r!==void 0?typeof n=="string"?a(u).fill(r,n):a(u).fill(r):a(u)}o.alloc=function(u,r,n){return x(u,r,n)};function C(u){return S(u),a(u<0?0:_(u)|0)}o.allocUnsafe=function(u){return C(u)},o.allocUnsafeSlow=function(u){return C(u)};function T(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=a(n);const E=p.write(u,r);return E!==n&&(p=p.slice(0,E)),p}function M(u){const r=u.length<0?0:_(u.length)|0,n=a(r);for(let p=0;p<r;p+=1)n[p]=u[p]&255;return n}function F(u){if(mt(u,Uint8Array)){const r=new Uint8Array(u);return N(r.buffer,r.byteOffset,r.byteLength)}return M(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=a(r);return n.length===0||u.copy(n,0,0,r),n}if(u.length!==void 0)return typeof u.length!="number"||we(u.length)?a(0):M(u);if(u.type==="Buffer"&&Array.isArray(u.data))return M(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 v(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(mt(r,Uint8Array)&&(r=o.from(r,r.offset,r.byteLength)),mt(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,E=n.length;for(let A=0,I=Math.min(p,E);A<I;++A)if(r[A]!==n[A]){p=r[A],E=n[A];break}return p<E?-1:E<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 E=o.allocUnsafe(n);let A=0;for(p=0;p<r.length;++p){let I=r[p];if(mt(I,Uint8Array))A+I.length>E.length?(o.isBuffer(I)||(I=o.from(I)),I.copy(E,A)):Uint8Array.prototype.set.call(E,I,A);else if(o.isBuffer(I))I.copy(E,A);else throw new TypeError('"list" argument must be an Array of Buffers');A+=I.length}return E};function m(u,r){if(o.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||mt(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 E=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return it(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return qt(u).length;default:if(E)return p?-1:it(u).length;r=(""+r).toLowerCase(),E=!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 $(this,r,n);case"utf8":case"utf-8":return lt(this,r,n);case"ascii":return L(this,r,n);case"latin1":case"binary":return st(this,r,n);case"base64":return W(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return et(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?lt(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,E,A){if(mt(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),E===void 0&&(E=0),A===void 0&&(A=this.length),n<0||p>r.length||E<0||A>this.length)throw new RangeError("out of range index");if(E>=A&&n>=p)return 0;if(E>=A)return-1;if(n>=p)return 1;if(n>>>=0,p>>>=0,E>>>=0,A>>>=0,this===r)return 0;let I=A-E,q=p-n;const Z=Math.min(I,q),Q=this.slice(E,A),tt=r.slice(n,p);for(let j=0;j<Z;++j)if(Q[j]!==tt[j]){I=Q[j],q=tt[j];break}return I<q?-1:q<I?1:0};function R(u,r,n,p,E){if(u.length===0)return-1;if(typeof n=="string"?(p=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=E?0:u.length-1),n<0&&(n=u.length+n),n>=u.length){if(E)return-1;n=u.length-1}else if(n<0)if(E)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,E);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?E?Uint8Array.prototype.indexOf.call(u,r,n):Uint8Array.prototype.lastIndexOf.call(u,r,n):U(u,[r],n,p,E);throw new TypeError("val must be string, number or Buffer")}function U(u,r,n,p,E){let A=1,I=u.length,q=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;A=2,I/=2,q/=2,n/=2}function Z(tt,j){return A===1?tt[j]:tt.readUInt16BE(j*A)}let Q;if(E){let tt=-1;for(Q=n;Q<I;Q++)if(Z(u,Q)===Z(r,tt===-1?0:Q-tt)){if(tt===-1&&(tt=Q),Q-tt+1===q)return tt*A}else tt!==-1&&(Q-=Q-tt),tt=-1}else for(n+q>I&&(n=I-q),Q=n;Q>=0;Q--){let tt=!0;for(let j=0;j<q;j++)if(Z(u,Q+j)!==Z(r,j)){tt=!1;break}if(tt)return Q}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 E=u.length-n;p?(p=Number(p),p>E&&(p=E)):p=E;const A=r.length;p>A/2&&(p=A/2);let I;for(I=0;I<p;++I){const q=parseInt(r.substr(I*2,2),16);if(we(q))return I;u[n+I]=q}return I}function g(u,r,n,p){return Mt(it(r,u.length-n),u,n,p)}function V(u,r,n,p){return Mt(yt(r),u,n,p)}function rt(u,r,n,p){return Mt(qt(r),u,n,p)}function K(u,r,n,p){return Mt(Ee(r,u.length-n),u,n,p)}o.prototype.write=function(r,n,p,E){if(n===void 0)E="utf8",p=this.length,n=0;else if(p===void 0&&typeof n=="string")E=n,p=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(p)?(p=p>>>0,E===void 0&&(E="utf8")):(E=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const A=this.length-n;if((p===void 0||p>A)&&(p=A),r.length>0&&(p<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");E||(E="utf8");let I=!1;for(;;)switch(E){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 rt(this,r,n,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,r,n,p);default:if(I)throw new TypeError("Unknown encoding: "+E);E=(""+E).toLowerCase(),I=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(u,r,n){return r===0&&n===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(r,n))}function lt(u,r,n){n=Math.min(u.length,n);const p=[];let E=r;for(;E<n;){const A=u[E];let I=null,q=A>239?4:A>223?3:A>191?2:1;if(E+q<=n){let Z,Q,tt,j;switch(q){case 1:A<128&&(I=A);break;case 2:Z=u[E+1],(Z&192)===128&&(j=(A&31)<<6|Z&63,j>127&&(I=j));break;case 3:Z=u[E+1],Q=u[E+2],(Z&192)===128&&(Q&192)===128&&(j=(A&15)<<12|(Z&63)<<6|Q&63,j>2047&&(j<55296||j>57343)&&(I=j));break;case 4:Z=u[E+1],Q=u[E+2],tt=u[E+3],(Z&192)===128&&(Q&192)===128&&(tt&192)===128&&(j=(A&15)<<18|(Z&63)<<12|(Q&63)<<6|tt&63,j>65535&&j<1114112&&(I=j))}}I===null?(I=65533,q=1):I>65535&&(I-=65536,p.push(I>>>10&1023|55296),I=56320|I&1023),p.push(I),E+=q}return ht(p)}const ot=4096;function ht(u){const r=u.length;if(r<=ot)return String.fromCharCode.apply(String,u);let n="",p=0;for(;p<r;)n+=String.fromCharCode.apply(String,u.slice(p,p+=ot));return n}function L(u,r,n){let p="";n=Math.min(u.length,n);for(let E=r;E<n;++E)p+=String.fromCharCode(u[E]&127);return p}function st(u,r,n){let p="";n=Math.min(u.length,n);for(let E=r;E<n;++E)p+=String.fromCharCode(u[E]);return p}function $(u,r,n){const p=u.length;(!r||r<0)&&(r=0),(!n||n<0||n>p)&&(n=p);let E="";for(let A=r;A<n;++A)E+=rr[u[A]];return E}function et(u,r,n){const p=u.slice(r,n);let E="";for(let A=0;A<p.length-1;A+=2)E+=String.fromCharCode(p[A]+p[A+1]*256);return E}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 E=this.subarray(r,n);return Object.setPrototypeOf(E,o.prototype),E};function Y(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||Y(r,n,this.length);let E=this[r],A=1,I=0;for(;++I<n&&(A*=256);)E+=this[r+I]*A;return E},o.prototype.readUintBE=o.prototype.readUIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=this[r+--n],A=1;for(;n>0&&(A*=256);)E+=this[r+--n]*A;return E},o.prototype.readUint8=o.prototype.readUInt8=function(r,n){return r=r>>>0,n||Y(r,1,this.length),this[r]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(r,n){return r=r>>>0,n||Y(r,2,this.length),this[r]|this[r+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(r,n){return r=r>>>0,n||Y(r,2,this.length),this[r]<<8|this[r+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(r,n){return r=r>>>0,n||Y(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||Y(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},o.prototype.readBigUInt64LE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const E=n+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,A=this[++r]+this[++r]*2**8+this[++r]*2**16+p*2**24;return BigInt(E)+(BigInt(A)<<BigInt(32))}),o.prototype.readBigUInt64BE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const E=n*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],A=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+p;return(BigInt(E)<<BigInt(32))+BigInt(A)}),o.prototype.readIntLE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=this[r],A=1,I=0;for(;++I<n&&(A*=256);)E+=this[r+I]*A;return A*=128,E>=A&&(E-=Math.pow(2,8*n)),E},o.prototype.readIntBE=function(r,n,p){r=r>>>0,n=n>>>0,p||Y(r,n,this.length);let E=n,A=1,I=this[r+--E];for(;E>0&&(A*=256);)I+=this[r+--E]*A;return A*=128,I>=A&&(I-=Math.pow(2,8*n)),I},o.prototype.readInt8=function(r,n){return r=r>>>0,n||Y(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},o.prototype.readInt16LE=function(r,n){r=r>>>0,n||Y(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||Y(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||Y(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||Y(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},o.prototype.readBigInt64LE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const E=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(p<<24);return(BigInt(E)<<BigInt(32))+BigInt(n+this[++r]*256+this[++r]*65536+this[++r]*16777216)}),o.prototype.readBigInt64BE=Ft(function(r){r=r>>>0,X(r,"offset");const n=this[r],p=this[r+7];(n===void 0||p===void 0)&&nt(r,this.length-8);const E=(n<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(E)<<BigInt(32))+BigInt(this[++r]*16777216+this[++r]*65536+this[++r]*256+p)}),o.prototype.readFloatLE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),e.read(this,r,!0,23,4)},o.prototype.readFloatBE=function(r,n){return r=r>>>0,n||Y(r,4,this.length),e.read(this,r,!1,23,4)},o.prototype.readDoubleLE=function(r,n){return r=r>>>0,n||Y(r,8,this.length),e.read(this,r,!0,52,8)},o.prototype.readDoubleBE=function(r,n){return r=r>>>0,n||Y(r,8,this.length),e.read(this,r,!1,52,8)};function H(u,r,n,p,E,A){if(!o.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>E||r<A)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,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const q=Math.pow(2,8*p)-1;H(this,r,n,p,q,0)}let A=1,I=0;for(this[n]=r&255;++I<p&&(A*=256);)this[n+I]=r/A&255;return n+p},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,p=p>>>0,!E){const q=Math.pow(2,8*p)-1;H(this,r,n,p,q,0)}let A=p-1,I=1;for(this[n+A]=r&255;--A>=0&&(I*=256);)this[n+A]=r/I&255;return n+p},o.prototype.writeUint8=o.prototype.writeUInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(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||H(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||H(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||H(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||H(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(u,r,n,p,E){J(r,p,E,u,n,7);let A=Number(r&BigInt(4294967295));u[n++]=A,A=A>>8,u[n++]=A,A=A>>8,u[n++]=A,A=A>>8,u[n++]=A;let I=Number(r>>BigInt(32)&BigInt(4294967295));return u[n++]=I,I=I>>8,u[n++]=I,I=I>>8,u[n++]=I,I=I>>8,u[n++]=I,n}function bt(u,r,n,p,E){J(r,p,E,u,n,7);let A=Number(r&BigInt(4294967295));u[n+7]=A,A=A>>8,u[n+6]=A,A=A>>8,u[n+5]=A,A=A>>8,u[n+4]=A;let I=Number(r>>BigInt(32)&BigInt(4294967295));return u[n+3]=I,I=I>>8,u[n+2]=I,I=I>>8,u[n+1]=I,I=I>>8,u[n]=I,n+8}o.prototype.writeBigUInt64LE=Ft(function(r,n=0){return Tt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Ft(function(r,n=0){return bt(this,r,n,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const Z=Math.pow(2,8*p-1);H(this,r,n,p,Z-1,-Z)}let A=0,I=1,q=0;for(this[n]=r&255;++A<p&&(I*=256);)r<0&&q===0&&this[n+A-1]!==0&&(q=1),this[n+A]=(r/I>>0)-q&255;return n+p},o.prototype.writeIntBE=function(r,n,p,E){if(r=+r,n=n>>>0,!E){const Z=Math.pow(2,8*p-1);H(this,r,n,p,Z-1,-Z)}let A=p-1,I=1,q=0;for(this[n+A]=r&255;--A>=0&&(I*=256);)r<0&&q===0&&this[n+A+1]!==0&&(q=1),this[n+A]=(r/I>>0)-q&255;return n+p},o.prototype.writeInt8=function(r,n,p){return r=+r,n=n>>>0,p||H(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||H(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||H(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||H(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||H(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=Ft(function(r,n=0){return Tt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Ft(function(r,n=0){return bt(this,r,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Vt(u,r,n,p,E,A){if(n+p>u.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ht(u,r,n,p,E){return r=+r,n=n>>>0,E||Vt(u,r,n,4),e.write(u,r,n,p,23,4),n+4}o.prototype.writeFloatLE=function(r,n,p){return Ht(this,r,n,!0,p)},o.prototype.writeFloatBE=function(r,n,p){return Ht(this,r,n,!1,p)};function f(u,r,n,p,E){return r=+r,n=n>>>0,E||Vt(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,E){if(!o.isBuffer(r))throw new TypeError("argument should be a Buffer");if(p||(p=0),!E&&E!==0&&(E=this.length),n>=r.length&&(n=r.length),n||(n=0),E>0&&E<p&&(E=p),E===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(E<0)throw new RangeError("sourceEnd out of bounds");E>this.length&&(E=this.length),r.length-n<E-p&&(E=r.length-n+p);const A=E-p;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,p,E):Uint8Array.prototype.set.call(r,this.subarray(p,E),n),A},o.prototype.fill=function(r,n,p,E){if(typeof r=="string"){if(typeof n=="string"?(E=n,n=0,p=this.length):typeof p=="string"&&(E=p,p=this.length),E!==void 0&&typeof E!="string")throw new TypeError("encoding must be a string");if(typeof E=="string"&&!o.isEncoding(E))throw new TypeError("Unknown encoding: "+E);if(r.length===1){const I=r.charCodeAt(0);(E==="utf8"&&I<128||E==="latin1")&&(r=I)}}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 A;if(typeof r=="number")for(A=n;A<p;++A)this[A]=r;else{const I=o.isBuffer(r)?r:o.from(r,E),q=I.length;if(q===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(A=0;A<p-n;++A)this[A+n]=I[A%q]}return this};const l={};function B(u,r,n){l[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(E){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:E,writable:!0})}toString(){return`${this.name} [${u}]: ${this.message}`}}}B("ERR_BUFFER_OUT_OF_BOUNDS",function(u){return u?`${u} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),B("ERR_INVALID_ARG_TYPE",function(u,r){return`The "${u}" argument must be of type number. Received type ${typeof r}`},TypeError),B("ERR_OUT_OF_RANGE",function(u,r,n){let p=`The value of "${u}" is out of range.`,E=n;return Number.isInteger(n)&&Math.abs(n)>4294967296?E=w(String(n)):typeof n=="bigint"&&(E=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(E=w(E)),E+="n"),p+=` It must be ${r}. Received ${E}`,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 z(u,r,n){X(r,"offset"),(u[r]===void 0||u[r+n]===void 0)&&nt(r,u.length-(n+1))}function J(u,r,n,p,E,A){if(u>n||u<r){const I=typeof r=="bigint"?"n":"";let q;throw r===0||r===BigInt(0)?q=`>= 0${I} and < 2${I} ** ${(A+1)*8}${I}`:q=`>= -(2${I} ** ${(A+1)*8-1}${I}) and < 2 ** ${(A+1)*8-1}${I}`,new l.ERR_OUT_OF_RANGE("value",q,u)}z(p,E,A)}function X(u,r){if(typeof u!="number")throw new l.ERR_INVALID_ARG_TYPE(r,"number",u)}function nt(u,r,n){throw Math.floor(u)!==u?(X(u,n),new l.ERR_OUT_OF_RANGE("offset","an integer",u)):r<0?new l.ERR_BUFFER_OUT_OF_BOUNDS:new l.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,u)}const ct=/[^+/0-9A-Za-z-_]/g;function Bt(u){if(u=u.split("=")[0],u=u.trim().replace(ct,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function it(u,r){r=r||1/0;let n;const p=u.length;let E=null;const A=[];for(let I=0;I<p;++I){if(n=u.charCodeAt(I),n>55295&&n<57344){if(!E){if(n>56319){(r-=3)>-1&&A.push(239,191,189);continue}else if(I+1===p){(r-=3)>-1&&A.push(239,191,189);continue}E=n;continue}if(n<56320){(r-=3)>-1&&A.push(239,191,189),E=n;continue}n=(E-55296<<10|n-56320)+65536}else E&&(r-=3)>-1&&A.push(239,191,189);if(E=null,n<128){if((r-=1)<0)break;A.push(n)}else if(n<2048){if((r-=2)<0)break;A.push(n>>6|192,n&63|128)}else if(n<65536){if((r-=3)<0)break;A.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((r-=4)<0)break;A.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return A}function yt(u){const r=[];for(let n=0;n<u.length;++n)r.push(u.charCodeAt(n)&255);return r}function Ee(u,r){let n,p,E;const A=[];for(let I=0;I<u.length&&!((r-=2)<0);++I)n=u.charCodeAt(I),p=n>>8,E=n%256,A.push(E),A.push(p);return A}function qt(u){return t.toByteArray(Bt(u))}function Mt(u,r,n,p){let E;for(E=0;E<p&&!(E+n>=r.length||E>=u.length);++E)r[E+n]=u[E];return E}function mt(u,r){return u instanceof r||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===r.name}function we(u){return u!==u}const rr=function(){const u="0123456789abcdef",r=new Array(256);for(let n=0;n<16;++n){const p=n*16;for(let E=0;E<16;++E)r[p+E]=u[n]+u[E]}return r}();function Ft(u){return typeof BigInt>"u"?sr:u}function sr(){throw new Error("BigInt not supported")}}(re)),re}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Fe;function mi(){return Fe||(Fe=1,function(h,t){var e=Me(),i=e.Buffer;function s(a,o){for(var y in a)o[y]=a[y]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?h.exports=e:(s(e,t),t.Buffer=c);function c(a,o,y){return i(a,o,y)}c.prototype=Object.create(i.prototype),s(i,c),c.from=function(a,o,y){if(typeof a=="number")throw new TypeError("Argument must not be a number");return i(a,o,y)},c.alloc=function(a,o,y){if(typeof a!="number")throw new TypeError("Argument must be a number");var S=i(a);return o!==void 0?typeof y=="string"?S.fill(o,y):S.fill(o):S.fill(0),S},c.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return i(a)},c.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(a)}}(jt,jt.exports)),jt.exports}var De;function _i(){if(De)return ie;De=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 v;;)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(v)return;_=(""+_).toLowerCase(),v=!0}}function i(_){var v=e(_);if(typeof v!="string"&&(h.isEncoding===t||!t(_)))throw new Error("Unknown encoding: "+_);return v||_}ie.StringDecoder=s;function s(_){this.encoding=i(_);var v;switch(this.encoding){case"utf16le":this.text=C,this.end=T,v=4;break;case"utf8":this.fillLast=y,v=4;break;case"base64":this.text=M,this.end=F,v=3;break;default:this.write=N,this.end=O;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=h.allocUnsafe(v)}s.prototype.write=function(_){if(_.length===0)return"";var v,m;if(this.lastNeed){if(v=this.fillLast(_),v===void 0)return"";m=this.lastNeed,this.lastNeed=0}else m=0;return m<_.length?v?v+this.text(_,m):this.text(_,m):v||""},s.prototype.end=x,s.prototype.text=S,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 a(_,v,m){var d=v.length-1;if(d<m)return 0;var b=c(v[d]);return b>=0?(b>0&&(_.lastNeed=b-1),b):--d<m||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(_.lastNeed=b-2),b):--d<m||b===-2?0:(b=c(v[d]),b>=0?(b>0&&(b===2?b=0:_.lastNeed=b-3),b):0))}function o(_,v,m){if((v[0]&192)!==128)return _.lastNeed=0,"�";if(_.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return _.lastNeed=1,"�";if(_.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return _.lastNeed=2,"�"}}function y(_){var v=this.lastTotal-this.lastNeed,m=o(this,_);if(m!==void 0)return m;if(this.lastNeed<=_.length)return _.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);_.copy(this.lastChar,v,0,_.length),this.lastNeed-=_.length}function S(_,v){var m=a(this,_,v);if(!this.lastNeed)return _.toString("utf8",v);this.lastTotal=m;var d=_.length-(m-this.lastNeed);return _.copy(this.lastChar,0,d),_.toString("utf8",v,d)}function x(_){var v=_&&_.length?this.write(_):"";return this.lastNeed?v+"�":v}function C(_,v){if((_.length-v)%2===0){var m=_.toString("utf16le",v);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",v,_.length-1)}function T(_){var v=_&&_.length?this.write(_):"";if(this.lastNeed){var m=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,m)}return v}function M(_,v){var m=(_.length-v)%3;return m===0?_.toString("base64",v):(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",v,_.length-m))}function F(_){var v=_&&_.length?this.write(_):"";return this.lastNeed?v+this.lastChar.toString("base64",0,3-this.lastNeed):v}function N(_){return _.toString(this.encoding)}function O(_){return _&&_.length?this.write(_):""}return ie}var Ne;function gi(){return Ne||(Ne=1,function(h){(function(t){t.parser=function(f,l){return new i(f,l)},t.SAXParser=i,t.SAXStream=x,t.createStream=S,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,l){if(!(this instanceof i))return new i(f,l);var B=this;c(B),B.q=B.c="",B.bufferCheckPosition=t.MAX_BUFFER_LENGTH,B.opt=l||{},B.opt.lowercase=B.opt.lowercase||B.opt.lowercasetags,B.looseCase=B.opt.lowercase?"toLowerCase":"toUpperCase",B.tags=[],B.closed=B.closedRoot=B.sawRoot=!1,B.tag=B.error=null,B.strict=!!f,B.noscript=!!(f||B.opt.noscript),B.state=g.BEGIN,B.strictEntities=B.opt.strictEntities,B.ENTITIES=B.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),B.attribList=[],B.opt.xmlns&&(B.ns=Object.create(N)),B.opt.unquotedAttributeValues===void 0&&(B.opt.unquotedAttributeValues=!f),B.trackPosition=B.opt.position!==!1,B.trackPosition&&(B.position=B.line=B.column=0),rt(B,"onready")}Object.create||(Object.create=function(f){function l(){}l.prototype=f;var B=new l;return B}),Object.keys||(Object.keys=function(f){var l=[];for(var B in f)f.hasOwnProperty(B)&&l.push(B);return l});function s(f){for(var l=Math.max(t.MAX_BUFFER_LENGTH,10),B=0,w=0,z=e.length;w<z;w++){var J=f[e[w]].length;if(J>l)switch(e[w]){case"textNode":W(f);break;case"cdata":K(f,"oncdata",f.cdata),f.cdata="";break;case"script":K(f,"onscript",f.script),f.script="";break;default:ot(f,"Max buffer length exceeded: "+e[w])}B=Math.max(B,J)}var X=t.MAX_BUFFER_LENGTH-B;f.bufferCheckPosition=X+f.position}function c(f){for(var l=0,B=e.length;l<B;l++)f[e[l]]=""}function a(f){W(f),f.cdata!==""&&(K(f,"oncdata",f.cdata),f.cdata=""),f.script!==""&&(K(f,"onscript",f.script),f.script="")}i.prototype={end:function(){ht(this)},write:Ht,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=fi.Stream}catch{o=function(){}}o||(o=function(){});var y=t.EVENTS.filter(function(f){return f!=="error"&&f!=="end"});function S(f,l){return new x(f,l)}function x(f,l){if(!(this instanceof x))return new x(f,l);o.apply(this),this._parser=new i(f,l),this.writable=!0,this.readable=!0;var B=this;this._parser.onend=function(){B.emit("end")},this._parser.onerror=function(w){B.emit("error",w),B._parser.error=null},this._decoder=null,y.forEach(function(w){Object.defineProperty(B,"on"+w,{get:function(){return B._parser["on"+w]},set:function(z){if(!z)return B.removeAllListeners(w),B._parser["on"+w]=z,z;B.on(w,z)},enumerable:!0,configurable:!1})})}x.prototype=Object.create(o.prototype,{constructor:{value:x}}),x.prototype.write=function(f){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(f)){if(!this._decoder){var l=_i().StringDecoder;this._decoder=new l("utf8")}f=this._decoder.write(f)}return this._parser.write(f.toString()),this.emit("data",f),!0},x.prototype.end=function(f){return f&&f.length&&this.write(f),this._parser.end(),!0},x.prototype.on=function(f,l){var B=this;return!B._parser["on"+f]&&y.indexOf(f)!==-1&&(B._parser["on"+f]=function(){var w=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);w.splice(0,0,f),B.emit.apply(B,w)}),o.prototype.on.call(B,f,l)};var C="[CDATA[",T="DOCTYPE",M="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",N={xml:M,xmlns:F},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-]/,v=/[#:_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===`
|
|
7
|
+
`||f==="\r"||f===" "}function b(f){return f==='"'||f==="'"}function R(f){return f===">"||d(f)}function U(f,l){return f.test(l)}function k(f,l){return!U(f,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(f){var l=t.ENTITIES[f],B=typeof l=="number"?String.fromCharCode(l):l;t.ENTITIES[f]=B});for(var V in t.STATE)t.STATE[t.STATE[V]]=V;g=t.STATE;function rt(f,l,B){f[l]&&f[l](B)}function K(f,l,B){f.textNode&&W(f),rt(f,l,B)}function W(f){f.textNode=lt(f.opt,f.textNode),f.textNode&&rt(f,"ontext",f.textNode),f.textNode=""}function lt(f,l){return f.trim&&(l=l.trim()),f.normalize&&(l=l.replace(/\s+/g," ")),l}function ot(f,l){return W(f),f.trackPosition&&(l+=`
|
|
8
|
+
Line: `+f.line+`
|
|
9
|
+
Column: `+f.column+`
|
|
10
|
+
Char: `+f.c),l=new Error(l),f.error=l,rt(f,"onerror",l),f}function ht(f){return f.sawRoot&&!f.closedRoot&&L(f,"Unclosed root tag"),f.state!==g.BEGIN&&f.state!==g.BEGIN_WHITESPACE&&f.state!==g.TEXT&&ot(f,"Unexpected end"),W(f),f.c="",f.closed=!0,rt(f,"onend"),i.call(f,f.strict,f.opt),f}function L(f,l){if(typeof f!="object"||!(f instanceof i))throw new Error("bad call to strictFail");f.strict&&ot(f,l)}function st(f){f.strict||(f.tagName=f.tagName[f.looseCase]());var l=f.tags[f.tags.length-1]||f,B=f.tag={name:f.tagName,attributes:{}};f.opt.xmlns&&(B.ns=l.ns),f.attribList.length=0,K(f,"onopentagstart",B)}function $(f,l){var B=f.indexOf(":"),w=B<0?["",f]:f.split(":"),z=w[0],J=w[1];return l&&f==="xmlns"&&(z="xmlns",J=""),{prefix:z,local:J}}function et(f){if(f.strict||(f.attribName=f.attribName[f.looseCase]()),f.attribList.indexOf(f.attribName)!==-1||f.tag.attributes.hasOwnProperty(f.attribName)){f.attribName=f.attribValue="";return}if(f.opt.xmlns){var l=$(f.attribName,!0),B=l.prefix,w=l.local;if(B==="xmlns")if(w==="xml"&&f.attribValue!==M)L(f,"xml: prefix must be bound to "+M+`
|
|
11
|
+
Actual: `+f.attribValue);else if(w==="xmlns"&&f.attribValue!==F)L(f,"xmlns: prefix must be bound to "+F+`
|
|
12
|
+
Actual: `+f.attribValue);else{var z=f.tag,J=f.tags[f.tags.length-1]||f;z.ns===J.ns&&(z.ns=Object.create(J.ns)),z.ns[w]=f.attribValue}f.attribList.push([f.attribName,f.attribValue])}else f.tag.attributes[f.attribName]=f.attribValue,K(f,"onattribute",{name:f.attribName,value:f.attribValue});f.attribName=f.attribValue=""}function Y(f,l){if(f.opt.xmlns){var B=f.tag,w=$(f.tagName);B.prefix=w.prefix,B.local=w.local,B.uri=B.ns[w.prefix]||"",B.prefix&&!B.uri&&(L(f,"Unbound namespace prefix: "+JSON.stringify(f.tagName)),B.uri=w.prefix);var z=f.tags[f.tags.length-1]||f;B.ns&&z.ns!==B.ns&&Object.keys(B.ns).forEach(function(mt){K(f,"onopennamespace",{prefix:mt,uri:B.ns[mt]})});for(var J=0,X=f.attribList.length;J<X;J++){var nt=f.attribList[J],ct=nt[0],Bt=nt[1],it=$(ct,!0),yt=it.prefix,Ee=it.local,qt=yt===""?"":B.ns[yt]||"",Mt={name:ct,value:Bt,prefix:yt,local:Ee,uri:qt};yt&&yt!=="xmlns"&&!qt&&(L(f,"Unbound namespace prefix: "+JSON.stringify(yt)),Mt.uri=yt),f.tag.attributes[ct]=Mt,K(f,"onattribute",Mt)}f.attribList.length=0}f.tag.isSelfClosing=!!l,f.sawRoot=!0,f.tags.push(f.tag),K(f,"onopentag",f.tag),l||(!f.noscript&&f.tagName.toLowerCase()==="script"?f.state=g.SCRIPT:f.state=g.TEXT,f.tag=null,f.tagName=""),f.attribName=f.attribValue="",f.attribList.length=0}function H(f){if(!f.tagName){L(f,"Weird empty close tag."),f.textNode+="</>",f.state=g.TEXT;return}if(f.script){if(f.tagName!=="script"){f.script+="</"+f.tagName+">",f.tagName="",f.state=g.SCRIPT;return}K(f,"onscript",f.script),f.script=""}var l=f.tags.length,B=f.tagName;f.strict||(B=B[f.looseCase]());for(var w=B;l--;){var z=f.tags[l];if(z.name!==w)L(f,"Unexpected close tag");else break}if(l<0){L(f,"Unmatched closing tag: "+f.tagName),f.textNode+="</"+f.tagName+">",f.state=g.TEXT;return}f.tagName=B;for(var J=f.tags.length;J-- >l;){var X=f.tag=f.tags.pop();f.tagName=f.tag.name,K(f,"onclosetag",f.tagName);var nt={};for(var ct in X.ns)nt[ct]=X.ns[ct];var Bt=f.tags[f.tags.length-1]||f;f.opt.xmlns&&X.ns!==Bt.ns&&Object.keys(X.ns).forEach(function(it){var yt=X.ns[it];K(f,"onclosenamespace",{prefix:it,uri:yt})})}l===0&&(f.closedRoot=!0),f.tagName=f.attribValue=f.attribName="",f.attribList.length=0,f.state=g.TEXT}function Tt(f){var l=f.entity,B=l.toLowerCase(),w,z="";return f.ENTITIES[l]?f.ENTITIES[l]:f.ENTITIES[B]?f.ENTITIES[B]:(l=B,l.charAt(0)==="#"&&(l.charAt(1)==="x"?(l=l.slice(2),w=parseInt(l,16),z=w.toString(16)):(l=l.slice(1),w=parseInt(l,10),z=w.toString(10))),l=l.replace(/^0+/,""),isNaN(w)||z.toLowerCase()!==l?(L(f,"Invalid character entity"),"&"+f.entity+";"):String.fromCodePoint(w))}function bt(f,l){l==="<"?(f.state=g.OPEN_WAKA,f.startTagPosition=f.position):d(l)||(L(f,"Non-whitespace before first tag."),f.textNode=l,f.state=g.TEXT)}function Vt(f,l){var B="";return l<f.length&&(B=f.charAt(l)),B}function Ht(f){var l=this;if(this.error)throw this.error;if(l.closed)return ot(l,"Cannot write after close. Assign an onready handler.");if(f===null)return ht(l);typeof f=="object"&&(f=f.toString());for(var B=0,w="";w=Vt(f,B++),l.c=w,!!w;)switch(l.trackPosition&&(l.position++,w===`
|
|
13
|
+
`?(l.line++,l.column=0):l.column++),l.state){case g.BEGIN:if(l.state=g.BEGIN_WHITESPACE,w==="\uFEFF")continue;bt(l,w);continue;case g.BEGIN_WHITESPACE:bt(l,w);continue;case g.TEXT:if(l.sawRoot&&!l.closedRoot){for(var z=B-1;w&&w!=="<"&&w!=="&";)w=Vt(f,B++),w&&l.trackPosition&&(l.position++,w===`
|
|
14
|
+
`?(l.line++,l.column=0):l.column++);l.textNode+=f.substring(z,B-1)}w==="<"&&!(l.sawRoot&&l.closedRoot&&!l.strict)?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):(!d(w)&&(!l.sawRoot||l.closedRoot)&&L(l,"Text data outside of root node."),w==="&"?l.state=g.TEXT_ENTITY:l.textNode+=w);continue;case g.SCRIPT:w==="<"?l.state=g.SCRIPT_ENDING:l.script+=w;continue;case g.SCRIPT_ENDING:w==="/"?l.state=g.CLOSE_TAG:(l.script+="<"+w,l.state=g.SCRIPT);continue;case g.OPEN_WAKA:if(w==="!")l.state=g.SGML_DECL,l.sgmlDecl="";else if(!d(w))if(U(O,w))l.state=g.OPEN_TAG,l.tagName=w;else if(w==="/")l.state=g.CLOSE_TAG,l.tagName="";else if(w==="?")l.state=g.PROC_INST,l.procInstName=l.procInstBody="";else{if(L(l,"Unencoded <"),l.startTagPosition+1<l.position){var J=l.position-l.startTagPosition;w=new Array(J).join(" ")+w}l.textNode+="<"+w,l.state=g.TEXT}continue;case g.SGML_DECL:if(l.sgmlDecl+w==="--"){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+w,l.sgmlDecl=""):(l.sgmlDecl+w).toUpperCase()===C?(K(l,"onopencdata"),l.state=g.CDATA,l.sgmlDecl="",l.cdata=""):(l.sgmlDecl+w).toUpperCase()===T?(l.state=g.DOCTYPE,(l.doctype||l.sawRoot)&&L(l,"Inappropriately located doctype declaration"),l.doctype="",l.sgmlDecl=""):w===">"?(K(l,"onsgmldeclaration",l.sgmlDecl),l.sgmlDecl="",l.state=g.TEXT):(b(w)&&(l.state=g.SGML_DECL_QUOTED),l.sgmlDecl+=w);continue;case g.SGML_DECL_QUOTED:w===l.q&&(l.state=g.SGML_DECL,l.q=""),l.sgmlDecl+=w;continue;case g.DOCTYPE:w===">"?(l.state=g.TEXT,K(l,"ondoctype",l.doctype),l.doctype=!0):(l.doctype+=w,w==="["?l.state=g.DOCTYPE_DTD:b(w)&&(l.state=g.DOCTYPE_QUOTED,l.q=w));continue;case g.DOCTYPE_QUOTED:l.doctype+=w,w===l.q&&(l.q="",l.state=g.DOCTYPE);continue;case g.DOCTYPE_DTD:w==="]"?(l.doctype+=w,l.state=g.DOCTYPE):w==="<"?(l.state=g.OPEN_WAKA,l.startTagPosition=l.position):b(w)?(l.doctype+=w,l.state=g.DOCTYPE_DTD_QUOTED,l.q=w):l.doctype+=w;continue;case g.DOCTYPE_DTD_QUOTED:l.doctype+=w,w===l.q&&(l.state=g.DOCTYPE_DTD,l.q="");continue;case g.COMMENT:w==="-"?l.state=g.COMMENT_ENDING:l.comment+=w;continue;case g.COMMENT_ENDING:w==="-"?(l.state=g.COMMENT_ENDED,l.comment=lt(l.opt,l.comment),l.comment&&K(l,"oncomment",l.comment),l.comment=""):(l.comment+="-"+w,l.state=g.COMMENT);continue;case g.COMMENT_ENDED:w!==">"?(L(l,"Malformed comment"),l.comment+="--"+w,l.state=g.COMMENT):l.doctype&&l.doctype!==!0?l.state=g.DOCTYPE_DTD:l.state=g.TEXT;continue;case g.CDATA:w==="]"?l.state=g.CDATA_ENDING:l.cdata+=w;continue;case g.CDATA_ENDING:w==="]"?l.state=g.CDATA_ENDING_2:(l.cdata+="]"+w,l.state=g.CDATA);continue;case g.CDATA_ENDING_2:w===">"?(l.cdata&&K(l,"oncdata",l.cdata),K(l,"onclosecdata"),l.cdata="",l.state=g.TEXT):w==="]"?l.cdata+="]":(l.cdata+="]]"+w,l.state=g.CDATA);continue;case g.PROC_INST:w==="?"?l.state=g.PROC_INST_ENDING:d(w)?l.state=g.PROC_INST_BODY:l.procInstName+=w;continue;case g.PROC_INST_BODY:if(!l.procInstBody&&d(w))continue;w==="?"?l.state=g.PROC_INST_ENDING:l.procInstBody+=w;continue;case g.PROC_INST_ENDING:w===">"?(K(l,"onprocessinginstruction",{name:l.procInstName,body:l.procInstBody}),l.procInstName=l.procInstBody="",l.state=g.TEXT):(l.procInstBody+="?"+w,l.state=g.PROC_INST_BODY);continue;case g.OPEN_TAG:U(_,w)?l.tagName+=w:(st(l),w===">"?Y(l):w==="/"?l.state=g.OPEN_TAG_SLASH:(d(w)||L(l,"Invalid character in tag name"),l.state=g.ATTRIB));continue;case g.OPEN_TAG_SLASH:w===">"?(Y(l,!0),H(l)):(L(l,"Forward-slash in opening tag not followed by >"),l.state=g.ATTRIB);continue;case g.ATTRIB:if(d(w))continue;w===">"?Y(l):w==="/"?l.state=g.OPEN_TAG_SLASH:U(O,w)?(l.attribName=w,l.attribValue="",l.state=g.ATTRIB_NAME):L(l,"Invalid attribute name");continue;case g.ATTRIB_NAME:w==="="?l.state=g.ATTRIB_VALUE:w===">"?(L(l,"Attribute without value"),l.attribValue=l.attribName,et(l),Y(l)):d(w)?l.state=g.ATTRIB_NAME_SAW_WHITE:U(_,w)?l.attribName+=w:L(l,"Invalid attribute name");continue;case g.ATTRIB_NAME_SAW_WHITE:if(w==="=")l.state=g.ATTRIB_VALUE;else{if(d(w))continue;L(l,"Attribute without value"),l.tag.attributes[l.attribName]="",l.attribValue="",K(l,"onattribute",{name:l.attribName,value:""}),l.attribName="",w===">"?Y(l):U(O,w)?(l.attribName=w,l.state=g.ATTRIB_NAME):(L(l,"Invalid attribute name"),l.state=g.ATTRIB)}continue;case g.ATTRIB_VALUE:if(d(w))continue;b(w)?(l.q=w,l.state=g.ATTRIB_VALUE_QUOTED):(l.opt.unquotedAttributeValues||ot(l,"Unquoted attribute value"),l.state=g.ATTRIB_VALUE_UNQUOTED,l.attribValue=w);continue;case g.ATTRIB_VALUE_QUOTED:if(w!==l.q){w==="&"?l.state=g.ATTRIB_VALUE_ENTITY_Q:l.attribValue+=w;continue}et(l),l.q="",l.state=g.ATTRIB_VALUE_CLOSED;continue;case g.ATTRIB_VALUE_CLOSED:d(w)?l.state=g.ATTRIB:w===">"?Y(l):w==="/"?l.state=g.OPEN_TAG_SLASH:U(O,w)?(L(l,"No whitespace between attributes"),l.attribName=w,l.attribValue="",l.state=g.ATTRIB_NAME):L(l,"Invalid attribute name");continue;case g.ATTRIB_VALUE_UNQUOTED:if(!R(w)){w==="&"?l.state=g.ATTRIB_VALUE_ENTITY_U:l.attribValue+=w;continue}et(l),w===">"?Y(l):l.state=g.ATTRIB;continue;case g.CLOSE_TAG:if(l.tagName)w===">"?H(l):U(_,w)?l.tagName+=w:l.script?(l.script+="</"+l.tagName,l.tagName="",l.state=g.SCRIPT):(d(w)||L(l,"Invalid tagname in closing tag"),l.state=g.CLOSE_TAG_SAW_WHITE);else{if(d(w))continue;k(O,w)?l.script?(l.script+="</"+w,l.state=g.SCRIPT):L(l,"Invalid tagname in closing tag."):l.tagName=w}continue;case g.CLOSE_TAG_SAW_WHITE:if(d(w))continue;w===">"?H(l):L(l,"Invalid characters in closing tag");continue;case g.TEXT_ENTITY:case g.ATTRIB_VALUE_ENTITY_Q:case g.ATTRIB_VALUE_ENTITY_U:var X,nt;switch(l.state){case g.TEXT_ENTITY:X=g.TEXT,nt="textNode";break;case g.ATTRIB_VALUE_ENTITY_Q:X=g.ATTRIB_VALUE_QUOTED,nt="attribValue";break;case g.ATTRIB_VALUE_ENTITY_U:X=g.ATTRIB_VALUE_UNQUOTED,nt="attribValue";break}if(w===";"){var ct=Tt(l);l.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(ct)?(l.entity="",l.state=X,l.write(ct)):(l[nt]+=ct,l.entity="",l.state=X)}else U(l.entity.length?m:v,w)?l.entity+=w:(L(l,"Invalid character in entity name"),l[nt]+="&"+l.entity+w,l.entity="",l.state=X);continue;default:throw new Error(l,"Unknown state: "+l.state)}return l.position>=l.bufferCheckPosition&&s(l),l}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var f=String.fromCharCode,l=Math.floor,B=function(){var w=16384,z=[],J,X,nt=-1,ct=arguments.length;if(!ct)return"";for(var Bt="";++nt<ct;){var it=Number(arguments[nt]);if(!isFinite(it)||it<0||it>1114111||l(it)!==it)throw RangeError("Invalid code point: "+it);it<=65535?z.push(it):(it-=65536,J=(it>>10)+55296,X=it%1024+56320,z.push(J,X)),(nt+1===ct||z.length>w)&&(Bt+=f.apply(null,z),z.length=0)}return Bt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:B,configurable:!0,writable:!0}):String.fromCodePoint=B}()})(h)}(ee)),ee}var se,Oe;function ne(){return Oe||(Oe=1,se={isArray:function(h){return Array.isArray?Array.isArray(h):Object.prototype.toString.call(h)==="[object Array]"}}),se}var ae,Pe;function oe(){if(Pe)return ae;Pe=1;var h=ne().isArray;return ae={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}},ae}var le,Re;function Ue(){if(Re)return le;Re=1;var h=gi(),t=oe(),e=ne().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 a(_){var v=Number(_);if(!isNaN(v))return v;var m=_.toLowerCase();return m==="true"?!0:m==="false"?!1:_}function o(_,v){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 v=="string"&&(v=i[_+"Fn"](v,s)),_==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(m in v)if(v.hasOwnProperty(m))if("instructionFn"in i)v[m]=i.instructionFn(v[m],m,s);else{var d=v[m];delete v[m],v[i.instructionNameFn(m,d,s)]=d}}e(s[i[_+"Key"]])?s[i[_+"Key"]].push(v):s[i[_+"Key"]]=v}else{s[i.elementsKey]||(s[i.elementsKey]=[]);var b={};if(b[i.typeKey]=_,_==="instruction"){for(m in v)if(v.hasOwnProperty(m))break;b[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(m,v,s):m,i.instructionHasAttributes?(b[i.attributesKey]=v[m][i.attributesKey],"instructionFn"in i&&(b[i.attributesKey]=i.instructionFn(b[i.attributesKey],m,s))):("instructionFn"in i&&(v[m]=i.instructionFn(v[m],m,s)),b[i.instructionKey]=v[m])}else _+"Fn"in i&&(v=i[_+"Fn"](v,s)),b[i[_+"Key"]]=v;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 v;for(v in _)if(_.hasOwnProperty(v)&&(i.trim&&(_[v]=_[v].trim()),i.nativeTypeAttributes&&(_[v]=a(_[v])),"attributeValueFn"in i&&(_[v]=i.attributeValueFn(_[v],v,s)),"attributeNameFn"in i)){var m=_[v];delete _[v],_[i.attributeNameFn(v,_[v],s)]=m}}return _}function S(_){var v={};if(_.body&&(_.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var m=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,d;(d=m.exec(_.body))!==null;)v[d[1]]=d[2]||d[3]||d[4];v=y(v)}if(_.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;s[i.declarationKey]={},Object.keys(v).length&&(s[i.declarationKey][i.attributesKey]=v),i.addParent&&(s[i.declarationKey][i.parentKey]=s)}else{if(i.ignoreInstruction)return;i.trim&&(_.body=_.body.trim());var b={};i.instructionHasAttributes&&Object.keys(v).length?(b[_.name]={},b[_.name][i.attributesKey]=v):b[_.name]=_.body,o("instruction",b)}}function x(_,v){var m;if(typeof _=="object"&&(v=_.attributes,_=_.name),v=y(v),"elementNameFn"in i&&(_=i.elementNameFn(_,s)),i.compact){if(m={},!i.ignoreAttributes&&v&&Object.keys(v).length){m[i.attributesKey]={};var d;for(d in v)v.hasOwnProperty(d)&&(m[i.attributesKey][d]=v[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&&v&&Object.keys(v).length&&(m[i.attributesKey]=v),i.alwaysChildren&&(m[i.elementsKey]=[]),s[i.elementsKey].push(m);m[i.parentKey]=s,s=m}function C(_){i.ignoreText||!_.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(_=_.trim()),i.nativeType&&(_=a(_)),i.sanitize&&(_=_.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),o("text",_))}function T(_){i.ignoreComment||(i.trim&&(_=_.trim()),o("comment",_))}function M(_){var v=s[i.parentKey];i.addParent||delete s[i.parentKey],s=v}function F(_){i.ignoreCdata||(i.trim&&(_=_.trim()),o("cdata",_))}function N(_){i.ignoreDoctype||(_=_.replace(/^ /,""),i.trim&&(_=_.trim()),o("doctype",_))}function O(_){_.note=_}return le=function(_,v){var m=h.parser(!0,{}),d={};if(s=d,i=c(v),m.opt={strictEntities:!0},m.onopentag=x,m.ontext=C,m.oncomment=T,m.onclosetag=M,m.onerror=O,m.oncdata=F,m.ondoctype=N,m.onprocessinginstruction=S,m.write(_).close(),d[i.elementsKey]){var b=d[i.elementsKey];delete d[i.elementsKey],d[i.elementsKey]=b,delete d.text}return d},le}var ce,ke;function yi(){if(ke)return ce;ke=1;var h=oe(),t=Ue();function e(i){var s=h.copyOptions(i);return h.ensureSpacesExists(s),s}return ce=function(i,s){var c,a,o,y;return c=e(s),a=t(i,c),y="compact"in c&&c.compact?"_parent":"parent","addParent"in c&&c.addParent?o=JSON.stringify(a,function(S,x){return S===y?"_":x},c.spaces):o=JSON.stringify(a,null,c.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},ce}var ue,Le;function Ye(){if(Le)return ue;Le=1;var h=oe(),t=ne().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?`
|
|
15
|
+
`:"")+Array(d+1).join(m.spaces)}function a(m,d,b){if(d.ignoreAttributes)return"";"attributesFn"in d&&(m=d.attributesFn(m,i,e));var R,U,k,g,V=[];for(R in m)m.hasOwnProperty(R)&&m[R]!==null&&m[R]!==void 0&&(g=d.noQuotesForNativeAttributes&&typeof m[R]!="string"?"":'"',U=""+m[R],U=U.replace(/"/g,"""),k="attributeNameFn"in d?d.attributeNameFn(R,U,i,e):R,V.push(d.spaces&&d.indentAttributes?c(d,b+1,!1):" "),V.push(k+"="+g+("attributeValueFn"in d?d.attributeValueFn(U,R,i,e):U)+g));return m&&Object.keys(m).length&&d.spaces&&d.indentAttributes&&V.push(c(d,b,!1)),V.join("")}function o(m,d,b){return e=m,i="xml",d.ignoreDeclaration?"":"<?xml"+a(m[d.attributesKey],d,b)+"?>"}function y(m,d,b){if(d.ignoreInstruction)return"";var R;for(R in m)if(m.hasOwnProperty(R))break;var U="instructionNameFn"in d?d.instructionNameFn(R,m[R],i,e):R;if(typeof m[R]=="object")return e=m,i=U,"<?"+U+a(m[R][d.attributesKey],d,b)+"?>";var k=m[R]?m[R]:"";return"instructionFn"in d&&(k=d.instructionFn(k,R,i,e)),"<?"+U+(k?" "+k:"")+"?>"}function S(m,d){return d.ignoreComment?"":"<!--"+("commentFn"in d?d.commentFn(m,i,e):m)+"-->"}function x(m,d){return d.ignoreCdata?"":"<![CDATA["+("cdataFn"in d?d.cdataFn(m,i,e):m.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(m,d){return d.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in d?d.doctypeFn(m,i,e):m)+">"}function T(m,d){return d.ignoreText?"":(m=""+m,m=m.replace(/&/g,"&"),m=m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"textFn"in d?d.textFn(m,i,e):m)}function M(m,d){var b;if(m.elements&&m.elements.length)for(b=0;b<m.elements.length;++b)switch(m.elements[b][d.typeKey]){case"text":if(d.indentText)return!0;break;case"cdata":if(d.indentCdata)return!0;break;case"instruction":if(d.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function F(m,d,b){e=m,i=m.name;var R=[],U="elementNameFn"in d?d.elementNameFn(m.name,m):m.name;R.push("<"+U),m[d.attributesKey]&&R.push(a(m[d.attributesKey],d,b));var k=m[d.elementsKey]&&m[d.elementsKey].length||m[d.attributesKey]&&m[d.attributesKey]["xml:space"]==="preserve";return k||("fullTagEmptyElementFn"in d?k=d.fullTagEmptyElementFn(m.name,m):k=d.fullTagEmptyElement),k?(R.push(">"),m[d.elementsKey]&&m[d.elementsKey].length&&(R.push(N(m[d.elementsKey],d,b+1)),e=m,i=m.name),R.push(d.spaces&&M(m,d)?`
|
|
16
|
+
`+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+F(k,d,b);case"comment":return U+g+S(k[d.commentKey],d);case"doctype":return U+g+C(k[d.doctypeKey],d);case"cdata":return U+(d.indentCdata?g:"")+x(k[d.cdataKey],d);case"text":return U+(d.indentText?g:"")+T(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(">"+T(m,b)+"</"+k+">"),g.join("");m[b.attributesKey]&&g.push(a(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(v(m,b,R+1,!1)),e=m,i=d,d&&g.push((U?c(b,R,!1):"")+"</"+k+">"),g.join("")}function v(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):"")+T(g[U],d));break;case d.cdataKey:V.push((d.indentCdata?c(d,b,R):"")+x(g[U],d));break;case d.doctypeKey:V.push(c(d,b,R)+C(g[U],d));break;case d.commentKey:V.push(c(d,b,R)+S(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 ue=function(m,d){d=s(d);var b=[];return e=m,i="_root_",d.compact?b.push(v(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("")},ue}var he,Ge;function xi(){if(Ge)return he;Ge=1;var h=Ye();return he=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)},he}var fe,Ve;function Ei(){if(Ve)return fe;Ve=1;var h=Ue(),t=yi(),e=Ye(),i=xi();return fe={xml2js:h,xml2json:t,js2xml:e,json2xml:i},fe}var de=Ei(),wi=Me();const ft=class ft{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=s=>{var y,S;if(!s)return;const c=s.attributes||s._attributes;if(!c)return s;let a={...s,...c,...ft.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"]),...ft.propToBool(c,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(a.properties){const x=ft.toArray(a.properties.property),C={};for(let T of x){const M=T._attributes;if(!M)continue;let F;switch(M.type){case"file":F=this.getImagePath(M.value);break;case"object":case"float":case"int":F=+M.value;break;case"bool":F=M.value=="true";break;case"class":F={...((y=this.transform(T))==null?void 0:y.properties)??{},_classname:M.propertytype};break;default:F=M.value}C[M.name]=F}a.properties=C}a.polygon&&(a.polygon=this.transform(a.polygon)),a.polyline&&(a.polyline=this.transform(a.polyline)),a.points&&(a=a.points.split(" ").map(x=>{const C=x.split(",");return{x:+C[0],y:+C[1]}})),a.point&&(a.point=!0),a.ellipse&&(a.ellipse=!0),a.text&&(a.text={text:a.text._text,...this.transform(a.text)},delete a.text._text),a.image&&(a.image=this.transform(a.image)),a.source&&(this.isTilesetSource(a)||(a.source=this.getImagePath(a.source)));const o=a.object||((S=a.objectgroup)==null?void 0:S.object);return o&&(a.objects=ft.toArray(o).map(x=>this.transform(x))),delete a._attributes,delete a.attributes,delete a.object,delete a.objectgroup,a}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:Se(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 a=0;a<i;a+=4)c[s]=t.readUInt32LE(a),s++;return c}static decode(t,e){const{encoding:i,data:s}=t;return i=="base64"?ft.unpackTileBytes(wi.Buffer.from(s.trim(),"base64"),e):i=="csv"?s.trim().split(",").map(c=>+c):s}parseMap(){const t=de.xml2js(this.xml,{compact:!0}),e=de.xml2js(this.xml),i=t.map.tileset;t.map.group;const s=S=>{const{objectgroup:x,group:C,layer:T,imagelayer:M}=S,F=N=>{N&&ft.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)})};F(x),F(T),F(C),F(M),C&&s(C)};s(t.map);const c=(S,x=[])=>{var C;if(!S)return x;for(let T of S){const{name:M}=T;if(!["layer","group","imagelayer","objectgroup"].includes(M))continue;const F=(C=T.elements)==null?void 0:C.find(O=>O.name=="data");T.layer=this.layers.get(+T.attributes.id);const N={...this.transform(F)??{},...this.transform(T),...this.transform(T.layer),layers:c(T.elements),data:F?F.elements[0].text:void 0,type:M=="layer"?"tilelayer":M};delete N.elements,delete N.layer,N.data&&(N.data=ft.decode(N,N.width*N.height)),x.push(N)}return x},a=c(e.elements[0].elements),o=ft.toArray(i).map(S=>this.transform(S)),y={...this.transform(t.map),layers:a,tilesets:o};return delete y.layer,delete y.tileset,delete y.group,delete y.imagelayer,y}parseTileset(){const t=de.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:ft.toArray(e.tile).map(s=>{const c=this.transform(s);return s.animation&&(c.animations=ft.toArray(s.animation.frame).map(this.transform)),delete c.animation,c})};return delete i.tile,i}};ft.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},ft.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let pe=ft;class me{constructor(t){this.properties={},this.properties=(t==null?void 0: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 vi=2147483648,bi=1073741824,Ai=536870912,Ti=268435456;class Lt extends me{constructor(t){super(t),this.obj=t,this._gid=t==null?void 0:t.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&vi)}get verticalFlip(){return!!(this._gid&bi)}get diagonalFlip(){return!!(this._gid&Ai)}get rotatedHex120(){return!!(this._gid&Ti)}get gid(){return Lt.getRealGid(this._gid)}set gid(t){this._gid=t}}let _e=class extends Lt{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 Si extends Lt{constructor(t){super(t),this.layerName="",Object.assign(this,t),t!=null&&t.gid&&(this.y-=this.height)}}class ge extends me{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=Lt.getRealGid(t),c=ge.findTileSet(s,this.tilesets);if(!c)return;const a=c.getTile(s-c.firstgid);return a?new _e({...a.tile,gid:t,index:e,layerIndex:i}):new _e({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 Si(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 Ci extends me{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 _e(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class At{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=>At.typeOfFile(o).isXml,c=o=>{if(!o)return i(null);if(s(o)){const y=new pe(o,t,this.basePath);if(e=="map"){const S=y.parseMap();return i(S)}else if(e=="tileset"){const S=y.parseTileset();return i(S)}}return i(JSON.parse(o))};if(At.typeOfFile(t).isObject)return i(t);const{isHttp:a}=At.typeOfFile(t);if(s(t))c(t);else if(a||At.isBrowser()){let o=a?t:Se(this.basePath,t);At.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&&At.typeOfFile(this.file).isPath&&(this.file=s(this.file)),this._parseFile(this.file,"map",(c,a)=>{let o=!1;if(a)return t(null,a);if(c.tilesets){const y=[],S=()=>{x++,x==c.tilesets.length&&!o&&(c.tilesets=y,t(c))};let x=0;for(let C=0;C<c.tilesets.length;C++){const T=c.tilesets[C];if(!T.source||T.tiles||T.image||T.tile){y[C]=T,S();continue}i&&At.typeOfFile(T.source).isPath&&(T.source=s(T.source)),this._parseFile(T.source,"tileset",(M,F)=>{if(F)return o=!0,t(null,F);y[C]={...M,firstgid:T.firstgid},S()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((s,c)=>{s?e(s):i(c)},t)})}}const St={TEXTURES_PER_TILEMAP:16,TEXTILE_SCALE_MODE:"linear",use32bitIndex:!1};var Ii=Object.defineProperty,Bi=(h,t,e)=>t in h?Ii(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Ct=(h,t,e)=>(Bi(h,typeof t!="symbol"?t+"":t,e),e);const Yt=class Kt 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=Kt.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:2*4},aFrame:{buffer:e,format:"float32x4",stride:i,offset:4*4},aAnim:{buffer:e,format:"float32x2",stride:i,offset:8*4},aTextureId:{buffer:e,format:"sint32",stride:i,offset:10*4},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:11*4},aAlpha:{buffer:e,format:"float32",stride:i,offset:12*4}}}),Ct(this,"lastTimeAccess",0),Ct(this,"vertSize",Kt.vertSize),Ct(this,"vertPerQuad",Kt.vertPerQuad),Ct(this,"stride",Kt.stride),Ct(this,"buf"),this.buf=e}};Ct(Yt,"vertSize",13),Ct(Yt,"vertPerQuad",4),Ct(Yt,"stride",Yt.vertSize*4);let Mi=Yt;var Fi=Object.defineProperty,Di=(h,t,e)=>t in h?Fi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,It=(h,t,e)=>(Di(h,typeof t!="symbol"?t+"":t,e),e);class qe{constructor(){It(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 Ke{constructor(t,e){It(this,"renderer"),It(this,"tileAnim",[0,0]),It(this,"ibLen",0),It(this,"indexBuffer",null),It(this,"shader"),It(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 Mi(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=Ni(t,St.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:a}=e.uniforms;s.uProjectionMatrix.copyTo(i).append(s.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(c=t.parent.tileAnim||c),a[0]=c[0],a[1]=c[1],e.update(),this.adaptor.execute(this,t)}}It(Ke,"extension",{type:[P.ExtensionType.WebGLPipes,P.ExtensionType.WebGPUPipes],name:"tilemap"});function Ni(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 Oi=Object.defineProperty,Pi=(h,t,e)=>t in h?Oi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,vt=(h,t,e)=>(Pi(h,typeof t!="symbol"?t+"":t,e),e);class Ot{constructor(t){vt(this,"max_textures"),vt(this,"arr",[]),vt(this,"count",0),vt(this,"dirty",!1),vt(this,"dirty_gpu",!1),vt(this,"bind_group",null),vt(this,"bind_group_resources",{}),vt(this,"tex_sizes",null),vt(this,"null_color",new Float32Array([0,0,0,.5])),vt(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 a=0;a<i;a++){const o=e[a];o&&(t[a*4]=o.pixelWidth,t[a*4+1]=o.pixelHeight,t[a*4+2]=1/o.pixelWidth,t[a*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 a=0;a<e;a++){const o=(a<s?i[a]: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(`
|
|
17
|
+
`)}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(`
|
|
18
|
+
`)}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 Ri=Object.defineProperty,Ui=(h,t,e)=>t in h?Ri(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,ye=(h,t,e)=>(Ui(h,typeof t!="symbol"?t+"":t,e),e);const ki=`
|
|
19
|
+
in vec2 aVertexPosition;
|
|
20
|
+
in vec2 aTextureCoord;
|
|
21
|
+
in vec4 aFrame;
|
|
22
|
+
in vec2 aAnim;
|
|
23
|
+
in float aAnimDivisor;
|
|
24
|
+
in float aTextureId;
|
|
25
|
+
in float aAlpha;
|
|
26
|
+
|
|
27
|
+
uniform mat3 u_proj_trans;
|
|
28
|
+
uniform vec2 u_anim_frame;
|
|
29
|
+
|
|
30
|
+
out vec2 vTextureCoord;
|
|
31
|
+
out float vTextureId;
|
|
32
|
+
out vec4 vFrame;
|
|
33
|
+
out float vAlpha;
|
|
34
|
+
|
|
35
|
+
void main(void)
|
|
36
|
+
{
|
|
37
|
+
gl_Position = vec4((u_proj_trans * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
38
|
+
vec2 animCount = floor((aAnim + 0.5) / 2048.0);
|
|
39
|
+
vec2 animFrameOffset = aAnim - animCount * 2048.0;
|
|
40
|
+
vec2 currentFrame = floor(u_anim_frame / aAnimDivisor);
|
|
41
|
+
vec2 loop_num = floor((currentFrame + 0.5) / animCount);
|
|
42
|
+
vec2 animOffset = animFrameOffset * floor(currentFrame - loop_num * animCount);
|
|
43
|
+
|
|
44
|
+
vTextureCoord = aTextureCoord + animOffset;
|
|
45
|
+
vFrame = aFrame + vec4(animOffset, animOffset);
|
|
46
|
+
vTextureId = aTextureId;
|
|
47
|
+
vAlpha = aAlpha;
|
|
48
|
+
}
|
|
49
|
+
`,Li=`
|
|
50
|
+
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
51
|
+
precision highp float;
|
|
52
|
+
#else
|
|
53
|
+
precision mediump float;
|
|
54
|
+
#endif
|
|
55
|
+
in vec2 vTextureCoord;
|
|
56
|
+
in vec4 vFrame;
|
|
57
|
+
in float vTextureId;
|
|
58
|
+
in float vAlpha;
|
|
59
|
+
|
|
60
|
+
//include_textures
|
|
61
|
+
|
|
62
|
+
void main(void)
|
|
63
|
+
{
|
|
64
|
+
float textureId = floor(vTextureId + 0.5);
|
|
65
|
+
vec2 textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
|
|
66
|
+
vec4 color = sampleMultiTexture(textureId, textureCoord);
|
|
67
|
+
finalColor = color * vAlpha;
|
|
68
|
+
}
|
|
69
|
+
`;class ze extends qe{constructor(){super(...arguments),ye(this,"_shader",null),ye(this,"max_textures",St.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,s=this._shader,c=e.getTileset(),a=s.resources.texture_uniforms;a.uniforms.u_texture_size!==c.tex_sizes&&(a.uniforms.u_texture_size=c.tex_sizes,a.update());for(let o=0;o<c.length;o++)i.texture.bind(c.arr[o],o);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:ki,fragment:Li.replace("//include_textures",Ot.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new P.UniformGroup(Ot.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}ye(ze,"extension",{type:[P.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var Yi=Object.defineProperty,Gi=(h,t,e)=>t in h?Yi(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Xt=(h,t,e)=>(Gi(h,typeof t!="symbol"?t+"":t,e),e);const Vi=`
|
|
70
|
+
struct GlobalUniforms {
|
|
71
|
+
uProjectionMatrix:mat3x3f,
|
|
72
|
+
uWorldTransformMatrix:mat3x3f,
|
|
73
|
+
uWorldColorAlpha: vec4f,
|
|
74
|
+
uResolution: vec2f,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
struct TilemapUniforms {
|
|
78
|
+
u_proj_trans:mat3x3f,
|
|
79
|
+
u_anim_frame:vec2f
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
83
|
+
@group(2) @binding(0) var<uniform> loc: TilemapUniforms;
|
|
84
|
+
|
|
85
|
+
struct VSOutput {
|
|
86
|
+
@builtin(position) vPosition: vec4f,
|
|
87
|
+
@location(0) @interpolate(flat) vTextureId : i32,
|
|
88
|
+
@location(1) vTextureCoord : vec2f,
|
|
89
|
+
@location(2) @interpolate(flat) vFrame : vec4f,
|
|
90
|
+
@location(3) vAlpha : f32
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
@vertex
|
|
94
|
+
fn mainVert(
|
|
95
|
+
@location(6) aVertexPosition: vec2f,
|
|
96
|
+
@location(4) aTextureCoord: vec2f,
|
|
97
|
+
@location(3) aFrame: vec4f,
|
|
98
|
+
@location(1) aAnim: vec2f,
|
|
99
|
+
@location(2) aAnimDivisor: f32,
|
|
100
|
+
@location(5) aTextureId: i32,
|
|
101
|
+
@location(0) aAlpha: f32,
|
|
102
|
+
) -> VSOutput {
|
|
103
|
+
|
|
104
|
+
var vPosition = vec4((loc.u_proj_trans * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
105
|
+
var animCount = floor((aAnim + 0.5) / 2048.0);
|
|
106
|
+
var animFrameOffset = aAnim - animCount * 2048.0;
|
|
107
|
+
var currentFrame = floor(loc.u_anim_frame / aAnimDivisor);
|
|
108
|
+
var loop_num = floor((currentFrame + 0.5) / animCount);
|
|
109
|
+
var animOffset = animFrameOffset * floor(currentFrame - loop_num * animCount);
|
|
110
|
+
var vTextureCoord = aTextureCoord + animOffset;
|
|
111
|
+
var vFrame = aFrame + vec4(animOffset, animOffset);
|
|
112
|
+
|
|
113
|
+
return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
|
|
114
|
+
};
|
|
115
|
+
`,qi=`
|
|
116
|
+
//include_textures
|
|
117
|
+
|
|
118
|
+
@fragment
|
|
119
|
+
fn mainFrag(
|
|
120
|
+
@location(0) @interpolate(flat) vTextureId : i32,
|
|
121
|
+
@location(1) vTextureCoord : vec2f,
|
|
122
|
+
@location(2) @interpolate(flat) vFrame : vec4f,
|
|
123
|
+
@location(3) vAlpha : f32,
|
|
124
|
+
) -> @location(0) vec4f {
|
|
125
|
+
var textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
|
|
126
|
+
var uv = textureCoord * taf.u_texture_size[vTextureId].zw;
|
|
127
|
+
var dx = dpdx(uv);
|
|
128
|
+
var dy = dpdy(uv);
|
|
129
|
+
var color = sampleMultiTexture(vTextureId, uv, dx, dy);
|
|
130
|
+
return color * vAlpha;
|
|
131
|
+
};
|
|
132
|
+
`;class je extends qe{constructor(){super(...arguments),Xt(this,"_shader",null),Xt(this,"max_textures",St.TEXTURES_PER_TILEMAP),Xt(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:Vi,entryPoint:"mainVert"},fragment:{source:qi.replace("//include_textures",Ot.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new P.BindGroup({ut:this.pipe_uniforms})}}Xt(je,"extension",{type:[P.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var Ki=Object.defineProperty,zi=(h,t,e)=>t in h?Ki(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,at=(h,t,e)=>(zi(h,typeof t!="symbol"?t+"":t,e),e),We=(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))(We||{});const gt=Object.keys(We).length/2;class Xe extends P.ViewContainer{constructor(t){super({}),at(this,"shadowColor",new Float32Array([0,0,0,.5])),at(this,"state",P.State.for2d()),at(this,"is_valid",!1),at(this,"renderPipeId","tilemap"),at(this,"canBundle",!0),at(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),at(this,"tileAnim",null),at(this,"rects_count",0),at(this,"compositeParent",!1),at(this,"tileset",new Ot(St.TEXTURES_PER_TILEMAP)),at(this,"tilemapBounds",new P.Bounds),at(this,"hasAnimatedTile",!1),at(this,"pointsBuf",[]),at(this,"batched"),at(this,"vbId",0),at(this,"vb",null),at(this,"vbBuffer",null),at(this,"vbArray",null),at(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=[]){var i,s;let e=this.tileset;if(t instanceof Ot)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 Ot(St.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let c=!0;for(let a=0;a<t.length;a++)if(((i=t[a])==null?void 0:i.source)!==e.arr[a]){c=!1;break}if(c)return this}e=this.tileset=new Ot(St.TEXTURES_PER_TILEMAP);for(let c=0;c<t.length;c++)e.push((s=t[c])==null?void 0:s.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,a=-1,o=!1;if(typeof t=="number")a=t,o=!0,c=this.tileset.arr[a];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){a=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:S=0,tileWidth:x=c.width,tileHeight:C=c.height,animX:T=0,animY:M=0,rotate:F=0,animCountX:N=1024,animCountY:O=1024,animDivisor:_=1,alpha:v=1}=s,m=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||T>0||M>0,m.push(y),m.push(S),m.push(e),m.push(i),m.push(x),m.push(C),m.push(F),m.push(T|0),m.push(M|0),m.push(a),m.push(N),m.push(O),m.push(_),m.push(v),this.tilemapBounds.addFrame(e,i,e+x,i+C),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(gt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(gt-7)]=t,i[i.length-(gt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(gt-8)]=t,i[i.length-(gt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(gt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(gt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/gt;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 a=s.getBuffer("aVertexPosition"),o=s.stride*c;if(!this.vbBuffer||this.vbBuffer.byteLength<o){let T=s.stride;for(;T<o;)T*=2;this.vbBuffer=new ArrayBuffer(T),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const y=this.vbArray,S=this.vbInts;let x=0,C=0;for(let T=0;T<e.length;T+=gt){this.compositeParent&&(C=e[T+9]);const F=e[T+2],N=e[T+3],O=e[T+4],_=e[T+5],v=e[T+0],m=e[T+1];let d=e[T+6];const b=e[T+7],R=e[T+8],U=e[T+10]||1024,k=e[T+11]||1024,g=b+U*2048,V=R+k*2048,rt=e[T+12],K=e[T+13];let W,lt,ot,ht,L,st,$,et;if(d===0)W=v,lt=m,ot=v+O,ht=m,L=v+O,st=m+_,$=v,et=m+_;else{let Y=O/2,H=_/2;d%4!==0&&(Y=_/2,H=O/2);const Tt=v+Y,bt=m+H;d=P.groupD8.add(d,P.groupD8.NW),W=Tt+Y*P.groupD8.uX(d),lt=bt+H*P.groupD8.uY(d),d=P.groupD8.add(d,2),ot=Tt+Y*P.groupD8.uX(d),ht=bt+H*P.groupD8.uY(d),d=P.groupD8.add(d,2),L=Tt+Y*P.groupD8.uX(d),st=bt+H*P.groupD8.uY(d),d=P.groupD8.add(d,2),$=Tt+Y*P.groupD8.uX(d),et=bt+H*P.groupD8.uY(d)}y[x++]=F,y[x++]=N,y[x++]=W,y[x++]=lt,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K,y[x++]=F+O,y[x++]=N,y[x++]=ot,y[x++]=ht,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K,y[x++]=F+O,y[x++]=N+_,y[x++]=L,y[x++]=st,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K,y[x++]=F,y[x++]=N+_,y[x++]=$,y[x++]=et,y[x++]=v+.5,y[x++]=m+.5,y[x++]=v+O-.5,y[x++]=m+_-.5,y[x++]=g,y[x++]=V,S[x++]=C,y[x++]=rt,y[x++]=K}a.data=y}isModified(t){return!!(this.rects_count*gt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/gt}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,a,o,y=0,S=0,x=0,C=1024,T=1024,M=1,F=1){return this.tile(t,s,c,{u:e,v:i,tileWidth:a,tileHeight:o,animX:y,animY:S,rotate:x,animCountX:C,animCountY:T,animDivisor:M,alpha:F})}}var ji=Object.defineProperty,Wi=(h,t,e)=>t in h?ji(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,Gt=(h,t,e)=>(Wi(h,typeof t!="symbol"?t+"":t,e),e);class Xi extends P.Container{constructor(t){super(),Gt(this,"texturesPerTilemap"),Gt(this,"tileAnim",null),Gt(this,"lastModifiedTilemap",null),Gt(this,"modificationMarker",0),Gt(this,"setBitmaps",this.tileset),this.texturesPerTilemap=St.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 a=new Xe(t.slice(c*e,(c+1)*e));a.compositeParent=!0,this.addChild(a)}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 a=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const o=t/this.texturesPerTilemap>>0;let y=0;if(c=a[o],c)y=t%this.texturesPerTilemap;else{if(c=a[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<a.length;o++){const y=a[o],S=y.getTileset().arr;for(let x=0;x<S.length;x++)if(S[x]===t.source){c=y;break}if(c)break}if(!c){for(let o=a.length-1;o>=0;o--){const y=a[o];if(y.getTileset().count<this.texturesPerTilemap){c=y,y.getTileset().push(t.source);break}}c||(c=new Xe(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,a,o,y,S){return this.tile(t,e,i,{animX:s,animY:c,animCountX:a,animCountY:o,animDivisor:y,alpha:S})}addRect(t,e,i,s,c,a,o,y,S,x,C,T){const M=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[M]&&this.children[M].getTileset().count>0?(this.lastModifiedTilemap=this.children[M],this.lastModifiedTilemap.addRect(F,e,i,s,c,a,o,y,S,x,C,T)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}P.extensions.add(Ke),P.extensions.add(ze),P.extensions.add(je);class $t extends P.AnimatedSprite{constructor(t,e){super($t.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=$t.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))}}St.use32bitIndex=!0;class xe extends D.DisplayObject(Xi){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:a,tileheight:o,width:y}=this._layer;s&&(t=Math.floor(t/a),e=Math.floor(e/o));const S=t+e*y,x=this._layer.getTileByIndex(S);if(!x||x&&x.gid==0)return;const C=xe.findTileSet(x.gid,this.tileSets);if(!C)return;const T=new $t(x,C);if(T.x=t*a,T.y=e*o+(o-T.texture.height),T._x=t,T._y=e,C.tileoffset&&(T.x+=C.tileoffset.x??0,T.y+=C.tileoffset.y??0),!(c&&!c(T)))return T}_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 ge({...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",xe);function $i(h){return D.createComponent("CompositeTileLayer",h)}class Hi extends Ci{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 Qi(h,t,e){var s,c;const i=[];for(const a of h){if(a.type!==Rt.Tile){i.push(a);continue}const o=new Map;let y;if(Array.isArray(a.data))y=a.data.map(x=>typeof x=="number"?x:parseInt(String(x),10));else{i.push(a);continue}for(let x=0;x<y.length;x++){const C=y[x];if(C===0)continue;let T;for(let O=t.length-1;O>=0;O--)if(t[O].firstgid&&t[O].firstgid<=C){T=t[O];break}if(!T){o.has(0)||o.set(0,new Array(y.length).fill(0)),o.get(0)[x]=C;continue}const M=C-T.firstgid,F=(c=(s=T.tileset.tiles)==null?void 0:s[M])==null?void 0:c.properties,N=(F==null?void 0:F.z)??0;F==null||F.z,o.has(N)||o.set(N,new Array(y.length).fill(0)),o.get(N)[x]=C}const S=Array.from(o.keys()).sort((x,C)=>x-C);for(const x of S){const C=o.get(x);if(C.some(T=>T!==0)){const T={...a,name:`${a.name}_z${x}`,data:C,properties:{...a.properties,z:x}};i.push(T)}}}return i.sort((a,o)=>{var x,C;const y=((x=a.properties)==null?void 0:x.z)??.5,S=((C=o.properties)==null?void 0:C.z)??.5;return y-S}),i}function Ji(h){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(h,{createLayersPerTilesZ:!1,basePath:""}),s=D.signal([]),c=h.objectLayer;let a=[],o={};const y=async(x,C="")=>typeof x!="string"?x:await new At(x,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const x=t();if(x){o=await y(x,e()),a=[];for(let T of o.tilesets)T.tile&&(T.tiles=T.tile),T.tiles||(T.tiles=[]),a.push(await new Hi(T).load(T.image.source));let C=o.layers;i()&&(C=Qi(o.layers,a)),s.set(C)}});const S=(x,C={})=>D.h(D.Container,C,D.loop(x,T=>{switch(T.type){case Rt.Tile:return D.h($i,{tilewidth:o.tilewidth,tileheight:o.tileheight,width:o.width,height:o.height,...T,tilesets:a});case Rt.Image:const{width:M,height:F,source:N}=T.image;return D.h(D.TilingSprite,{image:N,...T,width:T.repeatx?T.width*T.tilewidth:M,height:T.repeaty?T.height*T.tileheight:F});case Rt.Group:return S(D.signal(T.layers),T);case Rt.ObjectGroup:const O=c==null?void 0:c(T);return D.h(D.Container,T,O);default:return D.h(D.Container)}}));return D.h(D.Container,h,S(s))}function Zi(){const h=`
|
|
133
|
+
precision mediump float;
|
|
134
|
+
attribute vec2 aPosition;
|
|
135
|
+
attribute vec2 aUV;
|
|
136
|
+
varying vec2 vUV;
|
|
137
|
+
void main() {
|
|
138
|
+
vUV = aUV;
|
|
139
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
140
|
+
}
|
|
141
|
+
`,t=`
|
|
142
|
+
precision mediump float;
|
|
143
|
+
|
|
144
|
+
varying vec2 vUV;
|
|
145
|
+
|
|
146
|
+
uniform float uTime;
|
|
147
|
+
uniform vec2 uResolution;
|
|
148
|
+
uniform float uRainSpeed;
|
|
149
|
+
uniform float uWindDirection;
|
|
150
|
+
uniform float uWindStrength;
|
|
151
|
+
uniform float uRainDensity;
|
|
152
|
+
uniform float uMaxDrops;
|
|
153
|
+
|
|
154
|
+
// Optimized hash function (single multiply, no sin)
|
|
155
|
+
float hash(float n) {
|
|
156
|
+
return fract(n * 0.1031);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Generate a single rain drop with fine realistic streak (highly optimized)
|
|
160
|
+
float rainDrop(vec2 uv, float t, float seed, float dropIndex, float maxDrops, float cosA, float sinA) {
|
|
161
|
+
// Pre-generate only necessary random values (reduced from 6 to 3)
|
|
162
|
+
float rnd0 = hash(seed);
|
|
163
|
+
float rnd1 = hash(seed + 1.0);
|
|
164
|
+
float rnd2 = hash(seed + 2.0);
|
|
165
|
+
|
|
166
|
+
// Simplified X position calculation
|
|
167
|
+
float xStructured = mod(dropIndex, 35.0) / 35.0;
|
|
168
|
+
float x = mix(rnd0, xStructured, 0.4) * 2.4 - 1.2;
|
|
169
|
+
|
|
170
|
+
// Base speed + variation
|
|
171
|
+
float speed = (0.4 + rnd1 * 0.6) * uRainSpeed;
|
|
172
|
+
|
|
173
|
+
// Simplified Y position calculation
|
|
174
|
+
float yStructured = mod(dropIndex, maxDrops) / max(maxDrops, 1.0);
|
|
175
|
+
float initialYOffset = mix(rnd2, yStructured, 0.7);
|
|
176
|
+
float yProgress = mod(initialYOffset + t * speed, 1.0);
|
|
177
|
+
float y = 1.2 - yProgress * 2.4;
|
|
178
|
+
|
|
179
|
+
// Aggressive early discard - check vertical bounds first
|
|
180
|
+
if (y < -1.3 || y > 1.3) {
|
|
181
|
+
return 0.0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Simplified wind effect
|
|
185
|
+
float windOffset = uWindDirection * uWindStrength * yProgress * 0.5;
|
|
186
|
+
x += windOffset;
|
|
187
|
+
|
|
188
|
+
// Early discard for horizontal bounds
|
|
189
|
+
if (x < -1.5 || x > 1.5) {
|
|
190
|
+
return 0.0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Fast distance check before expensive calculations
|
|
194
|
+
vec2 diff = uv - vec2(x, y);
|
|
195
|
+
float distSq = dot(diff, diff);
|
|
196
|
+
|
|
197
|
+
// Early discard if too far (major performance boost)
|
|
198
|
+
if (distSq > 0.01) { // ~0.1 units distance
|
|
199
|
+
return 0.0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Only calculate expensive operations if we're close
|
|
203
|
+
float dropWidth = 0.0012 + rnd0 * 0.0008;
|
|
204
|
+
float dropLength = 0.035 + rnd1 * 0.020;
|
|
205
|
+
|
|
206
|
+
// Simplified rotation (only if needed)
|
|
207
|
+
float rotX = diff.x * cosA - diff.y * sinA;
|
|
208
|
+
float rotY = diff.x * sinA + diff.y * cosA;
|
|
209
|
+
|
|
210
|
+
// Fast distance calculation
|
|
211
|
+
float distX = abs(rotX) / dropWidth;
|
|
212
|
+
float distY = abs(rotY) / dropLength;
|
|
213
|
+
float dist = max(distX, distY * 0.6);
|
|
214
|
+
|
|
215
|
+
// Final early discard
|
|
216
|
+
if (dist > 1.2) {
|
|
217
|
+
return 0.0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Simplified intensity calculation
|
|
221
|
+
float intensity = 1.0 - smoothstep(0.0, 1.0, dist);
|
|
222
|
+
intensity *= 0.7 + 0.5 * rnd0;
|
|
223
|
+
|
|
224
|
+
// Simplified vertical fade
|
|
225
|
+
float verticalFade = smoothstep(-1.2, -0.8, y) * smoothstep(1.2, 0.8, y);
|
|
226
|
+
intensity *= verticalFade;
|
|
227
|
+
|
|
228
|
+
return intensity;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
void main() {
|
|
232
|
+
// Normalized uv coordinates centered (pre-calculated once)
|
|
233
|
+
vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy)
|
|
234
|
+
/ min(uResolution.x, uResolution.y);
|
|
235
|
+
|
|
236
|
+
float rain = 0.0;
|
|
237
|
+
|
|
238
|
+
// Clamp number of drops - reduced max for better performance
|
|
239
|
+
float maxDrops = clamp(uMaxDrops, 10.0, 150.0);
|
|
240
|
+
|
|
241
|
+
// Pre-calculate wind angle & trig once per fragment
|
|
242
|
+
float windAngle = uWindDirection * uWindStrength * 0.2;
|
|
243
|
+
float cosA = cos(windAngle);
|
|
244
|
+
float sinA = sin(windAngle);
|
|
245
|
+
|
|
246
|
+
// Performance optimization: reduce loop iterations based on resolution
|
|
247
|
+
float pixelCount = uResolution.x * uResolution.y;
|
|
248
|
+
float resolutionFactor = clamp(pixelCount / 500000.0, 0.5, 1.0); // LOD based on resolution
|
|
249
|
+
float effectiveMaxDrops = maxDrops * resolutionFactor;
|
|
250
|
+
float loopMax = min(effectiveMaxDrops, 150.0);
|
|
251
|
+
|
|
252
|
+
// Optimized loop with early exit optimization
|
|
253
|
+
for (float i = 0.0; i < 150.0; i++) {
|
|
254
|
+
if (i >= loopMax) break;
|
|
255
|
+
// Use larger prime number spacing for better seed distribution
|
|
256
|
+
float seed = i * 23.47;
|
|
257
|
+
float dropValue = rainDrop(uv, uTime, seed, i, maxDrops, cosA, sinA);
|
|
258
|
+
rain += dropValue;
|
|
259
|
+
|
|
260
|
+
// Early exit if we've accumulated enough intensity (performance optimization)
|
|
261
|
+
if (rain > 2.0) break;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Scale based on density (optimized calculation)
|
|
265
|
+
rain *= uRainDensity * 0.007;
|
|
266
|
+
|
|
267
|
+
// Realistic rain color
|
|
268
|
+
vec3 rainColor = vec3(0.88, 0.92, 1.0);
|
|
269
|
+
|
|
270
|
+
// Alpha calculation - improved visibility
|
|
271
|
+
float alpha = rain * 0.9;
|
|
272
|
+
|
|
273
|
+
gl_FragColor = vec4(rainColor * rain, alpha);
|
|
274
|
+
}
|
|
275
|
+
`;return new P.GlProgram({vertex:h,fragment:t})}function tr(){const h=`
|
|
276
|
+
precision mediump float;
|
|
277
|
+
attribute vec2 aPosition;
|
|
278
|
+
attribute vec2 aUV;
|
|
279
|
+
varying vec2 vUV;
|
|
280
|
+
void main() {
|
|
281
|
+
vUV = aUV;
|
|
282
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
283
|
+
}
|
|
284
|
+
`,t=`
|
|
285
|
+
precision mediump float;
|
|
286
|
+
|
|
287
|
+
varying vec2 vUV;
|
|
288
|
+
|
|
289
|
+
uniform float uTime;
|
|
290
|
+
uniform vec2 uResolution;
|
|
291
|
+
uniform float uSnowSpeed;
|
|
292
|
+
uniform float uWindDirection;
|
|
293
|
+
uniform float uWindStrength;
|
|
294
|
+
uniform float uSnowDensity;
|
|
295
|
+
uniform float uMaxFlakes;
|
|
296
|
+
|
|
297
|
+
// Hash function for random number generation
|
|
298
|
+
float hash(float n) {
|
|
299
|
+
return fract(sin(n) * 43758.5453);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Generate a single snowflake
|
|
303
|
+
float snowFlake(vec2 uv, float t, float seed) {
|
|
304
|
+
// Pre-calculate all necessary hash values once
|
|
305
|
+
float rnd0 = hash(seed);
|
|
306
|
+
float rnd1 = hash(seed + 1.0);
|
|
307
|
+
float rnd2 = hash(seed + 2.0);
|
|
308
|
+
float rnd3 = hash(seed + 3.0);
|
|
309
|
+
float rnd4 = hash(seed + 4.0);
|
|
310
|
+
|
|
311
|
+
// Base X position
|
|
312
|
+
float x = rnd0 * 2.4 - 1.2;
|
|
313
|
+
|
|
314
|
+
// Falling speed (slower than rain)
|
|
315
|
+
float baseSpeed = 0.3 + rnd1 * 0.4;
|
|
316
|
+
float speed = baseSpeed * uSnowSpeed;
|
|
317
|
+
|
|
318
|
+
// Y position falling from top to bottom
|
|
319
|
+
float y = 1.2 - fract(t * speed + rnd2) * 2.4;
|
|
320
|
+
|
|
321
|
+
// Early exit if flake is too far vertically
|
|
322
|
+
if (y < -1.4 || y > 1.4) {
|
|
323
|
+
return 0.0;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Fall progress (0 = top, 1 = bottom)
|
|
327
|
+
float fallProgress = (1.2 - y) / 2.4;
|
|
328
|
+
|
|
329
|
+
// Optimized oscillation - natural and subtle movement
|
|
330
|
+
float oscillationPhase = t * 1.8 + seed * 6.28;
|
|
331
|
+
float oscillation = sin(oscillationPhase) * 0.08 + sin(oscillationPhase * 1.4) * 0.04;
|
|
332
|
+
oscillation *= (1.0 + fallProgress * 0.3);
|
|
333
|
+
|
|
334
|
+
// Wind effect - more pronounced and progressive with fall
|
|
335
|
+
float windOffset = uWindDirection * uWindStrength * fallProgress * 0.8;
|
|
336
|
+
|
|
337
|
+
// Add horizontal drift due to wind (even at top)
|
|
338
|
+
float windDrift = uWindDirection * uWindStrength * 0.2;
|
|
339
|
+
|
|
340
|
+
// Final X position with wind and oscillation
|
|
341
|
+
x += windOffset + windDrift + oscillation;
|
|
342
|
+
|
|
343
|
+
// Early exit if flake is too far horizontally
|
|
344
|
+
if (x < -1.4 || x > 1.4) {
|
|
345
|
+
return 0.0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
vec2 diff = uv - vec2(x, y);
|
|
349
|
+
|
|
350
|
+
// Fast distance check before expensive calculations
|
|
351
|
+
float distSq = dot(diff, diff);
|
|
352
|
+
|
|
353
|
+
// Early exit if too far (major performance boost)
|
|
354
|
+
if (distSq > 0.015) { // ~0.12 units distance
|
|
355
|
+
return 0.0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Flake size (circular) - only calculate if close
|
|
359
|
+
float flakeSize = 0.008 + rnd3 * 0.006;
|
|
360
|
+
float sizeSq = flakeSize * flakeSize;
|
|
361
|
+
|
|
362
|
+
// Additional early exit check
|
|
363
|
+
if (distSq > sizeSq * 1.5) {
|
|
364
|
+
return 0.0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
float dist = sqrt(distSq) / flakeSize;
|
|
368
|
+
|
|
369
|
+
// Intensity with soft flake shape
|
|
370
|
+
float intensity = 1.0 - smoothstep(0.0, 1.0, dist);
|
|
371
|
+
intensity *= 0.8 + 0.2 * rnd4;
|
|
372
|
+
|
|
373
|
+
// Light twinkle (reduced frequency for performance)
|
|
374
|
+
float twinkle = 0.9 + 0.1 * sin(t * 6.0 + seed * 12.56);
|
|
375
|
+
intensity *= twinkle;
|
|
376
|
+
|
|
377
|
+
// Fade at top and bottom
|
|
378
|
+
intensity *= smoothstep(-1.2, -0.8, y) * smoothstep(1.2, 0.8, y);
|
|
379
|
+
|
|
380
|
+
return intensity;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
void main() {
|
|
384
|
+
vec2 uv = (gl_FragCoord.xy - 0.5 * uResolution.xy) / min(uResolution.x, uResolution.y);
|
|
385
|
+
|
|
386
|
+
float snow = 0.0;
|
|
387
|
+
|
|
388
|
+
// Calculate number of flakes based on density (optimized for performance)
|
|
389
|
+
// Density 50-400 corresponds to approximately 40-150 flakes (reduced for performance)
|
|
390
|
+
float targetFlakes = 40.0 + (uSnowDensity - 50.0) * (110.0 / 350.0);
|
|
391
|
+
float maxFlakes = clamp(max(uMaxFlakes, targetFlakes), 30.0, 120.0);
|
|
392
|
+
|
|
393
|
+
// Performance optimization: reduce loop iterations based on resolution
|
|
394
|
+
float pixelCount = uResolution.x * uResolution.y;
|
|
395
|
+
float resolutionFactor = clamp(pixelCount / 500000.0, 0.5, 1.0); // LOD based on resolution
|
|
396
|
+
float effectiveMaxFlakes = maxFlakes * resolutionFactor;
|
|
397
|
+
float loopMax = min(effectiveMaxFlakes, 120.0);
|
|
398
|
+
|
|
399
|
+
// Generate flakes (limited to 120 for performance)
|
|
400
|
+
for (float i = 0.0; i < 120.0; i++) {
|
|
401
|
+
if (i >= loopMax) break;
|
|
402
|
+
float flakeValue = snowFlake(uv, uTime, i * 15.67);
|
|
403
|
+
snow += flakeValue;
|
|
404
|
+
|
|
405
|
+
// Early exit if we've accumulated enough intensity (performance optimization)
|
|
406
|
+
if (snow > 2.5) break;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Intensity adjustment based on density (normalization)
|
|
410
|
+
// Higher density means more visible flakes
|
|
411
|
+
float densityFactor = clamp(uSnowDensity / 200.0, 0.3, 2.0);
|
|
412
|
+
snow *= densityFactor;
|
|
413
|
+
|
|
414
|
+
// White color for snow
|
|
415
|
+
vec3 snowColor = vec3(1.0, 1.0, 1.0);
|
|
416
|
+
|
|
417
|
+
gl_FragColor = vec4(snowColor * snow, snow * 0.9);
|
|
418
|
+
}
|
|
419
|
+
`;return new P.GlProgram({vertex:h,fragment:t})}function er(){const h=`
|
|
420
|
+
precision mediump float;
|
|
421
|
+
attribute vec2 aPosition;
|
|
422
|
+
attribute vec2 aUV;
|
|
423
|
+
varying vec2 vUV;
|
|
424
|
+
void main() {
|
|
425
|
+
vUV = aUV;
|
|
426
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
427
|
+
}
|
|
428
|
+
`,t=`
|
|
429
|
+
precision mediump float;
|
|
430
|
+
varying vec2 vUV;
|
|
431
|
+
|
|
432
|
+
uniform float uTime;
|
|
433
|
+
uniform vec2 uResolution;
|
|
434
|
+
|
|
435
|
+
uniform float uSpeed; // movement
|
|
436
|
+
uniform float uScale; // detail scale
|
|
437
|
+
uniform float uDensity; // opacity
|
|
438
|
+
|
|
439
|
+
// ------------------- noise -----------------------------------
|
|
440
|
+
|
|
441
|
+
float hash(vec2 p) {
|
|
442
|
+
return fract(sin(dot(p, vec2(127.1,311.7))) * 43758.5453);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
float noise(vec2 p) {
|
|
446
|
+
vec2 i = floor(p);
|
|
447
|
+
vec2 f = fract(p);
|
|
448
|
+
vec2 u = f*f*(3.0 - 2.0*f);
|
|
449
|
+
return mix(
|
|
450
|
+
mix(hash(i + vec2(0.,0.)), hash(i + vec2(1.,0.)), u.x),
|
|
451
|
+
mix(hash(i + vec2(0.,1.)), hash(i + vec2(1.,1.)), u.x),
|
|
452
|
+
u.y
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
float fbm(vec2 p){
|
|
457
|
+
float v = 0.0;
|
|
458
|
+
float a = 0.5;
|
|
459
|
+
for(int i = 0; i < 5; i++){
|
|
460
|
+
v += a * noise(p);
|
|
461
|
+
p *= 2.0;
|
|
462
|
+
a *= 0.5;
|
|
463
|
+
}
|
|
464
|
+
return v;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// --------------------------------------------------------------
|
|
468
|
+
|
|
469
|
+
void main() {
|
|
470
|
+
|
|
471
|
+
vec2 uv = gl_FragCoord.xy / uResolution.xy;
|
|
472
|
+
|
|
473
|
+
float fog = 0.0;
|
|
474
|
+
|
|
475
|
+
// -------- multi-layer fog ----------------------
|
|
476
|
+
|
|
477
|
+
for(int i = 0; i < 3; i++){
|
|
478
|
+
float layer = float(i);
|
|
479
|
+
|
|
480
|
+
vec2 p = uv;
|
|
481
|
+
|
|
482
|
+
float scale = uScale * (1.0 + layer * 0.6);
|
|
483
|
+
float t = uTime * uSpeed * (0.3 + layer * 0.4);
|
|
484
|
+
|
|
485
|
+
// drift
|
|
486
|
+
p.x += t * 0.2;
|
|
487
|
+
p.y += sin(t + p.x * 2.0) * 0.03;
|
|
488
|
+
|
|
489
|
+
// extra wave motion
|
|
490
|
+
p.x += cos(p.y * 2.5 + t) * 0.03;
|
|
491
|
+
|
|
492
|
+
fog += fbm(p * scale) * (1.0 - layer * 0.25);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// normalize & threshold
|
|
496
|
+
fog = smoothstep(0.25, 0.8, fog);
|
|
497
|
+
|
|
498
|
+
// -------------- vertical fade (optional) -----------------
|
|
499
|
+
|
|
500
|
+
float height = uv.y;
|
|
501
|
+
fog *= (1.0 - height * 0.3);
|
|
502
|
+
|
|
503
|
+
// -------------- density handling -------------------------
|
|
504
|
+
|
|
505
|
+
float density = clamp(uDensity, 0.0, 1.0);
|
|
506
|
+
|
|
507
|
+
// alpha based on fog intensity (soft)
|
|
508
|
+
float alpha = fog * density * 0.8;
|
|
509
|
+
|
|
510
|
+
// -------------- fog color -----------------------
|
|
511
|
+
|
|
512
|
+
vec3 baseColor = vec3(0.92, 0.94, 0.96);
|
|
513
|
+
|
|
514
|
+
// slight variation
|
|
515
|
+
float v = fbm(uv * 2.0 + uTime * 0.1) * 0.05;
|
|
516
|
+
|
|
517
|
+
vec3 color = baseColor + v;
|
|
518
|
+
|
|
519
|
+
// modulate brightness by fog value: bright in high density
|
|
520
|
+
color *= (0.6 + fog * 0.4);
|
|
521
|
+
|
|
522
|
+
// ---------- result ---------------------------------
|
|
523
|
+
|
|
524
|
+
gl_FragColor = vec4(color, alpha);
|
|
525
|
+
}
|
|
526
|
+
`;return new P.GlProgram({vertex:h,fragment:t})}const $e=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:a=D.signal(80),height:o=D.signal(.2),scale:y=D.signal(2),resolution:S}=D.useProps(h),x=D.signal([1e3,1e3]),C=S?typeof S=="function"?S:D.signal(S):x;D.mount(ht=>{const L=ht.props.context;L!=null&&L.canvasSize&&t(()=>{const st=L.canvasSize();st&&st.width>0&&st.height>0&&x.set([st.width,st.height])})});const T=typeof e=="function"?e:D.signal(e),M=typeof i=="function"?i:D.signal(i),F=typeof s=="function"?s:D.signal(s),N=typeof c=="function"?c:D.signal(c),O=typeof a=="function"?a:D.signal(a),_=typeof o=="function"?o:D.signal(o),v=typeof y=="function"?y:D.signal(y);let m,d;if(t()==="rain")m=Zi(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uRainSpeed:{value:T(),type:"f32"},uWindDirection:{value:M(),type:"f32"},uWindStrength:{value:F(),type:"f32"},uRainDensity:{value:N(),type:"f32"},uMaxDrops:{value:O(),type:"f32"}};else if(t()==="snow")m=tr(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSnowSpeed:{value:T(),type:"f32"},uWindDirection:{value:M(),type:"f32"},uWindStrength:{value:F(),type:"f32"},uSnowDensity:{value:N(),type:"f32"},uMaxFlakes:{value:O(),type:"f32"}};else if(t()==="fog")m=er(),d={uTime:{value:0,type:"f32"},uResolution:{value:C(),type:"vec2<f32>"},uSpeed:{value:T(),type:"f32"},uScale:{value:v(),type:"f32"},uDensity:{value:N(),type:"f32"}};else throw new Error(`Unknown weather effect: ${t()}. Supported: rain, snow, fog`);const b=new P.UniformGroup(d),R=new P.Shader({glProgram:m,resources:{uniforms:b}}),U=new P.Geometry({attributes:{aPosition:[-1,-1,1,-1,1,1,-1,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let k=Math.random()*10,g=[...C()],V=M(),rt=F(),K=T(),W=N(),lt=O();_();let ot=v();return D.tick(({deltaTime:ht})=>{k+=ht/600,b.uniforms.uTime=k;const L=C();(L[0]!==g[0]||L[1]!==g[1])&&(b.uniforms.uResolution=L,g=[...L]);const st=M();if(st!==V&&(b.uniforms.uWindDirection=st,V=st),t()==="rain"||t()==="snow"){const $=F();$!==rt&&(b.uniforms.uWindStrength=$,rt=$)}if(t()==="rain"){const $=T();$!==K&&(b.uniforms.uRainSpeed=$,K=$);const et=N();et!==W&&(b.uniforms.uRainDensity=et,W=et);const Y=O();Y!==lt&&(b.uniforms.uMaxDrops=Y,lt=Y)}else if(t()==="snow"){const $=T();$!==K&&(b.uniforms.uSnowSpeed=$,K=$);const et=N();et!==W&&(b.uniforms.uSnowDensity=et,W=et);const Y=O();Y!==lt&&(b.uniforms.uMaxFlakes=Y,lt=Y)}else if(t()==="fog"){const $=T();$!==K&&(b.uniforms.uSpeed=$,K=$);const et=v();et!==ot&&(b.uniforms.uScale=et,ot=et);const Y=N();Y!==W&&(b.uniforms.uDensity=Y,W=Y)}}),D.h(D.Mesh,{geometry:U,shader:R,width:"100%",height:"100%"})},ir=$e;return xt.Bar=Je,xt.LightSpot=li,xt.Loading=ui,xt.NightAmbiant=ci,xt.Particle=oi,xt.TiledMap=Ji,xt.Weather=ir,xt.WeatherEffect=$e,Object.defineProperty(xt,Symbol.toStringTag,{value:"Module"}),xt}({},CanvasEngine,PIXI);
|
|
527
|
+
//# sourceMappingURL=index.global.js.map
|