@canvasengine/presets 2.0.0-beta.55 → 2.0.0-beta.58

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.
@@ -1,4 +1,4 @@
1
- var CanvasEnginePresets=(function(Ct,D,L){"use strict";function zi(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const Ot=zi(L);function xe(n){var t=n.toString(16);return t.length==1?"0"+t:t}function Gi(n,t,e){return"#"+xe(n)+xe(t)+xe(e)}function ji(n){const{width:t,height:e,value:i,maxValue:r,backgroundColor:l,foregroundColor:c,border:a,innerMargin:g,borderRadius:S}=D.useProps(n,{backgroundColor:"#000000",foregroundColor:"#FFFFFF",innerMargin:0,borderRadius:0});return D.h(D.Graphics,{...n,width:t,height:e,draw(w){S()?w.roundRect(0,0,t(),e(),S()):w.rect(0,0,t(),e()),a&&w.stroke(a),w.fill(l())}},D.h(D.Graphics,{width:t,height:e,draw(w){const C=g(),M=S(),N=Math.max(0,Math.min(t()-2*C,i()/r()*(t()-2*C))),F=e()-2*C;S?w.roundRect(C,C,N,F,M):w.rect(C,C,N,F);const k=c();if(k.startsWith("rgba")){const[R,m,x,y]=k.match(/\d+(\.\d+)?/g).map(Number);w.fill({color:Gi(R,m,x),alpha:y})}else w.fill(k)}}))}class he{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 Xt{constructor(t){this.data=t}update(t){}dispose(){}}class Xe extends Xt{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 Ot.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 we;(function(n){n[n.Sprite=0]="Sprite",n[n.MovieClip=1]="MovieClip"})(we||(we={}));class Ee{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 st{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 re;(function(n){n.Circle="circle",n.Box="box",n.Ring="ring"})(re||(re={}));class Ki extends Ee{constructor(){super(re.Box)}emit(t){const e=this._settings,i=this.emitter,r=e.width*.5*this.__scaleMod,l=e.height*.5*this.__scaleMod;let c=i.rotation;const a=st.float(-r,r),g=st.float(-l,l);c!=0?(t.component.x=this.__x+this._t*(this.x-this.__x)+a*Math.cos(c)-g*Math.sin(c),t.component.y=this.__y+this._t*(this.y-this.__y)+a*Math.sin(c)+g*Math.cos(c)):(t.component.x=this.__x+this._t*(this.x-this.__x)+a,t.component.y=this.__y+this._t*(this.y-this.__y)+g),e.radial?(c+=Math.atan2(g,a),t.dx=Math.cos(c),t.dy=Math.sin(c)):(t.dx=this._dx,t.dy=this._dy),t.component.rotation=c,this._t+=this._posInterpolationStep}}class qi extends Ee{constructor(){super(re.Circle)}emit(t){const e=this._settings,i=this.emitter;let r;if(e.angle?r=st.float(-e.angle*.5,e.angle*.5)+i.rotation:r=st.float(0,6.28319)+i.rotation,e.radius>0){let l=st.float(0,e.radius)*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(r)*l,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(r)*l}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(r),t.dy=Math.sin(r),t.component.rotation=r):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}class Wi extends Ee{constructor(){super(re.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 r;e.uniform?(r=this._angle+i.rotation,this._angle+=this._uniformStep):r=st.float(-e.angle*.5,e.angle*.5)+i.rotation;const l=e.radius*this.__scaleMod;t.component.x=this.__x+this._t*(this.x-this.__x)+Math.cos(r)*l,t.component.y=this.__y+this._t*(this.y-this.__y)+Math.sin(r)*l,e.radial?(t.dx=Math.cos(r),t.dy=Math.sin(r),t.component.rotation=r):(t.dx=this._dx,t.dy=this._dy,t.component.rotation=i.rotation),this._t+=this._posInterpolationStep}}var zt;(function(n){n[n.Sprite=0]="Sprite",n[n.MovieClip=1]="MovieClip",n[n.Emitter=2]="Emitter",n[n.Trigger=3]="Trigger"})(zt||(zt={}));class $i extends Ot.AnimatedSprite{constructor(t,e,i,r){let l=[],c=e.length;for(let a=0;a<c;a++)l.push(Ot.Texture.from(e[a]));super(l),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 Hi{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 Qe;(function(n){n.Linear="linear",n.EaseInQuad="easeInQuad",n.EaseOutQuad="easeOutQuad",n.EaseInOutQuad="easeInOutQuad",n.EaseInCubic="easeInCubic",n.EaseOutCubic="easeOutCubic",n.EaseInOutCubic="easeInOutCubic",n.EaseInQuart="easeInQuart",n.EaseOutQuart="easeOutQuart",n.EaseInOutQuart="easeInOutQuart",n.EaseInQuint="easeInQuint",n.EaseOutQuint="easeOutQuint",n.EaseInOutQuint="easeInOutQuint",n.EaseInSine="easeInSine",n.EaseOutSine="easeOutSine",n.EaseInOutSine="easeInOutSine",n.EaseInExpo="easeInExpo",n.EaseOutExpo="easeOutExpo",n.EaseInOutExpo="easeInOutExpo",n.EaseInCirc="easeInCirc",n.EaseOutCirc="easeOutCirc",n.EaseInOutCirc="easeInOutCirc",n.EaseInElastic="easeInElastic",n.EaseOutElastic="easeOutElastic",n.EaseInOutElastic="easeInOutElastic",n.EaseInBack="easeInBack",n.EaseOutBack="easeOutBack",n.EaseInOutBack="easeInOutBack",n.EaseInBounce="easeInBounce",n.EaseOutBounce="easeOutBounce",n.EaseInOutBounce="easeInOutBounce"})(Qe||(Qe={}));class Pt{static linear(t,e,i,r){return i*t/r+e}static easeInQuad(t,e,i,r){return i*(t/=r)*t+e}static easeOutQuad(t,e,i,r){return-i*(t/=r)*(t-2)+e}static easeInOutQuad(t,e,i,r){return(t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e}static easeInCubic(t,e,i,r){return i*(t/=r)*t*t+e}static easeOutCubic(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e}static easeInOutCubic(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e}static easeInQuart(t,e,i,r){return i*(t/=r)*t*t*t+e}static easeOutQuart(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e}static easeInOutQuart(t,e,i,r){return(t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e}static easeInQuint(t,e,i,r){return i*(t/=r)*t*t*t*t+e}static easeOutQuint(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e}static easeInOutQuint(t,e,i,r){return(t/=r/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,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}static easeOutSine(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e}static easeInOutSine(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e}static easeInExpo(t,e,i,r){return t===0?e:i*Math.pow(2,10*(t/r-1))+e}static easeOutExpo(t,e,i,r){return t===r?e+i:i*(-Math.pow(2,-10*t/r)+1)+e}static easeInOutExpo(t,e,i,r){return(t/=r/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,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e}static easeOutCirc(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e}static easeInOutCirc(t,e,i,r){return(t/=r/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,r){let l,c,a;return a=1.70158,c=0,l=i,t===0||(t/=r),c||(c=r*.3),l<Math.abs(i)?(l=i,a=c/4):a=c/(2*Math.PI)*Math.asin(i/l),-(l*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/c))+e}static easeOutElastic(t,e,i,r){let l,c,a;return a=1.70158,c=0,l=i,t===0||(t/=r),c||(c=r*.3),l<Math.abs(i)?(l=i,a=c/4):a=c/(2*Math.PI)*Math.asin(i/l),l*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/c)+i+e}static easeInOutElastic(t,e,i,r){let l,c,a;return a=1.70158,c=0,l=i,t===0||(t/=r/2),c||(c=r*.44999999999999996),l<Math.abs(i)?(l=i,a=c/4):a=c/(2*Math.PI)*Math.asin(i/l),t<1?-.5*(l*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/c))+e:l*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/c)*.5+i+e}static easeInBack(t,e,i,r,l){return l===void 0&&(l=1.70158),i*(t/=r)*t*((l+1)*t-l)+e}static easeOutBack(t,e,i,r,l){return l===void 0&&(l=1.70158),i*((t=t/r-1)*t*((l+1)*t+l)+1)+e}static easeInOutBack(t,e,i,r,l){return l===void 0&&(l=1.70158),(t/=r/2)<1?i/2*(t*t*(((l*=1.525)+1)*t-l))+e:i/2*((t-=2)*t*(((l*=1.525)+1)*t+l)+2)+e}static easeInBounce(t,e,i,r){let l;return l=Pt.easeOutBounce(r-t,0,i,r),i-l+e}static easeOutBounce(t,e,i,r){return(t/=r)<.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,r){let l;return t<r/2?(l=Pt.easeInBounce(t*2,0,i,r),l*.5+e):(l=Pt.easeOutBounce(t*2-r,0,i,r),l*.5+i*.5+e)}}class It{constructor(){this.__hasCallback=!1,this._list=new he}add(t,e,i){this._list.add(new Xt(new Ze(t,e,!1,i))),this.__hasCallback=!0}addOnce(t,e){this._list.add(new Xt(new Ze(t,e,!0))),this.__hasCallback=!0}dispatch(...t){const e=this._list;let i=e.first,r;for(;i;){r=i.next;let l=!0;const c=i.data;c.callRate&&c.calls%c.callRate!=0&&(l=!1),l&&(c.callback.apply(c.scope,t),c.once&&e.remove(i)),i=r}this.__hasCallback=e.__length>0}remove(t){const e=this._list;let i=e.first,r;for(;i;){if(r=i.next,i.data.callback===t){e.remove(i);return}i=r}this.__hasCallback=e.__length>0}removeAll(){this._list.clear(),this.__hasCallback=!1}}class Ze{constructor(t,e,i,r){this.callback=t,this.scope=e,this.once=i,this.callRate=r,this.calls=0}}let Xi=class extends Xt{constructor(){super(),this.dx=0,this.dy=0,this._childEmitters=[],this._hasChildEmitters=!1,this._spawnOnHalfway=!1,this.__recycled=!0,this.__on={died:new It,bounced:new It,updated:new It},this._color=new Hi}init(t,e,i){const r=this.component,l=this.__fx;this.emitter=t,this.settings=e;const c=this.duration=st.float(e.durationMin,e.durationMax)*i;if(this._dt=1/this.duration,this.time=0,this.__recycled=!1,e.addOnTop?t.container.addChild(r):t.container.addChildAt(r,0),r.blendMode=l.__getBlendMode(e.blendMode),this.startX=r.x,this.startY=r.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=st.float(e.bounceFacMin,e.bounceFacMax)*i,this.friction=1-st.float(e.frictionMin,e.frictionMax)*i,this._spawnOnBounce=e.spawn.onBounce.length>0,this.useAlign=e.align,e.useMotion){const a=st.float(e.moveSpeedMin,e.moveSpeedMax);this.moveSpeedX=a*this.dx*i,this.moveSpeedY=a*this.dy*i}else this.moveSpeedX=this.moveSpeedY=0;else if(e.useMotion){const a=this.distance=st.integer(e.distanceMin,e.distanceMax)*.8*i;this.deltaX=(r.x+a*this.dx-this.startX)*.8,this.deltaY=(r.y+a*this.dy-this.startY)*.8,this.distanceEase=Pt[e.distanceEase],this.useAlign=!1}else r.x=this.startX,r.y=this.startY;if(e.useRotation&&e.randomStartRotation&&!this.useAlign&&(r.rotation=st.float(0,6.28319)),e.useAlpha&&(this.alphaStart=r.alpha=st.float(e.alphaStartMin,e.alphaStartMax),this.alphaDelta=st.float(e.alphaEndMin,e.alphaEndMax)-this.alphaStart,this.alphaEase=Pt[e.alphaEase]||null,this.useFadeIn=e.fadeIn,e.fadeIn&&(this.alphaDuration=c*(1-e.fadeInDurationFac),this.fadeInDuration=c*e.fadeInDurationFac,this.fadeInEase=Pt[e.fadeInEase||"easeInSine"])),e.useScale&&(this.uniformScale=e.uniformScale,this.useScaleIn=e.scaleIn,e.useScale?(this.uniformScale=e.uniformScale,this.scaleEase=Pt[e.scaleEase],e.uniformScale?(this.scaleStart=r.scale.x=r.scale.y=st.float(e.scaleStartMin,e.scaleStartMax)*i,this.scaleDelta=(st.float(e.scaleEndMin,e.scaleEndMax)-this.scaleStart)*i):(this.scaleXStart=r.scale.x=st.float(e.scaleXStartMin,e.scaleXStartMax)*i,this.scaleXDelta=(st.float(e.scaleXEndMin,e.scaleXEndMax)-this.scaleXStart)*i,this.scaleXEase=Pt[e.scaleXEase],this.scaleYStart=r.scale.y=st.float(e.scaleYStartMin,e.scaleYStartMax)*i,this.scaleYDelta=(st.float(e.scaleYEndMin,e.scaleYEndMax)-this.scaleYStart)*i,this.scaleYEase=Pt[e.scaleYEase]),e.scaleIn&&(this.scaleDuration=c*(1-e.scaleInDurationFac),this.scaleInDuration=c*e.scaleInDurationFac,this.scaleInEase=Pt[e.scaleInEase||"easeInSine"])):e.uniformScale?(r.scale.x=e.scaleStartMin,r.scale.y=e.scaleStartMin):(r.scale.x=e.scaleXStartMin,r.scale.y=e.scaleYStartMin)),e.useRotation&&(this.rotationSpeed=st.float(e.rotationSpeedMin,e.rotationSpeedMax)*i,e.randomRotationDirection&&(this.rotationSpeed*=st.sign())),e.useTint&&(this.tintEase=Pt[e.tintEase],this._color.setRgb(e.tintStart,e.tintEnd)),e.useChilds){this._childEmitters.length=0;let a=e.childs.length;if(this._hasChildEmitters=a>0,this._childEmitters)for(;--a>-1;){const g=e.childs[a],S=l.getParticleEmitterById(g.id);S.init(t.container,!0,(g.scale||1)*(i||1)),g.adoptRotation&&(S.rotation=r.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 r=this.component,l=e*t;if(this.useGravity){const c=t/.0166666;if(r.x+=this.moveSpeedX*c,r.y+=this.moveSpeedY*c,this.moveSpeedY+=this.gravity*c,this.useAlign&&(r.rotation=Math.atan2(this.moveSpeedY,this.moveSpeedX)),this.useFloor&&this.floorY>0&&r.y>this.floorY){r.y=this.floorY,this.moveSpeedY*=-this.bounceFac,this.moveSpeedX*=this.friction,this.useSpawns&&this._spawnOnBounce&&this.emitter.__subSpawn(this,this.settings.spawn.onBounce);const a=this.emitter;a.__on.particleBounced.__hasCallback&&a.__on.particleBounced.dispatch(this),this.__on.bounced.__hasCallback&&this.__on.bounced.dispatch(this),this.settings.stopOnBounce&&a.__removeParticle(this);return}}else this.useMotion&&(this.distanceEase?(r.x=this.distanceEase(e,this.startX,this.deltaX,i),r.y=this.distanceEase(e,this.startY,this.deltaY,i)):(r.x=this.deltaX*l+this.startX,r.y=this.deltaY*l+this.startY));if(this.useAlpha&&(this.useFadeIn?e<this.fadeInDuration?r.alpha=this.fadeInEase(e,0,this.alphaStart,this.fadeInDuration):r.alpha=this.alphaEase(e-this.fadeInDuration,this.alphaStart,this.alphaDelta,this.alphaDuration):this.alphaEase?r.alpha=this.alphaEase(e,this.alphaStart,this.alphaDelta,i):r.alpha=this.alphaDelta*l+this.alphaStart),this.useRotation&&(r.rotation+=this.rotationSpeed),this.useScale&&(this.uniformScale?this.useScaleIn?e<this.scaleInDuration?r.scale.x=r.scale.y=this.scaleInEase(e,0,this.scaleStart,this.scaleInDuration):r.scale.x=r.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleStart,this.scaleDelta,this.scaleDuration):this.scaleEase?(r.scale.x=this.scaleEase(e,this.scaleStart,this.scaleDelta,i),r.scale.y=this.scaleEase(e,this.scaleStart,this.scaleDelta,i)):r.scale.x=r.scale.y=this.scaleDelta*l+this.scaleStart:this.useScaleIn?e<this.scaleInDuration?(r.scale.x=this.scaleInEase(e,0,this.scaleXStart,this.scaleInDuration),r.scale.y=this.scaleInEase(e,0,this.scaleYStart,this.scaleInDuration)):(r.scale.x=this.scaleEase(e-this.scaleInDuration,this.scaleXStart,this.scaleXDelta,this.scaleDuration),r.scale.y=this.scaleEase(e-this.scaleInDuration,this.scaleYStart,this.scaleYDelta,this.scaleDuration)):(this.scaleXEase?r.scale.x=this.scaleXEase(e,this.scaleXStart,this.scaleXDelta,i):r.scale.x=this.scaleXDelta*l+this.scaleXStart,this.scaleYEase?r.scale.y=this.scaleYEase(e,this.scaleYStart,this.scaleYDelta,i):r.scale.y=this.scaleYDelta*l+this.scaleYStart)),this.useTint&&(r.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 c=this._childEmitters;let a=c.length;for(;--a>-1;){const g=c[a];g.__recycled||(g.x=r.position.x,g.y=r.position.y,g.__adoptRotation&&(g.rotation=r.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 Gt{static sanitizeBundle(t){for(let e of t.emitters){const i=Gt._presetStructure.emitter;Gt.parse(e,i,Gt._presetStructure.emitterSpawn)}for(let e of t.sequences){const i=Gt._presetStructure.sequence;Gt.parse(e,i,Gt._presetStructure.sequenceEffect)}}static parse(t,e,i){for(let r in e)if(t[r]==null)t[r]=e[r];else{const l=t[r];if(typeof l!="object")continue;const c=e[r];if(!l.hasOwnProperty("length"))Gt.parse(l,c,i);else for(let a of l)for(let g in i)a[g]==null&&(a[g]=i[g])}}}Gt._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 Qi extends Ot.Sprite{constructor(t,e,i,r){super(Ot.Texture.from(e)),this.componentId=t,this.anchor.set(i||.5,r||.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 Qt(n){if(typeof n!="object"||n===null)return n;const t=Array.isArray(n)?[]:{};for(const e in n){const i=n[e];t[e]=Qt(i)}return t}var Zi=function(n,t,e,i){function r(l){return l instanceof e?l:new e(function(c){c(l)})}return new(e||(e=Promise))(function(l,c){function a(w){try{S(i.next(w))}catch(C){c(C)}}function g(w){try{S(i.throw(w))}catch(C){c(C)}}function S(w){w.done?l(w.value):r(w.value).then(a,g)}S((i=i.apply(n,t||[])).next())})};class Rt{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 he,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 l=this._effects.first,c;for(;l;)c=l.next,l.update(i),l=c;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="",r=[]){return new Promise((l,c)=>Zi(this,void 0,void 0,function*(){const a={rfx_spritesheet:e,rfx_bundleSettings:t};for(var g in r)a[g]=r[g];Ot.Assets.addBundle("rfx_assets",a);const S=yield Ot.Assets.loadBundle("rfx_assets");l(this.initBundle(S.rfx_bundleSettings))}))}initBundle(t,e){if(t.__h!==Rt._bundleHash)throw new Error("Invalid settings file.");if(t.__v!=Rt.settingsVersion)throw new Error("Settings version mismatch.");Gt.sanitizeBundle(t),e&&this.clearCache();for(let i in t.emitters){const r=t.emitters[i];this.addParticleEmitter(r.id,r)}for(let i in t.sequences){const r=t.sequences[i];this.addEffectSequence(r.id,r)}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 r,l=this._settingsCache.effectSequences[t];if(!l)throw new Error(`Settings not defined for '${t}'`);return i.length==0?(r=new Je(t),r.__fx=this):r=i.pop(),e&&(l=Qt(l),l.__isClone=!0),r.__applySettings(l),r}getParticleEmitter(t,e=!0,i=!1){const r=this._nameMaps.emitters[t];if(!r)throw new Error(`Settings not defined for '${t}'`);return this.getParticleEmitterById(r.id,e,i)}getParticleEmitterById(t,e=!0,i=!1){const r=this._cache.emitters;let l,c=this._settingsCache.emitters[t];if(!c)throw new Error(`Settings not defined for '${t}'`);return r.length==0?(l=new ve(t),l.__fx=this):l=r.pop(),i&&(c=Qt(c),c.__isClone=!0),l.autoRecycleOnComplete=e,l.__applySettings(c),l}createParticleEmitterFrom(t,e=!0){const i=this._cache.emitters;let r;return i.length==0?(r=new ve(t.id),r.__fx=this):r=i.pop(),r.autoRecycleOnComplete=e,r.__applySettings(t),r}createEffectSequenceEmitterFrom(t){const e=this._cache.effectSequences;let i;return e.length==0?(i=new Je(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(Ot.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 r=this._settingsCache.sprites[t];if(r==null)throw new Error(`Settings not defined for '${t}'`);const l=new Qi(t,r.texture,r.anchorX,r.anchorY);return l.__fx=this,l}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 r=this._settingsCache.mcs[t];if(r==null)throw new Error(`Settings not defined for '${t}'`);const l=new $i(t,r.textures,r.anchorX,r.anchorY);return l.__fx=this,l}return i.pop()}__getParticle(){let t=this._cache,e=t.particles;if(e.length==0){const i=new Xi;return i.__fx=this,i}return e.pop()}__getEmitterCore(t,e){let i=this._cache.cores,r=i[t];return r==null&&(r=i[t]=[]),r.length==0?new Rt.__emitterCores[t](t):r.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 Ot.BLEND_MODES===void 0&&typeof t=="number"?this.useBlendModes?Rt._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 c=t;c.values();for(const[a,g]of c)g instanceof Ot.Texture&&(i[a]=g)}else i=t;const r={},l={sprites:[],movieClips:[]};for(let c in i)if(!(e&&c.indexOf(e)==-1)&&(this.initSprite(c,{texture:c,anchorX:.5,anchorY:.5}),l.sprites.push(c),c.substr(0,3)=="mc_")){const g=c.split("_")[1];r[g]==null&&(r[g]=[]),r[g].push(c)}for(let c in r){let a=r[c];l.movieClips.push(c),this.initMovieClip(c,{textures:a,anchorX:.5,anchorY:.5})}return l}}Rt.settingsVersion=0,Rt.version="1.3.4",Rt._bundleHash="80c6df7fb0d3d898f34ce0031c037fef",Rt.ComponentType=we,Rt.EffectSequenceComponentType=zt,Rt._blendModes=["normal","add","multiply","screen"],Rt.__emitterCores={circle:qi,box:Ki,ring:Wi};var te;(function(n){n[n.ParticleEmitter=0]="ParticleEmitter",n[n.EffectSequence=1]="EffectSequence"})(te||(te={}));class ve extends Xe{constructor(t){super(t),this.targetOffset=0,this.autoRecycleOnComplete=!0,this._particles=new he,this._particleCount=0,this._childEmitters=[],this._hasChildEmitters=!1,this._paused=!1,this.__adoptRotation=!1,this.__on={started:new It,completed:new It,exhausted:new It,particleUpdated:new It,particleSpawned:new It,particleBounced:new It,particleDied:new It}}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 r=e.childs.length;if(this._hasChildEmitters=r>0,this._hasChildEmitters)for(;--r>-1;){const l=e.childs[r],c=this.settings.__isClone?i.createParticleEmitterFrom(l.settings):i.getParticleEmitterById(l.id),a=i.__containers[c.settings.containerId]||this.container;c.init(a,!0,(l.scale||1)*(this._scaleMod||1)),l.adoptRotation&&(c.rotation=this._rotation,c.__adoptRotation=!0),c.__parent=this,this._childEmitters.push(c)}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+st.float(i.spawnFrequencyMin,i.spawnFrequencyMax))):(this.exhausted=!0,this.__on.exhausted.__hasCallback&&this.__on.exhausted.dispatch(this)));let l=this._particles.first,c;for(;l;)c=l.next,l.update(t),l=c;return this}spawn(){if(this._paused)return this;const t=this.settings,e=this.__fx;let i=st.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 r=t.particleSettings,l=e.__getParticle();let c;switch(r.componentType){case 0:l.componentId=r.componentId,c=e.__getSprite(l.componentId);break;case 1:l.componentId=r.componentId,c=e.__getMovieClip(l.componentId),r.componentParams&&(c.loop=!(r.componentParams.loop==null||!r.componentParams.loop),c.animationSpeed=st.float(r.componentParams.animationSpeedMin||1,r.componentParams.animationSpeedMax||1)),c.gotoAndPlay(0);break}c.anchor.set(r.componentParams.anchorX,r.componentParams.anchorY),l.component=c,this.core.emit(l),l.init(this,r,this._scaleMod),this._particles.add(l),this._particleCount++,e.particleCount++}return this.core.step(),this._nextSpawnTime=st.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 r=this.__on;r.completed.removeAll(),r.started.removeAll(),r.exhausted.removeAll(),r.particleBounced.removeAll(),r.particleDied.removeAll(),r.particleSpawned.removeAll(),r.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 r=e[i];r.__adoptRotation&&(r.rotation=r.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 r=e.length;for(;--r>-1;){const l=e[r];let c,a;switch(l.type){case 0:c=this.settings.__isClone?i.createParticleEmitterFrom(l.settings):i.getParticleEmitterById(l.id),a=i.__containers[c.settings.containerId]||this.container,c.init(a,!0,(l.scale||1)*this._scaleMod),l.adoptRotation?(c.rotation=t.component.rotation+c.settings.rotation,c.__adoptRotation=!0):c.rotation=c.settings.rotation;break;case 1:c=this.settings.__isClone?i.createEffectSequenceEmitterFrom(l.settings):i.getEffectSequenceById(l.id),a=i.__containers[c.settings.containerId]||this.container,c.init(a,0,!0,(l.scale||1)*this._scaleMod),l.adoptRotation&&(c.rotation=t.component.rotation);break}c.x=t.component.x,c.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 l in i){const c=i[l];for(const a of c){switch(a.type){case te.ParticleEmitter:a.settings=Qt(e.__getEmitterSettings(a.id));break;case te.EffectSequence:a.settings=Qt(e.__getSequenceSettings(a.id));break}a.settings.__isClone=!0}}const r=t.childs;for(const l of r){switch(l.type){case te.ParticleEmitter:l.settings=Qt(e.__getEmitterSettings(l.id));break;case te.EffectSequence:l.settings=Qt(e.__getSequenceSettings(l.id));break}l.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 Je extends Xe{constructor(t){super(t),this._list=[],this._elements=new he,this.__on={started:new It,completed:new It,exhausted:new It,effectSpawned:new It,triggerActivated:new It}}init(t,e=0,i=!0,r=1){return this.container=t,this._scaleMod=r,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 l=this.__fx,c=this._nextEffectSettings;let a,g,S;switch(c.componentType){case zt.Sprite:a=l.__getSprite(c.componentId),S=l.__containers[c.containerId]||this.container,S.addChild(a),a.blendMode=l.__getBlendMode(c.blendMode),a.tint=c.tint,a.scale.set(st.float(c.scaleMin,c.scaleMax)*st.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=st.float(c.alphaMin,c.alphaMax),a.anchor.set(c.componentParams.anchorX,c.componentParams.anchorY),g=new Xt({component:a,endTime:e+c.duration*1e3}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+st.float(c.rotationMin,c.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(zt.Sprite,a);break;case zt.MovieClip:a=l.__getMovieClip(c.componentId),c.componentParams.loop?(a.animationSpeed=st.float(c.componentParams.animationSpeedMin||1,c.componentParams.animationSpeedMax||1),a.loop=c.componentParams.loop||!1):c.duration,a.anchor.set(c.componentParams.anchorX,c.componentParams.anchorY),a.gotoAndPlay(0),S=l.__containers[c.containerId]||this.container,S.addChild(a),a.blendMode=l.__getBlendMode(c.blendMode),a.tint=c.tint,a.scale.set(st.float(c.scaleMin,c.scaleMax)*st.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),a.alpha=st.float(c.alphaMin,c.alphaMax),g=new Xt({component:a,endTime:e+c.duration*1e3}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+st.float(c.rotationMin,c.rotationMax),this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(zt.MovieClip,a);break;case zt.Emitter:a=l.getParticleEmitterById(c.componentId),S=l.__containers[c.containerId]||this.container,a.init(S,!0,st.float(c.scaleMin,c.scaleMax)*st.float(this.settings.scaleMin,this.settings.scaleMax)*this._scaleMod),g=new Xt({component:a,endTime:a.endTime}),this._elements.add(g),a.x=this._x,a.y=this._y,a.rotation=this._rotation+a.settings.rotation,this.__on.effectSpawned.__hasCallback&&this.__on.effectSpawned.dispatch(zt.Emitter,a);break;case zt.Trigger:this.__on.triggerActivated.__hasCallback&&this.__on.triggerActivated.dispatch(c.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 r=i.first;for(;r;){if(r.update(t),e>r.data.endTime){const l=r.data.component;l instanceof ve?l.completed&&i.remove(r):(i.remove(r),l.recycle())}r=r.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 r=this.__on;r.completed.__hasCallback&&r.completed.removeAll(),r.started.__hasCallback&&r.started.removeAll(),r.exhausted.__hasCallback&&r.exhausted.removeAll(),r.effectSpawned.__hasCallback&&r.effectSpawned.removeAll(),r.triggerActivated.__hasCallback&&r.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,r;for(;i;)r=i.next,i.data.rotation=t,i=r}get x(){return this._x}set x(t){this._x=t;let i=this._elements.first,r;for(;i;)r=i.next,i.data.x=t,i=r}get y(){return this._y}set y(t){this._y=t;let i=this._elements.first,r;for(;i;)r=i.next,i.data.y=t,i=r}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 Ji(n){const{emit:t,settings:e={}}=n,{name:i}=D.useProps(n),r=new Rt;let l;return Ot.Assets.add({alias:"fx_settings",src:"/default-bundle.json"}),Ot.Assets.add({alias:"fx_spritesheet",src:"/revoltfx-spritesheet.json"}),D.tick(({deltaRatio:c})=>{r.update(c)}),D.mount(async c=>{l=c;let g={...(await Ot.Assets.load(["fx_settings","fx_spritesheet"])).fx_settings};if(e.emitters){const w=e.emitters.map((C,M)=>({...C,id:1e4+M}));g.emitters=[...g.emitters,...w]}r.initBundle(g,!0)}),D.on(t,()=>{r.getParticleEmitter(i()).init(l.componentInstance)}),D.h(D.Container)}const tr=`/**
1
+ var CanvasEnginePresets=(function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(e){var t=e.toString(16);return t.length==1?`0`+t:t}function i(e,t,n){return`#`+r(e)+r(t)+r(n)}function a(e){let{width:n,height:r,value:a,maxValue:o,backgroundColor:s,foregroundColor:c,border:l,innerMargin:u,borderRadius:d}=(0,t.useProps)(e,{backgroundColor:`#000000`,foregroundColor:`#FFFFFF`,innerMargin:0,borderRadius:0});return(0,t.h)(t.Graphics,{...e,width:n,height:r,draw(e){d()?e.roundRect(0,0,n(),r(),d()):e.rect(0,0,n(),r()),l&&e.stroke(l),e.fill(s())}},(0,t.h)(t.Graphics,{width:n,height:r,draw(e){let t=u(),s=d(),l=Math.max(0,Math.min(n()-2*t,a()/o()*(n()-2*t))),f=r()-2*t;d?e.roundRect(t,t,l,f,s):e.rect(t,t,l,f);let p=c();if(p.startsWith(`rgba`)){let[t,n,r,a]=p.match(/\d+(\.\d+)?/g).map(Number);e.fill({color:i(t,n,r),alpha:a})}else e.fill(p)}}))}var o={hitSpark:{duration:180,emitters:[{burst:18,angle:[0,360],speed:[120,340],particle:{shape:`spark`,lifetime:[160,340],color:[`#fff4a8`,`#ff7a2f`],alpha:[1,0],scale:[.18,0],rotationSpeed:[-480,480],blendMode:`add`,ease:`outCubic`}}]},slashSpark:{duration:160,emitters:[{burst:22,angle:[-12,12],speed:[180,430],spreadX:10,spreadY:3,particle:{shape:`spark`,lifetime:[110,260],color:[`#ffffff`,`#ffcf5a`],alpha:[1,0],scale:[.16,0],rotation:[-8,8],rotationSpeed:[-260,260],blendMode:`add`,ease:`outCubic`}},{burst:8,angle:[150,210],speed:[60,160],particle:{shape:`star`,lifetime:[140,320],color:[`#fff8cc`,`#ff8f3d`],alpha:[.85,0],scale:[.12,.4],blendMode:`add`,ease:`outQuad`}}]},impactBurst:{duration:260,emitters:[{burst:24,angle:[0,360],speed:[130,280],particle:{shape:`spark`,lifetime:[180,420],color:[`#fff3ba`,`#d64d27`],alpha:[1,0],scale:[.2,0],rotationSpeed:[-360,360],blendMode:`add`,ease:`outCubic`}},{burst:10,angle:[0,360],speed:[30,90],particle:{shape:`softCircle`,lifetime:[220,520],color:[`#ffd18a`,`#6d3a2a`],alpha:[.38,0],scale:[.28,1.15],ease:`outQuad`}}]},smokePuff:{duration:260,emitters:[{burst:16,angle:[-130,-50],speed:[12,58],spreadX:10,spreadY:6,gravity:-10,particle:{shape:`softCircle`,lifetime:[520,940],color:[`#8f8f8f`,`#4f4f4f`],alpha:[.38,0],scale:[.45,1.85],rotationSpeed:[-40,40],ease:`outQuad`}}]},dustStep:{duration:160,emitters:[{burst:10,angle:[-170,-10],speed:[18,86],spreadX:8,spreadY:3,particle:{shape:`softCircle`,lifetime:[260,520],color:`#b99a6a`,alpha:[.26,0],scale:[.22,.9],ease:`outQuad`}}]},dashDust:{duration:220,emitters:[{burst:22,angle:[155,205],speed:[70,190],spreadX:18,spreadY:5,particle:{shape:`softCircle`,lifetime:[300,640],color:[`#cfb07c`,`#8f744f`],alpha:[.34,0],scale:[.28,1.2],ease:`outCubic`}},{burst:9,angle:[168,192],speed:[150,330],spreadX:10,particle:{shape:`spark`,lifetime:[120,280],color:`#d9c08a`,alpha:[.42,0],scale:[.12,0],ease:`outCubic`}}]},magicBurst:{duration:360,emitters:[{burst:32,angle:[0,360],speed:[70,220],particle:{shape:`star`,lifetime:[420,840],color:[`#77e5ff`,`#b970ff`],alpha:[.95,0],scale:[.18,.75],rotationSpeed:[-220,220],blendMode:`add`,ease:`outCubic`}}]},healPulse:{duration:520,emitters:[{burst:18,angle:[-120,-60],speed:[28,86],spreadX:20,spreadY:10,gravity:-16,particle:{shape:`star`,lifetime:[520,980],color:[`#d9ffe6`,`#55e68a`],alpha:[.85,0],scale:[.18,.62],rotationSpeed:[-120,120],blendMode:`add`,ease:`outQuad`}},{burst:10,angle:[-105,-75],speed:[12,42],spreadX:16,particle:{shape:`softCircle`,lifetime:[620,1100],color:[`#9fffc5`,`#3edc7c`],alpha:[.3,0],scale:[.3,1],blendMode:`add`,ease:`outQuad`}}]},campfire:{duration:1e3,emitters:[{loop:!0,rate:38,angle:[-110,-70],speed:[16,54],spreadX:8,spreadY:3,particle:{shape:`softCircle`,lifetime:[360,720],color:[`#ffd36d`,`#ff4b1f`],alpha:[.8,0],scale:[.25,1.05],blendMode:`add`,ease:`outQuad`}},{loop:!0,rate:12,angle:[-115,-65],speed:[10,30],particle:{shape:`softCircle`,lifetime:[620,1100],color:`#555555`,alpha:[.18,0],scale:[.35,1.4],ease:`outQuad`}}]},torchFire:{duration:1e3,emitters:[{loop:!0,rate:24,angle:[-104,-76],speed:[12,42],spreadX:4,spreadY:2,particle:{shape:`softCircle`,lifetime:[280,560],color:[`#fff09a`,`#ff5a22`],alpha:[.75,0],scale:[.16,.72],blendMode:`add`,ease:`outQuad`}},{loop:!0,rate:7,angle:[-112,-68],speed:[8,26],particle:{shape:`softCircle`,lifetime:[520,960],color:`#4f4f4f`,alpha:[.13,0],scale:[.22,.9],ease:`outQuad`}}]},pickup:{duration:320,emitters:[{burst:14,angle:[210,330],speed:[70,170],particle:{shape:`star`,lifetime:[260,620],color:[`#ffffff`,`#ffe66d`],alpha:[1,0],scale:[.2,.65],blendMode:`add`,ease:`outCubic`}}]},levelUp:{duration:820,emitters:[{burst:30,angle:[-105,-75],speed:[80,210],spreadX:34,spreadY:10,gravity:-24,particle:{shape:`star`,lifetime:[620,1180],color:[`#ffffff`,`#ffe870`],alpha:[1,0],scale:[.16,.8],rotationSpeed:[-180,180],blendMode:`add`,ease:`outCubic`}},{duration:420,rate:36,angle:[-98,-82],speed:[90,180],spreadX:26,particle:{shape:`spark`,lifetime:[420,840],color:[`#fff8c8`,`#66d9ff`],alpha:[.75,0],scale:[.12,0],blendMode:`add`,ease:`outCubic`}}]},explosionSmall:{duration:280,emitters:[{burst:28,angle:[0,360],speed:[120,300],particle:{shape:`softCircle`,lifetime:[300,720],color:[`#fff1a6`,`#d34b24`],alpha:[1,0],scale:[.25,1.15],blendMode:`add`,ease:`outCubic`}}]}},s=new Map,c=new Map;function l(e=`softCircle`){return s.has(e)||s.set(e,u(e)),s.get(e)}function u(e){if(typeof document>`u`)return n.Texture.WHITE;let t=document.createElement(`canvas`);t.width=e===`spark`?64:48,t.height=e===`spark`?16:48;let r=t.getContext(`2d`);if(!r)return n.Texture.WHITE;if(r.clearRect(0,0,t.width,t.height),r.fillStyle=`#ffffff`,r.strokeStyle=`#ffffff`,e===`spark`){let e=r.createLinearGradient(0,0,t.width,0);e.addColorStop(0,`rgba(255,255,255,0)`),e.addColorStop(.22,`rgba(255,255,255,1)`),e.addColorStop(1,`rgba(255,255,255,0)`),r.strokeStyle=e,r.lineWidth=4,r.lineCap=`round`,r.beginPath(),r.moveTo(3,t.height/2),r.lineTo(t.width-3,t.height/2),r.stroke()}else if(e===`square`)r.fillRect(8,8,32,32);else if(e===`star`)d(r,24,24,5,20,8);else if(e===`circle`)r.beginPath(),r.arc(24,24,18,0,Math.PI*2),r.fill();else{let e=r.createRadialGradient(24,24,2,24,24,22);e.addColorStop(0,`rgba(255,255,255,1)`),e.addColorStop(.45,`rgba(255,255,255,0.72)`),e.addColorStop(1,`rgba(255,255,255,0)`),r.fillStyle=e,r.fillRect(0,0,t.width,t.height)}return n.Texture.from(t)}function d(e,t,n,r,i,a){e.beginPath();for(let o=0;o<r*2;o++){let s=o%2==0?i:a,c=o*Math.PI/r-Math.PI/2,l=t+Math.cos(c)*s,u=n+Math.sin(c)*s;o===0?e.moveTo(l,u):e.lineTo(l,u)}e.closePath(),e.fill()}async function f(e={}){let t=[];if(e.image&&!c.has(e.image)){let r=n.Assets.load(e.image);c.set(e.image,r),t.push(r.then(t=>{c.set(e.image,t)}))}e.spritesheet&&t.push(Promise.resolve(n.Assets.load(e.spritesheet))),await Promise.all(t)}async function p(e){await Promise.all((e?.emitters??[]).map(e=>f(e.particle)))}function m(e={},t=Math.random){if(e.texture)return[e.texture];if(e.frames?.length){let r=e.frames.map(e=>n.Texture.from(e));return e.frameMode===`random`?[r[Math.floor(t()*r.length)]??r[0]]:r}if(e.frame)return[n.Texture.from(e.frame)];if(e.image){let t=c.get(e.image);return t&&!(t instanceof Promise)?[t]:[]}return[l(e.shape)]}function h(e=Date.now()){let t=e>>>0;return()=>(t=t*1664525+1013904223>>>0,t/4294967296)}function g(e,t,n){return e===void 0?n:Array.isArray(e)?e[0]+(e[1]-e[0])*t():e}function _(e,t){return g(e,t,0)*Math.PI/180}function v(e,t=16777215){if(e===void 0)return t;if(typeof e==`number`)return e;let n=e.trim().replace(`#`,``);return n.length===3?parseInt(n.split(``).map(e=>e+e).join(``),16):parseInt(n,16)}function y(e,t,n){return e+(t-e)*n}function b(e,t,n){let r=e>>16&255,i=e>>8&255,a=e&255,o=t>>16&255,s=t>>8&255,c=t&255,l=Math.round(y(r,o,n)),u=Math.round(y(i,s,n)),d=Math.round(y(a,c,n));return(l<<16)+(u<<8)+d}function x(e,t){let n=Math.max(0,Math.min(1,t));return e===`outQuad`?1-(1-n)*(1-n):e===`outCubic`?1-(1-n)**3:e===`inQuad`?n*n:n}var S=class{constructor(e={}){this.instances=new Set,this.pool=[],this.activeCount=0,this.random=h(e.seed),this.maxParticles=e.maxParticles??600}async preload(e){await p(e)}spawn(e,t,n={}){let r={container:e,preset:t,elapsed:0,loop:!!n.loop,complete:!1,activeParticles:0,emitters:t.emitters.map(e=>({...e,elapsed:0,emittedBurst:!1,carry:0,particles:[]})),options:n,stop:()=>{r.loop=!1,r.complete=!0,r.emitters.forEach(e=>{e.duration=0,e.loop=!1})}};return this.instances.add(r),n.onStart?.(r),r}update(e){let t=Number.isFinite(e)?Math.max(0,e):0;for(let e of Array.from(this.instances))this.updateInstance(e,t)}clear(){for(let e of Array.from(this.instances))this.recycleInstance(e);this.instances.clear()}get activeInstances(){return this.instances.size}updateInstance(e,t){e.elapsed+=t;let n=e.preset.delay??0;if(e.elapsed<n)return;let r=!1,i=!1;for(let n of e.emitters)this.updateEmitter(e,n,t),r||=n.particles.length>0,i||=this.isEmitterActive(e,n);e.activeParticles=e.emitters.reduce((e,t)=>e+t.particles.length,0),!i&&!r&&(e.complete=!0),e.complete&&!r&&(this.instances.delete(e),e.options.onComplete?.(e))}updateEmitter(e,t,n){t.elapsed+=n;let r=t.delay??0;if(t.elapsed>=r&&this.isEmitterActive(e,t)){if(t.burst&&!t.emittedBurst){for(let n=0;n<t.burst;n++)this.spawnParticle(e,t);t.emittedBurst=!0}if(t.rate){t.carry+=t.rate*n/1e3;let r=Math.floor(t.carry);t.carry-=r;for(let n=0;n<r;n++)this.spawnParticle(e,t)}}for(let r=t.particles.length-1;r>=0;r--){let i=t.particles[r];i.age+=n,i.age>=i.lifetime?(this.recycleParticle(e.container,i),t.particles.splice(r,1)):this.updateParticle(i,n)}}isEmitterActive(e,t){if(e.complete)return!1;let n=t.delay??0,r=t.elapsed-n;return r<0?!1:t.burst&&!t.emittedBurst||e.loop||t.loop?!0:r<=(t.duration??e.preset.duration??0)}spawnParticle(e,t){let r=t.maxParticles??e.options.maxParticles??this.maxParticles;if(this.activeCount>=r||t.particles.length>=r)return;let i=t.particle??{},a=m(i,this.random);if(!a.length){if(e.options.missingTexture===`skip`)return;if(e.options.missingTexture===`error`)throw Error(`Fx particle texture is not loaded`);a.push(l(i.shape))}let o=this.pool.pop()??new n.Sprite(n.Texture.WHITE);o.texture=a[0],o.visible=!0,o.anchor.set(i.anchor?.x??.5,i.anchor?.y??.5),o.x=(t.x??0)+g([-(t.spreadX??0),t.spreadX??0],this.random,0),o.y=(t.y??0)+g([-(t.spreadY??0),t.spreadY??0],this.random,0),o.rotation=g(i.rotation,this.random,0)*Math.PI/180,o.blendMode=i.blendMode??`normal`;let s=_(t.angle,this.random),c=g(t.speed,this.random,0),u=i.alpha??[1,0],d=i.scale??[1,0],f=i.tint??i.color??16777215,p=v(Array.isArray(f)?f[0]:f),h=v(Array.isArray(f)?f[1]:f,p),y=g(Array.isArray(d)?d[0]:d,this.random,1),b=Array.isArray(d)?g(d[1],this.random,0):y,x=g(Array.isArray(u)?u[0]:u,this.random,1),S=Array.isArray(u)?g(u[1],this.random,0):x;o.alpha=x,o.tint=p,o.scale.set(y),e.container.addChild(o);let C={sprite:o,age:0,lifetime:g(i.lifetime,this.random,600),vx:Math.cos(s)*c,vy:Math.sin(s)*c,ax:t.accelerationX??0,ay:t.accelerationY??0,gravity:t.gravity??0,startAlpha:x,endAlpha:S,startScale:y,endScale:b,startTint:p,endTint:h,rotationSpeed:g(i.rotationSpeed,this.random,0)*Math.PI/180,frameRate:i.frameRate??12,frames:a,ease:i.ease??`linear`};t.particles.push(C),this.activeCount++,e.options.onParticleSpawn?.(C)}updateParticle(e,t){let n=t/1e3,r=e.age/e.lifetime,i=x(e.ease,r);if(e.vx+=e.ax*n,e.vy+=(e.ay+e.gravity)*n,e.sprite.x+=e.vx*n,e.sprite.y+=e.vy*n,e.sprite.rotation+=e.rotationSpeed*n,e.sprite.alpha=y(e.startAlpha,e.endAlpha,i),e.sprite.scale.set(y(e.startScale,e.endScale,i)),e.sprite.tint=b(e.startTint,e.endTint,i),e.frames.length>1){let t=Math.min(e.frames.length-1,Math.floor(e.age/1e3*e.frameRate)%e.frames.length);e.sprite.texture=e.frames[t]}}recycleParticle(e,t){e.removeChild(t.sprite),t.sprite.visible=!1,t.sprite.alpha=1,t.sprite.tint=16777215,t.sprite.scale.set(1),this.pool.push(t.sprite),this.activeCount=Math.max(0,this.activeCount-1)}recycleInstance(e){for(let t of e.emitters){for(let n of t.particles)this.recycleParticle(e.container,n);t.particles=[]}}},C=e=>typeof e==`function`?e():e;function w(e,t){let n=C(t);if(n)return n;let r=C(e),i=o[r];if(!i)throw Error(`Unknown Fx preset: ${r}`);return i}function T(e){let{name:n,preset:r,trigger:i,autostart:a,loop:o,enabled:s,x:c,y:l,rotation:u,scale:d,alpha:f,seed:p,maxParticles:m,timeScale:h,preload:g,missingTexture:_,onStart:v,onComplete:y,onParticleSpawn:b,...x}=(0,t.useProps)(e,{name:`hitSpark`,autostart:!1,loop:!1,enabled:!0,x:0,y:0,rotation:0,scale:1,alpha:1,timeScale:1,preload:!0,missingTexture:`shape`}),T,E=new S({seed:C(p),maxParticles:C(m)}),D=async(e={})=>{if(!T||!C(s))return;let t=w(n,r);return C(g)&&await E.preload(t),E.spawn(T,t,{loop:C(o),seed:C(p),maxParticles:C(m),missingTexture:C(_),onStart:v,onComplete:y,onParticleSpawn:b,...e})};return(0,t.mount)(e=>(T=e.componentInstance,(C(a)||C(o))&&D(),()=>{E.clear()})),i?.listen&&(0,t.on)(i,async e=>{await D(e)}),(0,t.tick)(({deltaTime:e})=>{E.update((e??16.67)*C(h))}),(0,t.h)(t.Container,{...x,x:c,y:l,rotation:u,scale:d,alpha:f})}function E(e){let{emit:t,...n}=e;return T({...n,trigger:n.trigger??t})}var D=`/**
2
2
  * Night + spot light + fog fragment shader.
3
3
  * - Supports multiple circular spots (uSpots) in screen-pixel space.
4
4
  * - Each spot is vec4(xPx, yPx, radiusPx, intensity).
@@ -57,7 +57,7 @@ void main() {
57
57
 
58
58
  finalColor = color;
59
59
  }
60
- `,ti=`/**
60
+ `,O=`/**
61
61
  * Default Pixi filter vertex shader.
62
62
  * Outputs vTextureCoord (0-1) for sampling the input texture in fragment shader.
63
63
  */
@@ -83,19 +83,19 @@ void main(void) {
83
83
  gl_Position = filterVertexPosition();
84
84
  vTextureCoord = filterTextureCoord();
85
85
  }
86
- `,be=24,er=180,ir=.75,rr=.5,nr=.35,sr=new Float32Array([.08,.08,.14]),fe=n=>{if(typeof n=="string"){let t=n.replace(/^#/,"");t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);const e=parseInt(t,16);return new Float32Array([(e>>16&255)/255,(e>>8&255)/255,(e&255)/255])}if(typeof n=="number")return new Float32Array([(n>>16&255)/255,(n>>8&255)/255,(n&255)/255]);if(Array.isArray(n)&&n.length>=3){const t=n.every(e=>e<=1);return new Float32Array(t?n:n.map(e=>e/255))}return new Float32Array([0,0,0])};function ei(n,t){const e=new Float32Array(be*4),i={value:e,type:"vec4<f32>",size:be},r={value:t?.darkness??ir,type:"f32"},l={value:t?.fogColor?fe(t.fogColor):sr,type:"vec3<f32>"},c={value:t?.fogRadius??rr,type:"f32"},a={value:t?.fogSoftness??nr,type:"f32"},g={value:t?.darkColor?fe(t.darkColor):new Float32Array([0,0,0]),type:"vec3<f32>"};let S=t?.spots?[...t.spots]:[],w=t?.lightWorldPosition??null;const C=L.Filter.from({gl:{vertex:ti,fragment:tr},resources:{nightUniforms:{uSpots:i,uDarkness:r,uDarkColor:g,uFogColor:l,uFogRadius:c,uFogSoftness:a}}}),M=(x,y,f)=>Math.min(Math.max(x,y),f),N=()=>Date.now()/1e3,F=()=>w?[{x:w.x,y:w.y},...S]:S,k=()=>{const x=F(),y=Math.min(x.length,be),f=n?.getVisibleBounds?.()??t?.getBounds?.(),A=!!f&&f.width>0&&f.height>0,P=n?.toScreen?.bind(n),I=A&&typeof P=="function";let O=0,_=0;if(I){const V=P(f.x,f.y);Ft(V?.x)&&Ft(V?.y)&&(O=V.x,_=V.y)}const U=N();e.fill(0);for(let V=0;V<y;V++){const z=x[V],K=z.radius??er,et=M(z.intensity??1,0,2),Q=z.phase??V*.7;let W=et;if(z.flicker){const H=z.flickerSpeed??12;W*=.88+.12*Math.sin(U*H+Q)}if(z.pulse){const H=z.pulseSpeed??2;W*=.8+.2*Math.sin(U*H+Q)}let Y=z.x,Z=z.y,yt=K;if(I){const H=P(z.x,z.y);Y=H.x-O,Z=H.y-_}else A&&(Y=z.x-f.x,Z=z.y-f.y);const ct=V*4;e[ct]=Y,e[ct+1]=Z,e[ct+2]=yt,e[ct+3]=M(W,0,2)}i.value=e},R=C.apply.bind(C);C.apply=((...x)=>(k(),R(...x)));const m=C;return m.setLightWorldPosition=x=>{w=x,k()},m.getLightWorldPosition=()=>w,m.setSpots=x=>{S=[...x],k()},m.getSpots=()=>F().map(x=>({...x})),m.syncLightToViewport=k,m.setDarkness=x=>{r.value=x},m.setDarkColor=x=>{g.value=fe(x)},m.setFogColor=x=>{l.value=fe(x)},m.setFogRadius=x=>{c.value=x},m.setFogSoftness=x=>{a.value=x},k(),m}const Tt=n=>typeof n=="function"?n():n,Ft=n=>typeof n=="number"&&Number.isFinite(n),or=n=>{const t=Tt(n);if(!t)return null;const e=Tt(t.x),i=Tt(t.y);if(!Ft(e)||!Ft(i))return null;const r=Tt(t.radius),l=Tt(t.intensity),c=Tt(t.flickerSpeed),a=Tt(t.pulseSpeed),g=Tt(t.phase);return{x:e,y:i,radius:Ft(r)?r:void 0,intensity:Ft(l)?l:void 0,flicker:!!Tt(t.flicker),flickerSpeed:Ft(c)?c:void 0,pulse:!!Tt(t.pulse),pulseSpeed:Ft(a)?a:void 0,phase:Ft(g)?g:void 0}},ii=n=>{const t=Tt(n);return Array.isArray(t)?t.map(or).filter(e=>!!e):[]},ar=n=>{if(!n)return null;if(typeof n.getVisibleBounds=="function"){const t=n.getVisibleBounds();if(t)return t}if(typeof n.getLocalBounds=="function"){const t=n.getLocalBounds();if(t)return t}return Ft(n.width)&&Ft(n.height)?{x:0,y:0,width:n.width,height:n.height}:null};function lr(n={}){const t=D.useProps(n),e=()=>t.lightSpots??t.spots;return D.mount(i=>{const r=i.props.context,l=r?.viewport,c=l??i.parent?.componentInstance;if(!c)return;const a=r?.canvasSize,g=()=>{if(!l&&typeof a=="function"){const R=a();if(R&&Ft(R.width)&&Ft(R.height)&&R.width>0&&R.height>0)return{x:0,y:0,width:R.width,height:R.height}}return ar(c)},S=Tt(t.darkness),w=Tt(t.darkColor),C=Tt(t.fogColor),M=Tt(t.fogRadius),N=Tt(t.fogSoftness),F=ei(l,{spots:ii(e()),getBounds:g,darkness:Ft(S)?S:void 0,darkColor:w??void 0,fogColor:C??void 0,fogRadius:Ft(M)?M:void 0,fogSoftness:Ft(N)?N:void 0}),k=Array.isArray(c.filters)?c.filters:[];return k.includes(F)||(c.filters=[...k,F]),D.effect(()=>{F.setSpots(ii(e()))}),D.effect(()=>{const R=Tt(t.darkness);Ft(R)&&F.setDarkness(R)}),D.effect(()=>{const R=Tt(t.darkColor);R!==void 0&&F.setDarkColor(R)}),D.effect(()=>{const R=Tt(t.fogColor);R!==void 0&&F.setFogColor(R)}),D.effect(()=>{const R=Tt(t.fogRadius);Ft(R)&&F.setFogRadius(R)}),D.effect(()=>{const R=Tt(t.fogSoftness);Ft(R)&&F.setFogSoftness(R)}),()=>{const m=(Array.isArray(c.filters)?c.filters:[]).filter(x=>x!==F);c.filters=m.length>0?m:null}}),D.h(D.Container)}function cr(n={}){const{size:t=30,color:e="#3498db",backgroundColor:i,speed:r=180,segments:l=8,segmentWidth:c=3,inactiveAlpha:a=.15}=D.useProps(n,{size:30,color:"#3498db",speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),g=D.signal(0);D.tick(({deltaTime:F})=>{const R=(typeof r=="function"?r():r)*F/1e3;g.set(g()+R)});const S=F=>{const k=typeof t=="function"?t():t,R=typeof e=="function"?e():e,m=i?typeof i=="function"?i():i:null,x=typeof l=="function"?l():l;typeof c=="function"&&c();const y=typeof a=="function"?a():a,f=g();m&&F.circle(0,0,k).fill(m);const A=360/x,P=k*.4,I=k;for(let O=0;O<x;O++){const _=O*A,U=(f%360+360)%360;let V=Math.abs(U-_);V>180&&(V=360-V);let K=V/120;K=Math.min(1,K),K=K*K*K;const et=y+(1-K)*(1-y),Q=_*(Math.PI/180),W=A*(Math.PI/180),Y=Q-W/2,Z=Q+W/2;F.arc(0,0,P,Y,Z).arc(0,0,I,Z,Y,!0).fill({color:R,alpha:et})}},C=(typeof t=="function"?t():t)*2,M=D.signal(C),N=D.signal(C);return typeof t=="function"&&D.effect(()=>{const F=t();M.set(F*2),N.set(F*2)}),D.h(D.Container,n,[D.h(D.Graphics,{draw:S})])}var ee=(n=>(n.Tile="tilelayer",n.ObjectGroup="objectgroup",n.Image="imagelayer",n.Group="group",n))(ee||{});function ri(...n){return n.filter(t=>t&&t.length>0).join("/").replace(/\/+/g,"/")}function ur(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var t=n.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(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),e}var Se={};const hr=ur(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ae={},de={exports:{}},Te={},ne={},ni;function fr(){if(ni)return ne;ni=1,ne.byteLength=a,ne.toByteArray=S,ne.fromByteArray=M;for(var n=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,l=i.length;r<l;++r)n[r]=i[r],t[i.charCodeAt(r)]=r;t[45]=62,t[95]=63;function c(N){var F=N.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=N.indexOf("=");k===-1&&(k=F);var R=k===F?0:4-k%4;return[k,R]}function a(N){var F=c(N),k=F[0],R=F[1];return(k+R)*3/4-R}function g(N,F,k){return(F+k)*3/4-k}function S(N){var F,k=c(N),R=k[0],m=k[1],x=new e(g(N,R,m)),y=0,f=m>0?R-4:R,A;for(A=0;A<f;A+=4)F=t[N.charCodeAt(A)]<<18|t[N.charCodeAt(A+1)]<<12|t[N.charCodeAt(A+2)]<<6|t[N.charCodeAt(A+3)],x[y++]=F>>16&255,x[y++]=F>>8&255,x[y++]=F&255;return m===2&&(F=t[N.charCodeAt(A)]<<2|t[N.charCodeAt(A+1)]>>4,x[y++]=F&255),m===1&&(F=t[N.charCodeAt(A)]<<10|t[N.charCodeAt(A+1)]<<4|t[N.charCodeAt(A+2)]>>2,x[y++]=F>>8&255,x[y++]=F&255),x}function w(N){return n[N>>18&63]+n[N>>12&63]+n[N>>6&63]+n[N&63]}function C(N,F,k){for(var R,m=[],x=F;x<k;x+=3)R=(N[x]<<16&16711680)+(N[x+1]<<8&65280)+(N[x+2]&255),m.push(w(R));return m.join("")}function M(N){for(var F,k=N.length,R=k%3,m=[],x=16383,y=0,f=k-R;y<f;y+=x)m.push(C(N,y,y+x>f?f:y+x));return R===1?(F=N[k-1],m.push(n[F>>2]+n[F<<4&63]+"==")):R===2&&(F=(N[k-2]<<8)+N[k-1],m.push(n[F>>10]+n[F>>4&63]+n[F<<2&63]+"=")),m.join("")}return ne}var pe={};var si;function dr(){return si||(si=1,pe.read=function(n,t,e,i,r){var l,c,a=r*8-i-1,g=(1<<a)-1,S=g>>1,w=-7,C=e?r-1:0,M=e?-1:1,N=n[t+C];for(C+=M,l=N&(1<<-w)-1,N>>=-w,w+=a;w>0;l=l*256+n[t+C],C+=M,w-=8);for(c=l&(1<<-w)-1,l>>=-w,w+=i;w>0;c=c*256+n[t+C],C+=M,w-=8);if(l===0)l=1-S;else{if(l===g)return c?NaN:(N?-1:1)*(1/0);c=c+Math.pow(2,i),l=l-S}return(N?-1:1)*c*Math.pow(2,l-i)},pe.write=function(n,t,e,i,r,l){var c,a,g,S=l*8-r-1,w=(1<<S)-1,C=w>>1,M=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=i?0:l-1,F=i?1:-1,k=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,c=w):(c=Math.floor(Math.log(t)/Math.LN2),t*(g=Math.pow(2,-c))<1&&(c--,g*=2),c+C>=1?t+=M/g:t+=M*Math.pow(2,1-C),t*g>=2&&(c++,g/=2),c+C>=w?(a=0,c=w):c+C>=1?(a=(t*g-1)*Math.pow(2,r),c=c+C):(a=t*Math.pow(2,C-1)*Math.pow(2,r),c=0));r>=8;n[e+N]=a&255,N+=F,a/=256,r-=8);for(c=c<<r|a,S+=r;S>0;n[e+N]=c&255,N+=F,c/=256,S-=8);n[e+N-F]|=k*128}),pe}var oi;function ai(){return oi||(oi=1,(function(n){const t=fr(),e=dr(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=x,n.INSPECT_MAX_BYTES=50;const r=2147483647;n.kMaxLength=r,a.TYPED_ARRAY_SUPPORT=l(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const h=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(h,s),h.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function c(h){if(h>r)throw new RangeError('The value "'+h+'" is invalid for option "size"');const s=new Uint8Array(h);return Object.setPrototypeOf(s,a.prototype),s}function a(h,s,o){if(typeof h=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return C(h)}return g(h,s,o)}a.poolSize=8192;function g(h,s,o){if(typeof h=="string")return M(h,s);if(ArrayBuffer.isView(h))return F(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(Et(h,ArrayBuffer)||h&&Et(h.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Et(h,SharedArrayBuffer)||h&&Et(h.buffer,SharedArrayBuffer)))return k(h,s,o);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const p=h.valueOf&&h.valueOf();if(p!=null&&p!==h)return a.from(p,s,o);const v=R(h);if(v)return v;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return a.from(h[Symbol.toPrimitive]("string"),s,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}a.from=function(h,s,o){return g(h,s,o)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function S(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function w(h,s,o){return S(h),h<=0?c(h):s!==void 0?typeof o=="string"?c(h).fill(s,o):c(h).fill(s):c(h)}a.alloc=function(h,s,o){return w(h,s,o)};function C(h){return S(h),c(h<0?0:m(h)|0)}a.allocUnsafe=function(h){return C(h)},a.allocUnsafeSlow=function(h){return C(h)};function M(h,s){if((typeof s!="string"||s==="")&&(s="utf8"),!a.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const o=y(h,s)|0;let p=c(o);const v=p.write(h,s);return v!==o&&(p=p.slice(0,v)),p}function N(h){const s=h.length<0?0:m(h.length)|0,o=c(s);for(let p=0;p<s;p+=1)o[p]=h[p]&255;return o}function F(h){if(Et(h,Uint8Array)){const s=new Uint8Array(h);return k(s.buffer,s.byteOffset,s.byteLength)}return N(h)}function k(h,s,o){if(s<0||h.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<s+(o||0))throw new RangeError('"length" is outside of buffer bounds');let p;return s===void 0&&o===void 0?p=new Uint8Array(h):o===void 0?p=new Uint8Array(h,s):p=new Uint8Array(h,s,o),Object.setPrototypeOf(p,a.prototype),p}function R(h){if(a.isBuffer(h)){const s=m(h.length)|0,o=c(s);return o.length===0||h.copy(o,0,0,s),o}if(h.length!==void 0)return typeof h.length!="number"||Kt(h.length)?c(0):N(h);if(h.type==="Buffer"&&Array.isArray(h.data))return N(h.data)}function m(h){if(h>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return h|0}function x(h){return+h!=h&&(h=0),a.alloc(+h)}a.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==a.prototype},a.compare=function(s,o){if(Et(s,Uint8Array)&&(s=a.from(s,s.offset,s.byteLength)),Et(o,Uint8Array)&&(o=a.from(o,o.offset,o.byteLength)),!a.isBuffer(s)||!a.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===o)return 0;let p=s.length,v=o.length;for(let b=0,T=Math.min(p,v);b<T;++b)if(s[b]!==o[b]){p=s[b],v=o[b];break}return p<v?-1:v<p?1:0},a.isEncoding=function(s){switch(String(s).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(s,o){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return a.alloc(0);let p;if(o===void 0)for(o=0,p=0;p<s.length;++p)o+=s[p].length;const v=a.allocUnsafe(o);let b=0;for(p=0;p<s.length;++p){let T=s[p];if(Et(T,Uint8Array))b+T.length>v.length?(a.isBuffer(T)||(T=a.from(T)),T.copy(v,b)):Uint8Array.prototype.set.call(v,T,b);else if(a.isBuffer(T))T.copy(v,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=T.length}return v};function y(h,s){if(a.isBuffer(h))return h.length;if(ArrayBuffer.isView(h)||Et(h,ArrayBuffer))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const o=h.length,p=arguments.length>2&&arguments[2]===!0;if(!p&&o===0)return 0;let v=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return q(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return wt(h).length;default:if(v)return p?-1:q(h).length;s=(""+s).toLowerCase(),v=!0}}a.byteLength=y;function f(h,s,o){let p=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,s>>>=0,o<=s))return"";for(h||(h="utf8");;)switch(h){case"hex":return yt(this,s,o);case"utf8":case"utf-8":return et(this,s,o);case"ascii":return Y(this,s,o);case"latin1":case"binary":return Z(this,s,o);case"base64":return K(this,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ct(this,s,o);default:if(p)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),p=!0}}a.prototype._isBuffer=!0;function A(h,s,o){const p=h[s];h[s]=h[o],h[o]=p}a.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<s;o+=2)A(this,o,o+1);return this},a.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<s;o+=4)A(this,o,o+3),A(this,o+1,o+2);return this},a.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<s;o+=8)A(this,o,o+7),A(this,o+1,o+6),A(this,o+2,o+5),A(this,o+3,o+4);return this},a.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?et(this,0,s):f.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(s){if(!a.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:a.compare(this,s)===0},a.prototype.inspect=function(){let s="";const o=n.INSPECT_MAX_BYTES;return s=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(s+=" ... "),"<Buffer "+s+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(s,o,p,v,b){if(Et(s,Uint8Array)&&(s=a.from(s,s.offset,s.byteLength)),!a.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(o===void 0&&(o=0),p===void 0&&(p=s?s.length:0),v===void 0&&(v=0),b===void 0&&(b=this.length),o<0||p>s.length||v<0||b>this.length)throw new RangeError("out of range index");if(v>=b&&o>=p)return 0;if(v>=b)return-1;if(o>=p)return 1;if(o>>>=0,p>>>=0,v>>>=0,b>>>=0,this===s)return 0;let T=b-v,$=p-o;const at=Math.min(T,$),lt=this.slice(v,b),dt=s.slice(o,p);for(let ht=0;ht<at;++ht)if(lt[ht]!==dt[ht]){T=lt[ht],$=dt[ht];break}return T<$?-1:$<T?1:0};function P(h,s,o,p,v){if(h.length===0)return-1;if(typeof o=="string"?(p=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Kt(o)&&(o=v?0:h.length-1),o<0&&(o=h.length+o),o>=h.length){if(v)return-1;o=h.length-1}else if(o<0)if(v)o=0;else return-1;if(typeof s=="string"&&(s=a.from(s,p)),a.isBuffer(s))return s.length===0?-1:I(h,s,o,p,v);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?v?Uint8Array.prototype.indexOf.call(h,s,o):Uint8Array.prototype.lastIndexOf.call(h,s,o):I(h,[s],o,p,v);throw new TypeError("val must be string, number or Buffer")}function I(h,s,o,p,v){let b=1,T=h.length,$=s.length;if(p!==void 0&&(p=String(p).toLowerCase(),p==="ucs2"||p==="ucs-2"||p==="utf16le"||p==="utf-16le")){if(h.length<2||s.length<2)return-1;b=2,T/=2,$/=2,o/=2}function at(dt,ht){return b===1?dt[ht]:dt.readUInt16BE(ht*b)}let lt;if(v){let dt=-1;for(lt=o;lt<T;lt++)if(at(h,lt)===at(s,dt===-1?0:lt-dt)){if(dt===-1&&(dt=lt),lt-dt+1===$)return dt*b}else dt!==-1&&(lt-=lt-dt),dt=-1}else for(o+$>T&&(o=T-$),lt=o;lt>=0;lt--){let dt=!0;for(let ht=0;ht<$;ht++)if(at(h,lt+ht)!==at(s,ht)){dt=!1;break}if(dt)return lt}return-1}a.prototype.includes=function(s,o,p){return this.indexOf(s,o,p)!==-1},a.prototype.indexOf=function(s,o,p){return P(this,s,o,p,!0)},a.prototype.lastIndexOf=function(s,o,p){return P(this,s,o,p,!1)};function O(h,s,o,p){o=Number(o)||0;const v=h.length-o;p?(p=Number(p),p>v&&(p=v)):p=v;const b=s.length;p>b/2&&(p=b/2);let T;for(T=0;T<p;++T){const $=parseInt(s.substr(T*2,2),16);if(Kt($))return T;h[o+T]=$}return T}function _(h,s,o,p){return ft(q(s,h.length-o),h,o,p)}function U(h,s,o,p){return ft(ot(s),h,o,p)}function V(h,s,o,p){return ft(wt(s),h,o,p)}function z(h,s,o,p){return ft(xt(s,h.length-o),h,o,p)}a.prototype.write=function(s,o,p,v){if(o===void 0)v="utf8",p=this.length,o=0;else if(p===void 0&&typeof o=="string")v=o,p=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(p)?(p=p>>>0,v===void 0&&(v="utf8")):(v=p,p=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const b=this.length-o;if((p===void 0||p>b)&&(p=b),s.length>0&&(p<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");v||(v="utf8");let T=!1;for(;;)switch(v){case"hex":return O(this,s,o,p);case"utf8":case"utf-8":return _(this,s,o,p);case"ascii":case"latin1":case"binary":return U(this,s,o,p);case"base64":return V(this,s,o,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,s,o,p);default:if(T)throw new TypeError("Unknown encoding: "+v);v=(""+v).toLowerCase(),T=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function K(h,s,o){return s===0&&o===h.length?t.fromByteArray(h):t.fromByteArray(h.slice(s,o))}function et(h,s,o){o=Math.min(h.length,o);const p=[];let v=s;for(;v<o;){const b=h[v];let T=null,$=b>239?4:b>223?3:b>191?2:1;if(v+$<=o){let at,lt,dt,ht;switch($){case 1:b<128&&(T=b);break;case 2:at=h[v+1],(at&192)===128&&(ht=(b&31)<<6|at&63,ht>127&&(T=ht));break;case 3:at=h[v+1],lt=h[v+2],(at&192)===128&&(lt&192)===128&&(ht=(b&15)<<12|(at&63)<<6|lt&63,ht>2047&&(ht<55296||ht>57343)&&(T=ht));break;case 4:at=h[v+1],lt=h[v+2],dt=h[v+3],(at&192)===128&&(lt&192)===128&&(dt&192)===128&&(ht=(b&15)<<18|(at&63)<<12|(lt&63)<<6|dt&63,ht>65535&&ht<1114112&&(T=ht))}}T===null?(T=65533,$=1):T>65535&&(T-=65536,p.push(T>>>10&1023|55296),T=56320|T&1023),p.push(T),v+=$}return W(p)}const Q=4096;function W(h){const s=h.length;if(s<=Q)return String.fromCharCode.apply(String,h);let o="",p=0;for(;p<s;)o+=String.fromCharCode.apply(String,h.slice(p,p+=Q));return o}function Y(h,s,o){let p="";o=Math.min(h.length,o);for(let v=s;v<o;++v)p+=String.fromCharCode(h[v]&127);return p}function Z(h,s,o){let p="";o=Math.min(h.length,o);for(let v=s;v<o;++v)p+=String.fromCharCode(h[v]);return p}function yt(h,s,o){const p=h.length;(!s||s<0)&&(s=0),(!o||o<0||o>p)&&(o=p);let v="";for(let b=s;b<o;++b)v+=Jt[h[b]];return v}function ct(h,s,o){const p=h.slice(s,o);let v="";for(let b=0;b<p.length-1;b+=2)v+=String.fromCharCode(p[b]+p[b+1]*256);return v}a.prototype.slice=function(s,o){const p=this.length;s=~~s,o=o===void 0?p:~~o,s<0?(s+=p,s<0&&(s=0)):s>p&&(s=p),o<0?(o+=p,o<0&&(o=0)):o>p&&(o=p),o<s&&(o=s);const v=this.subarray(s,o);return Object.setPrototypeOf(v,a.prototype),v};function H(h,s,o){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+s>o)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=this[s],b=1,T=0;for(;++T<o&&(b*=256);)v+=this[s+T]*b;return v},a.prototype.readUintBE=a.prototype.readUIntBE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=this[s+--o],b=1;for(;o>0&&(b*=256);)v+=this[s+--o]*b;return v},a.prototype.readUint8=a.prototype.readUInt8=function(s,o){return s=s>>>0,o||H(s,1,this.length),this[s]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(s,o){return s=s>>>0,o||H(s,2,this.length),this[s]|this[s+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(s,o){return s=s>>>0,o||H(s,2,this.length),this[s]<<8|this[s+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(s,o){return s=s>>>0,o||H(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(s,o){return s=s>>>0,o||H(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},a.prototype.readBigUInt64LE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,b=this[++s]+this[++s]*2**8+this[++s]*2**16+p*2**24;return BigInt(v)+(BigInt(b)<<BigInt(32))}),a.prototype.readBigUInt64BE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=o*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],b=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+p;return(BigInt(v)<<BigInt(32))+BigInt(b)}),a.prototype.readIntLE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=this[s],b=1,T=0;for(;++T<o&&(b*=256);)v+=this[s+T]*b;return b*=128,v>=b&&(v-=Math.pow(2,8*o)),v},a.prototype.readIntBE=function(s,o,p){s=s>>>0,o=o>>>0,p||H(s,o,this.length);let v=o,b=1,T=this[s+--v];for(;v>0&&(b*=256);)T+=this[s+--v]*b;return b*=128,T>=b&&(T-=Math.pow(2,8*o)),T},a.prototype.readInt8=function(s,o){return s=s>>>0,o||H(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},a.prototype.readInt16LE=function(s,o){s=s>>>0,o||H(s,2,this.length);const p=this[s]|this[s+1]<<8;return p&32768?p|4294901760:p},a.prototype.readInt16BE=function(s,o){s=s>>>0,o||H(s,2,this.length);const p=this[s+1]|this[s]<<8;return p&32768?p|4294901760:p},a.prototype.readInt32LE=function(s,o){return s=s>>>0,o||H(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},a.prototype.readInt32BE=function(s,o){return s=s>>>0,o||H(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},a.prototype.readBigInt64LE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(p<<24);return(BigInt(v)<<BigInt(32))+BigInt(o+this[++s]*256+this[++s]*65536+this[++s]*16777216)}),a.prototype.readBigInt64BE=Nt(function(s){s=s>>>0,rt(s,"offset");const o=this[s],p=this[s+7];(o===void 0||p===void 0)&&G(s,this.length-8);const v=(o<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(v)<<BigInt(32))+BigInt(this[++s]*16777216+this[++s]*65536+this[++s]*256+p)}),a.prototype.readFloatLE=function(s,o){return s=s>>>0,o||H(s,4,this.length),e.read(this,s,!0,23,4)},a.prototype.readFloatBE=function(s,o){return s=s>>>0,o||H(s,4,this.length),e.read(this,s,!1,23,4)},a.prototype.readDoubleLE=function(s,o){return s=s>>>0,o||H(s,8,this.length),e.read(this,s,!0,52,8)},a.prototype.readDoubleBE=function(s,o){return s=s>>>0,o||H(s,8,this.length),e.read(this,s,!1,52,8)};function it(h,s,o,p,v,b){if(!a.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>v||s<b)throw new RangeError('"value" argument is out of bounds');if(o+p>h.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(s,o,p,v){if(s=+s,o=o>>>0,p=p>>>0,!v){const $=Math.pow(2,8*p)-1;it(this,s,o,p,$,0)}let b=1,T=0;for(this[o]=s&255;++T<p&&(b*=256);)this[o+T]=s/b&255;return o+p},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(s,o,p,v){if(s=+s,o=o>>>0,p=p>>>0,!v){const $=Math.pow(2,8*p)-1;it(this,s,o,p,$,0)}let b=p-1,T=1;for(this[o+b]=s&255;--b>=0&&(T*=256);)this[o+b]=s/T&255;return o+p},a.prototype.writeUint8=a.prototype.writeUInt8=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,1,255,0),this[o]=s&255,o+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,65535,0),this[o]=s&255,this[o+1]=s>>>8,o+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,65535,0),this[o]=s>>>8,this[o+1]=s&255,o+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,4294967295,0),this[o+3]=s>>>24,this[o+2]=s>>>16,this[o+1]=s>>>8,this[o]=s&255,o+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,4294967295,0),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4};function vt(h,s,o,p,v){ut(s,p,v,h,o,7);let b=Number(s&BigInt(4294967295));h[o++]=b,b=b>>8,h[o++]=b,b=b>>8,h[o++]=b,b=b>>8,h[o++]=b;let T=Number(s>>BigInt(32)&BigInt(4294967295));return h[o++]=T,T=T>>8,h[o++]=T,T=T>>8,h[o++]=T,T=T>>8,h[o++]=T,o}function j(h,s,o,p,v){ut(s,p,v,h,o,7);let b=Number(s&BigInt(4294967295));h[o+7]=b,b=b>>8,h[o+6]=b,b=b>>8,h[o+5]=b,b=b>>8,h[o+4]=b;let T=Number(s>>BigInt(32)&BigInt(4294967295));return h[o+3]=T,T=T>>8,h[o+2]=T,T=T>>8,h[o+1]=T,T=T>>8,h[o]=T,o+8}a.prototype.writeBigUInt64LE=Nt(function(s,o=0){return vt(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Nt(function(s,o=0){return j(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(s,o,p,v){if(s=+s,o=o>>>0,!v){const at=Math.pow(2,8*p-1);it(this,s,o,p,at-1,-at)}let b=0,T=1,$=0;for(this[o]=s&255;++b<p&&(T*=256);)s<0&&$===0&&this[o+b-1]!==0&&($=1),this[o+b]=(s/T>>0)-$&255;return o+p},a.prototype.writeIntBE=function(s,o,p,v){if(s=+s,o=o>>>0,!v){const at=Math.pow(2,8*p-1);it(this,s,o,p,at-1,-at)}let b=p-1,T=1,$=0;for(this[o+b]=s&255;--b>=0&&(T*=256);)s<0&&$===0&&this[o+b+1]!==0&&($=1),this[o+b]=(s/T>>0)-$&255;return o+p},a.prototype.writeInt8=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,1,127,-128),s<0&&(s=255+s+1),this[o]=s&255,o+1},a.prototype.writeInt16LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,32767,-32768),this[o]=s&255,this[o+1]=s>>>8,o+2},a.prototype.writeInt16BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,2,32767,-32768),this[o]=s>>>8,this[o+1]=s&255,o+2},a.prototype.writeInt32LE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,2147483647,-2147483648),this[o]=s&255,this[o+1]=s>>>8,this[o+2]=s>>>16,this[o+3]=s>>>24,o+4},a.prototype.writeInt32BE=function(s,o,p){return s=+s,o=o>>>0,p||it(this,s,o,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4},a.prototype.writeBigInt64LE=Nt(function(s,o=0){return vt(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Nt(function(s,o=0){return j(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Mt(h,s,o,p,v,b){if(o+p>h.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function bt(h,s,o,p,v){return s=+s,o=o>>>0,v||Mt(h,s,o,4),e.write(h,s,o,p,23,4),o+4}a.prototype.writeFloatLE=function(s,o,p){return bt(this,s,o,!0,p)},a.prototype.writeFloatBE=function(s,o,p){return bt(this,s,o,!1,p)};function d(h,s,o,p,v){return s=+s,o=o>>>0,v||Mt(h,s,o,8),e.write(h,s,o,p,52,8),o+8}a.prototype.writeDoubleLE=function(s,o,p){return d(this,s,o,!0,p)},a.prototype.writeDoubleBE=function(s,o,p){return d(this,s,o,!1,p)},a.prototype.copy=function(s,o,p,v){if(!a.isBuffer(s))throw new TypeError("argument should be a Buffer");if(p||(p=0),!v&&v!==0&&(v=this.length),o>=s.length&&(o=s.length),o||(o=0),v>0&&v<p&&(v=p),v===p||s.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(p<0||p>=this.length)throw new RangeError("Index out of range");if(v<0)throw new RangeError("sourceEnd out of bounds");v>this.length&&(v=this.length),s.length-o<v-p&&(v=s.length-o+p);const b=v-p;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,p,v):Uint8Array.prototype.set.call(s,this.subarray(p,v),o),b},a.prototype.fill=function(s,o,p,v){if(typeof s=="string"){if(typeof o=="string"?(v=o,o=0,p=this.length):typeof p=="string"&&(v=p,p=this.length),v!==void 0&&typeof v!="string")throw new TypeError("encoding must be a string");if(typeof v=="string"&&!a.isEncoding(v))throw new TypeError("Unknown encoding: "+v);if(s.length===1){const T=s.charCodeAt(0);(v==="utf8"&&T<128||v==="latin1")&&(s=T)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(o<0||this.length<o||this.length<p)throw new RangeError("Out of range index");if(p<=o)return this;o=o>>>0,p=p===void 0?this.length:p>>>0,s||(s=0);let b;if(typeof s=="number")for(b=o;b<p;++b)this[b]=s;else{const T=a.isBuffer(s)?s:a.from(s,v),$=T.length;if($===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(b=0;b<p-o;++b)this[b+o]=T[b%$]}return this};const u={};function B(h,s,o){u[h]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(v){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:v,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}B("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),B("ERR_INVALID_ARG_TYPE",function(h,s){return`The "${h}" argument must be of type number. Received type ${typeof s}`},TypeError),B("ERR_OUT_OF_RANGE",function(h,s,o){let p=`The value of "${h}" is out of range.`,v=o;return Number.isInteger(o)&&Math.abs(o)>4294967296?v=E(String(o)):typeof o=="bigint"&&(v=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(v=E(v)),v+="n"),p+=` It must be ${s}. Received ${v}`,p},RangeError);function E(h){let s="",o=h.length;const p=h[0]==="-"?1:0;for(;o>=p+4;o-=3)s=`_${h.slice(o-3,o)}${s}`;return`${h.slice(0,o)}${s}`}function J(h,s,o){rt(s,"offset"),(h[s]===void 0||h[s+o]===void 0)&&G(s,h.length-(o+1))}function ut(h,s,o,p,v,b){if(h>o||h<s){const T=typeof s=="bigint"?"n":"";let $;throw s===0||s===BigInt(0)?$=`>= 0${T} and < 2${T} ** ${(b+1)*8}${T}`:$=`>= -(2${T} ** ${(b+1)*8-1}${T}) and < 2 ** ${(b+1)*8-1}${T}`,new u.ERR_OUT_OF_RANGE("value",$,h)}J(p,v,b)}function rt(h,s){if(typeof h!="number")throw new u.ERR_INVALID_ARG_TYPE(s,"number",h)}function G(h,s,o){throw Math.floor(h)!==h?(rt(h,o),new u.ERR_OUT_OF_RANGE("offset","an integer",h)):s<0?new u.ERR_BUFFER_OUT_OF_BOUNDS:new u.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,h)}const X=/[^+/0-9A-Za-z-_]/g;function tt(h){if(h=h.split("=")[0],h=h.trim().replace(X,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function q(h,s){s=s||1/0;let o;const p=h.length;let v=null;const b=[];for(let T=0;T<p;++T){if(o=h.charCodeAt(T),o>55295&&o<57344){if(!v){if(o>56319){(s-=3)>-1&&b.push(239,191,189);continue}else if(T+1===p){(s-=3)>-1&&b.push(239,191,189);continue}v=o;continue}if(o<56320){(s-=3)>-1&&b.push(239,191,189),v=o;continue}o=(v-55296<<10|o-56320)+65536}else v&&(s-=3)>-1&&b.push(239,191,189);if(v=null,o<128){if((s-=1)<0)break;b.push(o)}else if(o<2048){if((s-=2)<0)break;b.push(o>>6|192,o&63|128)}else if(o<65536){if((s-=3)<0)break;b.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((s-=4)<0)break;b.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return b}function ot(h){const s=[];for(let o=0;o<h.length;++o)s.push(h.charCodeAt(o)&255);return s}function xt(h,s){let o,p,v;const b=[];for(let T=0;T<h.length&&!((s-=2)<0);++T)o=h.charCodeAt(T),p=o>>8,v=o%256,b.push(v),b.push(p);return b}function wt(h){return t.toByteArray(tt(h))}function ft(h,s,o,p){let v;for(v=0;v<p&&!(v+o>=s.length||v>=h.length);++v)s[v+o]=h[v];return v}function Et(h,s){return h instanceof s||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===s.name}function Kt(h){return h!==h}const Jt=(function(){const h="0123456789abcdef",s=new Array(256);for(let o=0;o<16;++o){const p=o*16;for(let v=0;v<16;++v)s[p+v]=h[o]+h[v]}return s})();function Nt(h){return typeof BigInt>"u"?ie:h}function ie(){throw new Error("BigInt not supported")}})(Te)),Te}var li;function pr(){return li||(li=1,(function(n,t){var e=ai(),i=e.Buffer;function r(c,a){for(var g in c)a[g]=c[g]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=e:(r(e,t),t.Buffer=l);function l(c,a,g){return i(c,a,g)}l.prototype=Object.create(i.prototype),r(i,l),l.from=function(c,a,g){if(typeof c=="number")throw new TypeError("Argument must not be a number");return i(c,a,g)},l.alloc=function(c,a,g){if(typeof c!="number")throw new TypeError("Argument must be a number");var S=i(c);return a!==void 0?typeof g=="string"?S.fill(a,g):S.fill(a):S.fill(0),S},l.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return i(c)},l.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(c)}})(de,de.exports)),de.exports}var ci;function mr(){if(ci)return Ae;ci=1;var n=pr().Buffer,t=n.isEncoding||function(m){switch(m=""+m,m&&m.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function e(m){if(!m)return"utf8";for(var x;;)switch(m){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return m;default:if(x)return;m=(""+m).toLowerCase(),x=!0}}function i(m){var x=e(m);if(typeof x!="string"&&(n.isEncoding===t||!t(m)))throw new Error("Unknown encoding: "+m);return x||m}Ae.StringDecoder=r;function r(m){this.encoding=i(m);var x;switch(this.encoding){case"utf16le":this.text=C,this.end=M,x=4;break;case"utf8":this.fillLast=g,x=4;break;case"base64":this.text=N,this.end=F,x=3;break;default:this.write=k,this.end=R;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(x)}r.prototype.write=function(m){if(m.length===0)return"";var x,y;if(this.lastNeed){if(x=this.fillLast(m),x===void 0)return"";y=this.lastNeed,this.lastNeed=0}else y=0;return y<m.length?x?x+this.text(m,y):this.text(m,y):x||""},r.prototype.end=w,r.prototype.text=S,r.prototype.fillLast=function(m){if(this.lastNeed<=m.length)return m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,this.lastTotal-this.lastNeed,0,m.length),this.lastNeed-=m.length};function l(m){return m<=127?0:m>>5===6?2:m>>4===14?3:m>>3===30?4:m>>6===2?-1:-2}function c(m,x,y){var f=x.length-1;if(f<y)return 0;var A=l(x[f]);return A>=0?(A>0&&(m.lastNeed=A-1),A):--f<y||A===-2?0:(A=l(x[f]),A>=0?(A>0&&(m.lastNeed=A-2),A):--f<y||A===-2?0:(A=l(x[f]),A>=0?(A>0&&(A===2?A=0:m.lastNeed=A-3),A):0))}function a(m,x,y){if((x[0]&192)!==128)return m.lastNeed=0,"�";if(m.lastNeed>1&&x.length>1){if((x[1]&192)!==128)return m.lastNeed=1,"�";if(m.lastNeed>2&&x.length>2&&(x[2]&192)!==128)return m.lastNeed=2,"�"}}function g(m){var x=this.lastTotal-this.lastNeed,y=a(this,m);if(y!==void 0)return y;if(this.lastNeed<=m.length)return m.copy(this.lastChar,x,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);m.copy(this.lastChar,x,0,m.length),this.lastNeed-=m.length}function S(m,x){var y=c(this,m,x);if(!this.lastNeed)return m.toString("utf8",x);this.lastTotal=y;var f=m.length-(y-this.lastNeed);return m.copy(this.lastChar,0,f),m.toString("utf8",x,f)}function w(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+"�":x}function C(m,x){if((m.length-x)%2===0){var y=m.toString("utf16le",x);if(y){var f=y.charCodeAt(y.length-1);if(f>=55296&&f<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1],y.slice(0,-1)}return y}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=m[m.length-1],m.toString("utf16le",x,m.length-1)}function M(m){var x=m&&m.length?this.write(m):"";if(this.lastNeed){var y=this.lastTotal-this.lastNeed;return x+this.lastChar.toString("utf16le",0,y)}return x}function N(m,x){var y=(m.length-x)%3;return y===0?m.toString("base64",x):(this.lastNeed=3-y,this.lastTotal=3,y===1?this.lastChar[0]=m[m.length-1]:(this.lastChar[0]=m[m.length-2],this.lastChar[1]=m[m.length-1]),m.toString("base64",x,m.length-y))}function F(m){var x=m&&m.length?this.write(m):"";return this.lastNeed?x+this.lastChar.toString("base64",0,3-this.lastNeed):x}function k(m){return m.toString(this.encoding)}function R(m){return m&&m.length?this.write(m):""}return Ae}var ui;function yr(){return ui||(ui=1,(function(n){(function(t){t.parser=function(d,u){return new i(d,u)},t.SAXParser=i,t.SAXStream=w,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(d,u){if(!(this instanceof i))return new i(d,u);var B=this;l(B),B.q=B.c="",B.bufferCheckPosition=t.MAX_BUFFER_LENGTH,B.opt=u||{},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=!!d,B.noscript=!!(d||B.opt.noscript),B.state=_.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(k)),B.opt.unquotedAttributeValues===void 0&&(B.opt.unquotedAttributeValues=!d),B.trackPosition=B.opt.position!==!1,B.trackPosition&&(B.position=B.line=B.column=0),V(B,"onready")}Object.create||(Object.create=function(d){function u(){}u.prototype=d;var B=new u;return B}),Object.keys||(Object.keys=function(d){var u=[];for(var B in d)d.hasOwnProperty(B)&&u.push(B);return u});function r(d){for(var u=Math.max(t.MAX_BUFFER_LENGTH,10),B=0,E=0,J=e.length;E<J;E++){var ut=d[e[E]].length;if(ut>u)switch(e[E]){case"textNode":K(d);break;case"cdata":z(d,"oncdata",d.cdata),d.cdata="";break;case"script":z(d,"onscript",d.script),d.script="";break;default:Q(d,"Max buffer length exceeded: "+e[E])}B=Math.max(B,ut)}var rt=t.MAX_BUFFER_LENGTH-B;d.bufferCheckPosition=rt+d.position}function l(d){for(var u=0,B=e.length;u<B;u++)d[e[u]]=""}function c(d){K(d),d.cdata!==""&&(z(d,"oncdata",d.cdata),d.cdata=""),d.script!==""&&(z(d,"onscript",d.script),d.script="")}i.prototype={end:function(){W(this)},write:bt,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){c(this)}};var a;try{a=hr.Stream}catch{a=function(){}}a||(a=function(){});var g=t.EVENTS.filter(function(d){return d!=="error"&&d!=="end"});function S(d,u){return new w(d,u)}function w(d,u){if(!(this instanceof w))return new w(d,u);a.apply(this),this._parser=new i(d,u),this.writable=!0,this.readable=!0;var B=this;this._parser.onend=function(){B.emit("end")},this._parser.onerror=function(E){B.emit("error",E),B._parser.error=null},this._decoder=null,g.forEach(function(E){Object.defineProperty(B,"on"+E,{get:function(){return B._parser["on"+E]},set:function(J){if(!J)return B.removeAllListeners(E),B._parser["on"+E]=J,J;B.on(E,J)},enumerable:!0,configurable:!1})})}w.prototype=Object.create(a.prototype,{constructor:{value:w}}),w.prototype.write=function(d){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(d)){if(!this._decoder){var u=mr().StringDecoder;this._decoder=new u("utf8")}d=this._decoder.write(d)}return this._parser.write(d.toString()),this.emit("data",d),!0},w.prototype.end=function(d){return d&&d.length&&this.write(d),this._parser.end(),!0},w.prototype.on=function(d,u){var B=this;return!B._parser["on"+d]&&g.indexOf(d)!==-1&&(B._parser["on"+d]=function(){var E=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);E.splice(0,0,d),B.emit.apply(B,E)}),a.prototype.on.call(B,d,u)};var C="[CDATA[",M="DOCTYPE",N="http://www.w3.org/XML/1998/namespace",F="http://www.w3.org/2000/xmlns/",k={xml:N,xmlns:F},R=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,x=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,y=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function f(d){return d===" "||d===`
87
- `||d==="\r"||d===" "}function A(d){return d==='"'||d==="'"}function P(d){return d===">"||f(d)}function I(d,u){return d.test(u)}function O(d,u){return!I(d,u)}var _=0;t.STATE={BEGIN:_++,BEGIN_WHITESPACE:_++,TEXT:_++,TEXT_ENTITY:_++,OPEN_WAKA:_++,SGML_DECL:_++,SGML_DECL_QUOTED:_++,DOCTYPE:_++,DOCTYPE_QUOTED:_++,DOCTYPE_DTD:_++,DOCTYPE_DTD_QUOTED:_++,COMMENT_STARTING:_++,COMMENT:_++,COMMENT_ENDING:_++,COMMENT_ENDED:_++,CDATA:_++,CDATA_ENDING:_++,CDATA_ENDING_2:_++,PROC_INST:_++,PROC_INST_BODY:_++,PROC_INST_ENDING:_++,OPEN_TAG:_++,OPEN_TAG_SLASH:_++,ATTRIB:_++,ATTRIB_NAME:_++,ATTRIB_NAME_SAW_WHITE:_++,ATTRIB_VALUE:_++,ATTRIB_VALUE_QUOTED:_++,ATTRIB_VALUE_CLOSED:_++,ATTRIB_VALUE_UNQUOTED:_++,ATTRIB_VALUE_ENTITY_Q:_++,ATTRIB_VALUE_ENTITY_U:_++,CLOSE_TAG:_++,CLOSE_TAG_SAW_WHITE:_++,SCRIPT:_++,SCRIPT_ENDING:_++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(d){var u=t.ENTITIES[d],B=typeof u=="number"?String.fromCharCode(u):u;t.ENTITIES[d]=B});for(var U in t.STATE)t.STATE[t.STATE[U]]=U;_=t.STATE;function V(d,u,B){d[u]&&d[u](B)}function z(d,u,B){d.textNode&&K(d),V(d,u,B)}function K(d){d.textNode=et(d.opt,d.textNode),d.textNode&&V(d,"ontext",d.textNode),d.textNode=""}function et(d,u){return d.trim&&(u=u.trim()),d.normalize&&(u=u.replace(/\s+/g," ")),u}function Q(d,u){return K(d),d.trackPosition&&(u+=`
88
- Line: `+d.line+`
89
- Column: `+d.column+`
90
- Char: `+d.c),u=new Error(u),d.error=u,V(d,"onerror",u),d}function W(d){return d.sawRoot&&!d.closedRoot&&Y(d,"Unclosed root tag"),d.state!==_.BEGIN&&d.state!==_.BEGIN_WHITESPACE&&d.state!==_.TEXT&&Q(d,"Unexpected end"),K(d),d.c="",d.closed=!0,V(d,"onend"),i.call(d,d.strict,d.opt),d}function Y(d,u){if(typeof d!="object"||!(d instanceof i))throw new Error("bad call to strictFail");d.strict&&Q(d,u)}function Z(d){d.strict||(d.tagName=d.tagName[d.looseCase]());var u=d.tags[d.tags.length-1]||d,B=d.tag={name:d.tagName,attributes:{}};d.opt.xmlns&&(B.ns=u.ns),d.attribList.length=0,z(d,"onopentagstart",B)}function yt(d,u){var B=d.indexOf(":"),E=B<0?["",d]:d.split(":"),J=E[0],ut=E[1];return u&&d==="xmlns"&&(J="xmlns",ut=""),{prefix:J,local:ut}}function ct(d){if(d.strict||(d.attribName=d.attribName[d.looseCase]()),d.attribList.indexOf(d.attribName)!==-1||d.tag.attributes.hasOwnProperty(d.attribName)){d.attribName=d.attribValue="";return}if(d.opt.xmlns){var u=yt(d.attribName,!0),B=u.prefix,E=u.local;if(B==="xmlns")if(E==="xml"&&d.attribValue!==N)Y(d,"xml: prefix must be bound to "+N+`
91
- Actual: `+d.attribValue);else if(E==="xmlns"&&d.attribValue!==F)Y(d,"xmlns: prefix must be bound to "+F+`
92
- Actual: `+d.attribValue);else{var J=d.tag,ut=d.tags[d.tags.length-1]||d;J.ns===ut.ns&&(J.ns=Object.create(ut.ns)),J.ns[E]=d.attribValue}d.attribList.push([d.attribName,d.attribValue])}else d.tag.attributes[d.attribName]=d.attribValue,z(d,"onattribute",{name:d.attribName,value:d.attribValue});d.attribName=d.attribValue=""}function H(d,u){if(d.opt.xmlns){var B=d.tag,E=yt(d.tagName);B.prefix=E.prefix,B.local=E.local,B.uri=B.ns[E.prefix]||"",B.prefix&&!B.uri&&(Y(d,"Unbound namespace prefix: "+JSON.stringify(d.tagName)),B.uri=E.prefix);var J=d.tags[d.tags.length-1]||d;B.ns&&J.ns!==B.ns&&Object.keys(B.ns).forEach(function(Et){z(d,"onopennamespace",{prefix:Et,uri:B.ns[Et]})});for(var ut=0,rt=d.attribList.length;ut<rt;ut++){var G=d.attribList[ut],X=G[0],tt=G[1],q=yt(X,!0),ot=q.prefix,xt=q.local,wt=ot===""?"":B.ns[ot]||"",ft={name:X,value:tt,prefix:ot,local:xt,uri:wt};ot&&ot!=="xmlns"&&!wt&&(Y(d,"Unbound namespace prefix: "+JSON.stringify(ot)),ft.uri=ot),d.tag.attributes[X]=ft,z(d,"onattribute",ft)}d.attribList.length=0}d.tag.isSelfClosing=!!u,d.sawRoot=!0,d.tags.push(d.tag),z(d,"onopentag",d.tag),u||(!d.noscript&&d.tagName.toLowerCase()==="script"?d.state=_.SCRIPT:d.state=_.TEXT,d.tag=null,d.tagName=""),d.attribName=d.attribValue="",d.attribList.length=0}function it(d){if(!d.tagName){Y(d,"Weird empty close tag."),d.textNode+="</>",d.state=_.TEXT;return}if(d.script){if(d.tagName!=="script"){d.script+="</"+d.tagName+">",d.tagName="",d.state=_.SCRIPT;return}z(d,"onscript",d.script),d.script=""}var u=d.tags.length,B=d.tagName;d.strict||(B=B[d.looseCase]());for(var E=B;u--;){var J=d.tags[u];if(J.name!==E)Y(d,"Unexpected close tag");else break}if(u<0){Y(d,"Unmatched closing tag: "+d.tagName),d.textNode+="</"+d.tagName+">",d.state=_.TEXT;return}d.tagName=B;for(var ut=d.tags.length;ut-- >u;){var rt=d.tag=d.tags.pop();d.tagName=d.tag.name,z(d,"onclosetag",d.tagName);var G={};for(var X in rt.ns)G[X]=rt.ns[X];var tt=d.tags[d.tags.length-1]||d;d.opt.xmlns&&rt.ns!==tt.ns&&Object.keys(rt.ns).forEach(function(q){var ot=rt.ns[q];z(d,"onclosenamespace",{prefix:q,uri:ot})})}u===0&&(d.closedRoot=!0),d.tagName=d.attribValue=d.attribName="",d.attribList.length=0,d.state=_.TEXT}function vt(d){var u=d.entity,B=u.toLowerCase(),E,J="";return d.ENTITIES[u]?d.ENTITIES[u]:d.ENTITIES[B]?d.ENTITIES[B]:(u=B,u.charAt(0)==="#"&&(u.charAt(1)==="x"?(u=u.slice(2),E=parseInt(u,16),J=E.toString(16)):(u=u.slice(1),E=parseInt(u,10),J=E.toString(10))),u=u.replace(/^0+/,""),isNaN(E)||J.toLowerCase()!==u?(Y(d,"Invalid character entity"),"&"+d.entity+";"):String.fromCodePoint(E))}function j(d,u){u==="<"?(d.state=_.OPEN_WAKA,d.startTagPosition=d.position):f(u)||(Y(d,"Non-whitespace before first tag."),d.textNode=u,d.state=_.TEXT)}function Mt(d,u){var B="";return u<d.length&&(B=d.charAt(u)),B}function bt(d){var u=this;if(this.error)throw this.error;if(u.closed)return Q(u,"Cannot write after close. Assign an onready handler.");if(d===null)return W(u);typeof d=="object"&&(d=d.toString());for(var B=0,E="";E=Mt(d,B++),u.c=E,!!E;)switch(u.trackPosition&&(u.position++,E===`
93
- `?(u.line++,u.column=0):u.column++),u.state){case _.BEGIN:if(u.state=_.BEGIN_WHITESPACE,E==="\uFEFF")continue;j(u,E);continue;case _.BEGIN_WHITESPACE:j(u,E);continue;case _.TEXT:if(u.sawRoot&&!u.closedRoot){for(var J=B-1;E&&E!=="<"&&E!=="&";)E=Mt(d,B++),E&&u.trackPosition&&(u.position++,E===`
94
- `?(u.line++,u.column=0):u.column++);u.textNode+=d.substring(J,B-1)}E==="<"&&!(u.sawRoot&&u.closedRoot&&!u.strict)?(u.state=_.OPEN_WAKA,u.startTagPosition=u.position):(!f(E)&&(!u.sawRoot||u.closedRoot)&&Y(u,"Text data outside of root node."),E==="&"?u.state=_.TEXT_ENTITY:u.textNode+=E);continue;case _.SCRIPT:E==="<"?u.state=_.SCRIPT_ENDING:u.script+=E;continue;case _.SCRIPT_ENDING:E==="/"?u.state=_.CLOSE_TAG:(u.script+="<"+E,u.state=_.SCRIPT);continue;case _.OPEN_WAKA:if(E==="!")u.state=_.SGML_DECL,u.sgmlDecl="";else if(!f(E))if(I(R,E))u.state=_.OPEN_TAG,u.tagName=E;else if(E==="/")u.state=_.CLOSE_TAG,u.tagName="";else if(E==="?")u.state=_.PROC_INST,u.procInstName=u.procInstBody="";else{if(Y(u,"Unencoded <"),u.startTagPosition+1<u.position){var ut=u.position-u.startTagPosition;E=new Array(ut).join(" ")+E}u.textNode+="<"+E,u.state=_.TEXT}continue;case _.SGML_DECL:if(u.sgmlDecl+E==="--"){u.state=_.COMMENT,u.comment="",u.sgmlDecl="";continue}u.doctype&&u.doctype!==!0&&u.sgmlDecl?(u.state=_.DOCTYPE_DTD,u.doctype+="<!"+u.sgmlDecl+E,u.sgmlDecl=""):(u.sgmlDecl+E).toUpperCase()===C?(z(u,"onopencdata"),u.state=_.CDATA,u.sgmlDecl="",u.cdata=""):(u.sgmlDecl+E).toUpperCase()===M?(u.state=_.DOCTYPE,(u.doctype||u.sawRoot)&&Y(u,"Inappropriately located doctype declaration"),u.doctype="",u.sgmlDecl=""):E===">"?(z(u,"onsgmldeclaration",u.sgmlDecl),u.sgmlDecl="",u.state=_.TEXT):(A(E)&&(u.state=_.SGML_DECL_QUOTED),u.sgmlDecl+=E);continue;case _.SGML_DECL_QUOTED:E===u.q&&(u.state=_.SGML_DECL,u.q=""),u.sgmlDecl+=E;continue;case _.DOCTYPE:E===">"?(u.state=_.TEXT,z(u,"ondoctype",u.doctype),u.doctype=!0):(u.doctype+=E,E==="["?u.state=_.DOCTYPE_DTD:A(E)&&(u.state=_.DOCTYPE_QUOTED,u.q=E));continue;case _.DOCTYPE_QUOTED:u.doctype+=E,E===u.q&&(u.q="",u.state=_.DOCTYPE);continue;case _.DOCTYPE_DTD:E==="]"?(u.doctype+=E,u.state=_.DOCTYPE):E==="<"?(u.state=_.OPEN_WAKA,u.startTagPosition=u.position):A(E)?(u.doctype+=E,u.state=_.DOCTYPE_DTD_QUOTED,u.q=E):u.doctype+=E;continue;case _.DOCTYPE_DTD_QUOTED:u.doctype+=E,E===u.q&&(u.state=_.DOCTYPE_DTD,u.q="");continue;case _.COMMENT:E==="-"?u.state=_.COMMENT_ENDING:u.comment+=E;continue;case _.COMMENT_ENDING:E==="-"?(u.state=_.COMMENT_ENDED,u.comment=et(u.opt,u.comment),u.comment&&z(u,"oncomment",u.comment),u.comment=""):(u.comment+="-"+E,u.state=_.COMMENT);continue;case _.COMMENT_ENDED:E!==">"?(Y(u,"Malformed comment"),u.comment+="--"+E,u.state=_.COMMENT):u.doctype&&u.doctype!==!0?u.state=_.DOCTYPE_DTD:u.state=_.TEXT;continue;case _.CDATA:E==="]"?u.state=_.CDATA_ENDING:u.cdata+=E;continue;case _.CDATA_ENDING:E==="]"?u.state=_.CDATA_ENDING_2:(u.cdata+="]"+E,u.state=_.CDATA);continue;case _.CDATA_ENDING_2:E===">"?(u.cdata&&z(u,"oncdata",u.cdata),z(u,"onclosecdata"),u.cdata="",u.state=_.TEXT):E==="]"?u.cdata+="]":(u.cdata+="]]"+E,u.state=_.CDATA);continue;case _.PROC_INST:E==="?"?u.state=_.PROC_INST_ENDING:f(E)?u.state=_.PROC_INST_BODY:u.procInstName+=E;continue;case _.PROC_INST_BODY:if(!u.procInstBody&&f(E))continue;E==="?"?u.state=_.PROC_INST_ENDING:u.procInstBody+=E;continue;case _.PROC_INST_ENDING:E===">"?(z(u,"onprocessinginstruction",{name:u.procInstName,body:u.procInstBody}),u.procInstName=u.procInstBody="",u.state=_.TEXT):(u.procInstBody+="?"+E,u.state=_.PROC_INST_BODY);continue;case _.OPEN_TAG:I(m,E)?u.tagName+=E:(Z(u),E===">"?H(u):E==="/"?u.state=_.OPEN_TAG_SLASH:(f(E)||Y(u,"Invalid character in tag name"),u.state=_.ATTRIB));continue;case _.OPEN_TAG_SLASH:E===">"?(H(u,!0),it(u)):(Y(u,"Forward-slash in opening tag not followed by >"),u.state=_.ATTRIB);continue;case _.ATTRIB:if(f(E))continue;E===">"?H(u):E==="/"?u.state=_.OPEN_TAG_SLASH:I(R,E)?(u.attribName=E,u.attribValue="",u.state=_.ATTRIB_NAME):Y(u,"Invalid attribute name");continue;case _.ATTRIB_NAME:E==="="?u.state=_.ATTRIB_VALUE:E===">"?(Y(u,"Attribute without value"),u.attribValue=u.attribName,ct(u),H(u)):f(E)?u.state=_.ATTRIB_NAME_SAW_WHITE:I(m,E)?u.attribName+=E:Y(u,"Invalid attribute name");continue;case _.ATTRIB_NAME_SAW_WHITE:if(E==="=")u.state=_.ATTRIB_VALUE;else{if(f(E))continue;Y(u,"Attribute without value"),u.tag.attributes[u.attribName]="",u.attribValue="",z(u,"onattribute",{name:u.attribName,value:""}),u.attribName="",E===">"?H(u):I(R,E)?(u.attribName=E,u.state=_.ATTRIB_NAME):(Y(u,"Invalid attribute name"),u.state=_.ATTRIB)}continue;case _.ATTRIB_VALUE:if(f(E))continue;A(E)?(u.q=E,u.state=_.ATTRIB_VALUE_QUOTED):(u.opt.unquotedAttributeValues||Q(u,"Unquoted attribute value"),u.state=_.ATTRIB_VALUE_UNQUOTED,u.attribValue=E);continue;case _.ATTRIB_VALUE_QUOTED:if(E!==u.q){E==="&"?u.state=_.ATTRIB_VALUE_ENTITY_Q:u.attribValue+=E;continue}ct(u),u.q="",u.state=_.ATTRIB_VALUE_CLOSED;continue;case _.ATTRIB_VALUE_CLOSED:f(E)?u.state=_.ATTRIB:E===">"?H(u):E==="/"?u.state=_.OPEN_TAG_SLASH:I(R,E)?(Y(u,"No whitespace between attributes"),u.attribName=E,u.attribValue="",u.state=_.ATTRIB_NAME):Y(u,"Invalid attribute name");continue;case _.ATTRIB_VALUE_UNQUOTED:if(!P(E)){E==="&"?u.state=_.ATTRIB_VALUE_ENTITY_U:u.attribValue+=E;continue}ct(u),E===">"?H(u):u.state=_.ATTRIB;continue;case _.CLOSE_TAG:if(u.tagName)E===">"?it(u):I(m,E)?u.tagName+=E:u.script?(u.script+="</"+u.tagName,u.tagName="",u.state=_.SCRIPT):(f(E)||Y(u,"Invalid tagname in closing tag"),u.state=_.CLOSE_TAG_SAW_WHITE);else{if(f(E))continue;O(R,E)?u.script?(u.script+="</"+E,u.state=_.SCRIPT):Y(u,"Invalid tagname in closing tag."):u.tagName=E}continue;case _.CLOSE_TAG_SAW_WHITE:if(f(E))continue;E===">"?it(u):Y(u,"Invalid characters in closing tag");continue;case _.TEXT_ENTITY:case _.ATTRIB_VALUE_ENTITY_Q:case _.ATTRIB_VALUE_ENTITY_U:var rt,G;switch(u.state){case _.TEXT_ENTITY:rt=_.TEXT,G="textNode";break;case _.ATTRIB_VALUE_ENTITY_Q:rt=_.ATTRIB_VALUE_QUOTED,G="attribValue";break;case _.ATTRIB_VALUE_ENTITY_U:rt=_.ATTRIB_VALUE_UNQUOTED,G="attribValue";break}if(E===";"){var X=vt(u);u.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(X)?(u.entity="",u.state=rt,u.write(X)):(u[G]+=X,u.entity="",u.state=rt)}else I(u.entity.length?y:x,E)?u.entity+=E:(Y(u,"Invalid character in entity name"),u[G]+="&"+u.entity+E,u.entity="",u.state=rt);continue;default:throw new Error(u,"Unknown state: "+u.state)}return u.position>=u.bufferCheckPosition&&r(u),u}String.fromCodePoint||(function(){var d=String.fromCharCode,u=Math.floor,B=function(){var E=16384,J=[],ut,rt,G=-1,X=arguments.length;if(!X)return"";for(var tt="";++G<X;){var q=Number(arguments[G]);if(!isFinite(q)||q<0||q>1114111||u(q)!==q)throw RangeError("Invalid code point: "+q);q<=65535?J.push(q):(q-=65536,ut=(q>>10)+55296,rt=q%1024+56320,J.push(ut,rt)),(G+1===X||J.length>E)&&(tt+=d.apply(null,J),J.length=0)}return tt};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:B,configurable:!0,writable:!0}):String.fromCodePoint=B})()})(n)})(Se)),Se}var Me,hi;function Ce(){return hi||(hi=1,Me={isArray:function(n){return Array.isArray?Array.isArray(n):Object.prototype.toString.call(n)==="[object Array]"}}),Me}var Fe,fi;function Be(){if(fi)return Fe;fi=1;var n=Ce().isArray;return Fe={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"&&!n(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}},Fe}var Ne,di;function pi(){if(di)return Ne;di=1;var n=yr(),t=Be(),e=Ce().isArray,i,r;function l(m){return i=t.copyOptions(m),t.ensureFlagExists("ignoreDeclaration",i),t.ensureFlagExists("ignoreInstruction",i),t.ensureFlagExists("ignoreAttributes",i),t.ensureFlagExists("ignoreText",i),t.ensureFlagExists("ignoreComment",i),t.ensureFlagExists("ignoreCdata",i),t.ensureFlagExists("ignoreDoctype",i),t.ensureFlagExists("compact",i),t.ensureFlagExists("alwaysChildren",i),t.ensureFlagExists("addParent",i),t.ensureFlagExists("trim",i),t.ensureFlagExists("nativeType",i),t.ensureFlagExists("nativeTypeAttributes",i),t.ensureFlagExists("sanitize",i),t.ensureFlagExists("instructionHasAttributes",i),t.ensureFlagExists("captureSpacesBetweenElements",i),t.ensureAlwaysArrayExists(i),t.ensureKeyExists("declaration",i),t.ensureKeyExists("instruction",i),t.ensureKeyExists("attributes",i),t.ensureKeyExists("text",i),t.ensureKeyExists("comment",i),t.ensureKeyExists("cdata",i),t.ensureKeyExists("doctype",i),t.ensureKeyExists("type",i),t.ensureKeyExists("name",i),t.ensureKeyExists("elements",i),t.ensureKeyExists("parent",i),t.checkFnExists("doctype",i),t.checkFnExists("instruction",i),t.checkFnExists("cdata",i),t.checkFnExists("comment",i),t.checkFnExists("text",i),t.checkFnExists("instructionName",i),t.checkFnExists("elementName",i),t.checkFnExists("attributeName",i),t.checkFnExists("attributeValue",i),t.checkFnExists("attributes",i),i}function c(m){var x=Number(m);if(!isNaN(x))return x;var y=m.toLowerCase();return y==="true"?!0:y==="false"?!1:m}function a(m,x){var y;if(i.compact){if(!r[i[m+"Key"]]&&(e(i.alwaysArray)?i.alwaysArray.indexOf(i[m+"Key"])!==-1:i.alwaysArray)&&(r[i[m+"Key"]]=[]),r[i[m+"Key"]]&&!e(r[i[m+"Key"]])&&(r[i[m+"Key"]]=[r[i[m+"Key"]]]),m+"Fn"in i&&typeof x=="string"&&(x=i[m+"Fn"](x,r)),m==="instruction"&&("instructionFn"in i||"instructionNameFn"in i)){for(y in x)if(x.hasOwnProperty(y))if("instructionFn"in i)x[y]=i.instructionFn(x[y],y,r);else{var f=x[y];delete x[y],x[i.instructionNameFn(y,f,r)]=f}}e(r[i[m+"Key"]])?r[i[m+"Key"]].push(x):r[i[m+"Key"]]=x}else{r[i.elementsKey]||(r[i.elementsKey]=[]);var A={};if(A[i.typeKey]=m,m==="instruction"){for(y in x)if(x.hasOwnProperty(y))break;A[i.nameKey]="instructionNameFn"in i?i.instructionNameFn(y,x,r):y,i.instructionHasAttributes?(A[i.attributesKey]=x[y][i.attributesKey],"instructionFn"in i&&(A[i.attributesKey]=i.instructionFn(A[i.attributesKey],y,r))):("instructionFn"in i&&(x[y]=i.instructionFn(x[y],y,r)),A[i.instructionKey]=x[y])}else m+"Fn"in i&&(x=i[m+"Fn"](x,r)),A[i[m+"Key"]]=x;i.addParent&&(A[i.parentKey]=r),r[i.elementsKey].push(A)}}function g(m){if("attributesFn"in i&&m&&(m=i.attributesFn(m,r)),(i.trim||"attributeValueFn"in i||"attributeNameFn"in i||i.nativeTypeAttributes)&&m){var x;for(x in m)if(m.hasOwnProperty(x)&&(i.trim&&(m[x]=m[x].trim()),i.nativeTypeAttributes&&(m[x]=c(m[x])),"attributeValueFn"in i&&(m[x]=i.attributeValueFn(m[x],x,r)),"attributeNameFn"in i)){var y=m[x];delete m[x],m[i.attributeNameFn(x,m[x],r)]=y}}return m}function S(m){var x={};if(m.body&&(m.name.toLowerCase()==="xml"||i.instructionHasAttributes)){for(var y=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,f;(f=y.exec(m.body))!==null;)x[f[1]]=f[2]||f[3]||f[4];x=g(x)}if(m.name.toLowerCase()==="xml"){if(i.ignoreDeclaration)return;r[i.declarationKey]={},Object.keys(x).length&&(r[i.declarationKey][i.attributesKey]=x),i.addParent&&(r[i.declarationKey][i.parentKey]=r)}else{if(i.ignoreInstruction)return;i.trim&&(m.body=m.body.trim());var A={};i.instructionHasAttributes&&Object.keys(x).length?(A[m.name]={},A[m.name][i.attributesKey]=x):A[m.name]=m.body,a("instruction",A)}}function w(m,x){var y;if(typeof m=="object"&&(x=m.attributes,m=m.name),x=g(x),"elementNameFn"in i&&(m=i.elementNameFn(m,r)),i.compact){if(y={},!i.ignoreAttributes&&x&&Object.keys(x).length){y[i.attributesKey]={};var f;for(f in x)x.hasOwnProperty(f)&&(y[i.attributesKey][f]=x[f])}!(m in r)&&(e(i.alwaysArray)?i.alwaysArray.indexOf(m)!==-1:i.alwaysArray)&&(r[m]=[]),r[m]&&!e(r[m])&&(r[m]=[r[m]]),e(r[m])?r[m].push(y):r[m]=y}else r[i.elementsKey]||(r[i.elementsKey]=[]),y={},y[i.typeKey]="element",y[i.nameKey]=m,!i.ignoreAttributes&&x&&Object.keys(x).length&&(y[i.attributesKey]=x),i.alwaysChildren&&(y[i.elementsKey]=[]),r[i.elementsKey].push(y);y[i.parentKey]=r,r=y}function C(m){i.ignoreText||!m.trim()&&!i.captureSpacesBetweenElements||(i.trim&&(m=m.trim()),i.nativeType&&(m=c(m)),i.sanitize&&(m=m.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),a("text",m))}function M(m){i.ignoreComment||(i.trim&&(m=m.trim()),a("comment",m))}function N(m){var x=r[i.parentKey];i.addParent||delete r[i.parentKey],r=x}function F(m){i.ignoreCdata||(i.trim&&(m=m.trim()),a("cdata",m))}function k(m){i.ignoreDoctype||(m=m.replace(/^ /,""),i.trim&&(m=m.trim()),a("doctype",m))}function R(m){m.note=m}return Ne=function(m,x){var y=n.parser(!0,{}),f={};if(r=f,i=l(x),y.opt={strictEntities:!0},y.onopentag=w,y.ontext=C,y.oncomment=M,y.onclosetag=N,y.onerror=R,y.oncdata=F,y.ondoctype=k,y.onprocessinginstruction=S,y.write(m).close(),f[i.elementsKey]){var A=f[i.elementsKey];delete f[i.elementsKey],f[i.elementsKey]=A,delete f.text}return f},Ne}var Ie,mi;function gr(){if(mi)return Ie;mi=1;var n=Be(),t=pi();function e(i){var r=n.copyOptions(i);return n.ensureSpacesExists(r),r}return Ie=function(i,r){var l,c,a,g;return l=e(r),c=t(i,l),g="compact"in l&&l.compact?"_parent":"parent","addParent"in l&&l.addParent?a=JSON.stringify(c,function(S,w){return S===g?"_":w},l.spaces):a=JSON.stringify(c,null,l.spaces),a.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},Ie}var De,yi;function gi(){if(yi)return De;yi=1;var n=Be(),t=Ce().isArray,e,i;function r(y){var f=n.copyOptions(y);return n.ensureFlagExists("ignoreDeclaration",f),n.ensureFlagExists("ignoreInstruction",f),n.ensureFlagExists("ignoreAttributes",f),n.ensureFlagExists("ignoreText",f),n.ensureFlagExists("ignoreComment",f),n.ensureFlagExists("ignoreCdata",f),n.ensureFlagExists("ignoreDoctype",f),n.ensureFlagExists("compact",f),n.ensureFlagExists("indentText",f),n.ensureFlagExists("indentCdata",f),n.ensureFlagExists("indentAttributes",f),n.ensureFlagExists("indentInstruction",f),n.ensureFlagExists("fullTagEmptyElement",f),n.ensureFlagExists("noQuotesForNativeAttributes",f),n.ensureSpacesExists(f),typeof f.spaces=="number"&&(f.spaces=Array(f.spaces+1).join(" ")),n.ensureKeyExists("declaration",f),n.ensureKeyExists("instruction",f),n.ensureKeyExists("attributes",f),n.ensureKeyExists("text",f),n.ensureKeyExists("comment",f),n.ensureKeyExists("cdata",f),n.ensureKeyExists("doctype",f),n.ensureKeyExists("type",f),n.ensureKeyExists("name",f),n.ensureKeyExists("elements",f),n.checkFnExists("doctype",f),n.checkFnExists("instruction",f),n.checkFnExists("cdata",f),n.checkFnExists("comment",f),n.checkFnExists("text",f),n.checkFnExists("instructionName",f),n.checkFnExists("elementName",f),n.checkFnExists("attributeName",f),n.checkFnExists("attributeValue",f),n.checkFnExists("attributes",f),n.checkFnExists("fullTagEmptyElement",f),f}function l(y,f,A){return(!A&&y.spaces?`
95
- `:"")+Array(f+1).join(y.spaces)}function c(y,f,A){if(f.ignoreAttributes)return"";"attributesFn"in f&&(y=f.attributesFn(y,i,e));var P,I,O,_,U=[];for(P in y)y.hasOwnProperty(P)&&y[P]!==null&&y[P]!==void 0&&(_=f.noQuotesForNativeAttributes&&typeof y[P]!="string"?"":'"',I=""+y[P],I=I.replace(/"/g,"&quot;"),O="attributeNameFn"in f?f.attributeNameFn(P,I,i,e):P,U.push(f.spaces&&f.indentAttributes?l(f,A+1,!1):" "),U.push(O+"="+_+("attributeValueFn"in f?f.attributeValueFn(I,P,i,e):I)+_));return y&&Object.keys(y).length&&f.spaces&&f.indentAttributes&&U.push(l(f,A,!1)),U.join("")}function a(y,f,A){return e=y,i="xml",f.ignoreDeclaration?"":"<?xml"+c(y[f.attributesKey],f,A)+"?>"}function g(y,f,A){if(f.ignoreInstruction)return"";var P;for(P in y)if(y.hasOwnProperty(P))break;var I="instructionNameFn"in f?f.instructionNameFn(P,y[P],i,e):P;if(typeof y[P]=="object")return e=y,i=I,"<?"+I+c(y[P][f.attributesKey],f,A)+"?>";var O=y[P]?y[P]:"";return"instructionFn"in f&&(O=f.instructionFn(O,P,i,e)),"<?"+I+(O?" "+O:"")+"?>"}function S(y,f){return f.ignoreComment?"":"<!--"+("commentFn"in f?f.commentFn(y,i,e):y)+"-->"}function w(y,f){return f.ignoreCdata?"":"<![CDATA["+("cdataFn"in f?f.cdataFn(y,i,e):y.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function C(y,f){return f.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in f?f.doctypeFn(y,i,e):y)+">"}function M(y,f){return f.ignoreText?"":(y=""+y,y=y.replace(/&amp;/g,"&"),y=y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"textFn"in f?f.textFn(y,i,e):y)}function N(y,f){var A;if(y.elements&&y.elements.length)for(A=0;A<y.elements.length;++A)switch(y.elements[A][f.typeKey]){case"text":if(f.indentText)return!0;break;case"cdata":if(f.indentCdata)return!0;break;case"instruction":if(f.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function F(y,f,A){e=y,i=y.name;var P=[],I="elementNameFn"in f?f.elementNameFn(y.name,y):y.name;P.push("<"+I),y[f.attributesKey]&&P.push(c(y[f.attributesKey],f,A));var O=y[f.elementsKey]&&y[f.elementsKey].length||y[f.attributesKey]&&y[f.attributesKey]["xml:space"]==="preserve";return O||("fullTagEmptyElementFn"in f?O=f.fullTagEmptyElementFn(y.name,y):O=f.fullTagEmptyElement),O?(P.push(">"),y[f.elementsKey]&&y[f.elementsKey].length&&(P.push(k(y[f.elementsKey],f,A+1)),e=y,i=y.name),P.push(f.spaces&&N(y,f)?`
96
- `+Array(A+1).join(f.spaces):""),P.push("</"+I+">")):P.push("/>"),P.join("")}function k(y,f,A,P){return y.reduce(function(I,O){var _=l(f,A,P&&!I);switch(O.type){case"element":return I+_+F(O,f,A);case"comment":return I+_+S(O[f.commentKey],f);case"doctype":return I+_+C(O[f.doctypeKey],f);case"cdata":return I+(f.indentCdata?_:"")+w(O[f.cdataKey],f);case"text":return I+(f.indentText?_:"")+M(O[f.textKey],f);case"instruction":var U={};return U[O[f.nameKey]]=O[f.attributesKey]?O:O[f.instructionKey],I+(f.indentInstruction?_:"")+g(U,f,A)}},"")}function R(y,f,A){var P;for(P in y)if(y.hasOwnProperty(P))switch(P){case f.parentKey:case f.attributesKey:break;case f.textKey:if(f.indentText||A)return!0;break;case f.cdataKey:if(f.indentCdata||A)return!0;break;case f.instructionKey:if(f.indentInstruction||A)return!0;break;case f.doctypeKey:case f.commentKey:return!0;default:return!0}return!1}function m(y,f,A,P,I){e=y,i=f;var O="elementNameFn"in A?A.elementNameFn(f,y):f;if(typeof y>"u"||y===null||y==="")return"fullTagEmptyElementFn"in A&&A.fullTagEmptyElementFn(f,y)||A.fullTagEmptyElement?"<"+O+"></"+O+">":"<"+O+"/>";var _=[];if(f){if(_.push("<"+O),typeof y!="object")return _.push(">"+M(y,A)+"</"+O+">"),_.join("");y[A.attributesKey]&&_.push(c(y[A.attributesKey],A,P));var U=R(y,A,!0)||y[A.attributesKey]&&y[A.attributesKey]["xml:space"]==="preserve";if(U||("fullTagEmptyElementFn"in A?U=A.fullTagEmptyElementFn(f,y):U=A.fullTagEmptyElement),U)_.push(">");else return _.push("/>"),_.join("")}return _.push(x(y,A,P+1,!1)),e=y,i=f,f&&_.push((I?l(A,P,!1):"")+"</"+O+">"),_.join("")}function x(y,f,A,P){var I,O,_,U=[];for(O in y)if(y.hasOwnProperty(O))for(_=t(y[O])?y[O]:[y[O]],I=0;I<_.length;++I){switch(O){case f.declarationKey:U.push(a(_[I],f,A));break;case f.instructionKey:U.push((f.indentInstruction?l(f,A,P):"")+g(_[I],f,A));break;case f.attributesKey:case f.parentKey:break;case f.textKey:U.push((f.indentText?l(f,A,P):"")+M(_[I],f));break;case f.cdataKey:U.push((f.indentCdata?l(f,A,P):"")+w(_[I],f));break;case f.doctypeKey:U.push(l(f,A,P)+C(_[I],f));break;case f.commentKey:U.push(l(f,A,P)+S(_[I],f));break;default:U.push(l(f,A,P)+m(_[I],O,f,A,R(_[I],f)))}P=P&&!U.length}return U.join("")}return De=function(y,f){f=r(f);var A=[];return e=y,i="_root_",f.compact?A.push(x(y,f,0,!0)):(y[f.declarationKey]&&A.push(a(y[f.declarationKey],f,0)),y[f.elementsKey]&&y[f.elementsKey].length&&A.push(k(y[f.elementsKey],f,0,!A.length))),A.join("")},De}var Oe,_i;function _r(){if(_i)return Oe;_i=1;var n=gi();return Oe=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 n(i,e)},Oe}var Re,xi;function xr(){if(xi)return Re;xi=1;var n=pi(),t=gr(),e=gi(),i=_r();return Re={xml2js:n,xml2json:t,js2xml:e,json2xml:i},Re}var Pe=xr(),wr=ai();const Dt=class Dt{constructor(t,e="",i=""){this.xml=t,this.filePath=e,this.basePath=i,this.layers=new Map,this.transform=r=>{if(!r)return;const l=r.attributes||r._attributes;if(!l)return r;let c={...r,...l,...Dt.propToNumber(l,["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"]),...Dt.propToBool(l,["visible","infinite","locked","bold","italic","kerning","strikeout","underline","wrap"])};if(c.properties){const g=Dt.toArray(c.properties.property),S={};for(let w of g){const C=w._attributes;if(!C)continue;let M;switch(C.type){case"file":M=this.getImagePath(C.value);break;case"object":case"float":case"int":M=+C.value;break;case"bool":M=C.value=="true";break;case"class":M={...this.transform(w)?.properties??{},_classname:C.propertytype};break;default:M=C.value}S[C.name]=M}c.properties=S}c.polygon&&(c.polygon=this.transform(c.polygon)),c.polyline&&(c.polyline=this.transform(c.polyline)),c.points&&(c=c.points.split(" ").map(g=>{const S=g.split(",");return{x:+S[0],y:+S[1]}})),c.point&&(c.point=!0),c.ellipse&&(c.ellipse=!0),c.text&&(c.text={text:c.text._text,...this.transform(c.text)},delete c.text._text),c.image&&(c.image=this.transform(c.image)),c.source&&(this.isTilesetSource(c)||(c.source=this.getImagePath(c.source)));const a=c.object||c.objectgroup?.object;return a&&(c.objects=Dt.toArray(a).map(g=>this.transform(g))),delete c._attributes,delete c.attributes,delete c.object,delete c.objectgroup,c}}static toArray(t){return t?Array.isArray(t)?t:[t]:[]}getImagePath(t){return this.filePath.startsWith("http")?new URL(t,this.filePath).href:ri(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 r=0;const l=[];for(let c=0;c<i;c+=4)l[r]=t.readUInt32LE(c),r++;return l}static decode(t,e){const{encoding:i,data:r}=t;return i=="base64"?Dt.unpackTileBytes(wr.Buffer.from(r.trim(),"base64"),e):i=="csv"?r.trim().split(",").map(l=>+l):r}parseMap(){const t=Pe.xml2js(this.xml,{compact:!0}),e=Pe.xml2js(this.xml),i=t.map.tileset;t.map.group;const r=S=>{const{objectgroup:w,group:C,layer:M,imagelayer:N}=S,F=k=>{k&&Dt.toArray(k).forEach(R=>{if(this.layers.has(+R._attributes.id))throw new Error(`Tiled Parser Error: Layer with id ${R._attributes.id} already exists`);this.layers.set(+R._attributes.id,R)})};F(w),F(M),F(C),F(N),C&&r(C)};r(t.map);const l=(S,w=[])=>{if(!S)return w;for(let C of S){const{name:M}=C;if(!["layer","group","imagelayer","objectgroup"].includes(M))continue;const N=C.elements?.find(k=>k.name=="data");C.layer=this.layers.get(+C.attributes.id);const F={...this.transform(N)??{},...this.transform(C),...this.transform(C.layer),layers:l(C.elements),data:N?N.elements[0].text:void 0,type:M=="layer"?"tilelayer":M};delete F.elements,delete F.layer,F.data&&(F.data=Dt.decode(F,F.width*F.height)),w.push(F)}return w},c=l(e.elements[0].elements),a=Dt.toArray(i).map(S=>this.transform(S)),g={...this.transform(t.map),layers:c,tilesets:a};return delete g.layer,delete g.tileset,delete g.group,delete g.imagelayer,g}parseTileset(){const t=Pe.xml2js(this.xml,{compact:!0}),{tileset:e}=t,i={...this.transform(e),image:this.transform(e.image),tiles:Dt.toArray(e.tile).map(r=>{const l=this.transform(r);return r.animation&&(l.animations=Dt.toArray(r.animation.frame).map(this.transform)),delete l.animation,l})};return delete i.tile,i}};Dt.propToNumber=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=+t[i]);return t},Dt.propToBool=(t,e)=>{for(let i of e)t[i]!==void 0&&(t[i]=t[i]=="true"||t[i]=="1");return t};let Ue=Dt;class ke{constructor(t){this.properties={},this.properties=t?.properties??{}}getProperty(t,e){const i=this.properties[t];return i===void 0?e:i}hasProperty(t){return!!this.properties[t]}setProperty(t,e){this.properties[t]=e}getType(){return this.class||this.type}}const Er=2147483648,vr=1073741824,br=536870912,Sr=268435456;class se extends ke{constructor(t){super(t),this.obj=t,this._gid=t?.gid}static getRealGid(t){return t&268435455}get horizontalFlip(){return!!(this._gid&Er)}get verticalFlip(){return!!(this._gid&vr)}get diagonalFlip(){return!!(this._gid&br)}get rotatedHex120(){return!!(this._gid&Sr)}get gid(){return se.getRealGid(this._gid)}set gid(t){this._gid=t}}let Le=class extends se{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 Ar extends se{constructor(t){super(t),this.layerName="",Object.assign(this,t),t?.gid&&(this.y-=this.height)}}class Ve extends ke{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 r=se.getRealGid(t),l=Ve.findTileSet(r,this.tilesets);if(!l)return;const c=l.getTile(r-l.firstgid);return c?new Le({...c.tile,gid:t,index:e,layerIndex:i}):new Le({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 Ar(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 r=e.length-1;r>=0&&(i=e[r],!(i.firstgid&&i.firstgid<=t));r--);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 Tr extends ke{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 Le(t);return this.cacheTileId.set(e.id,e),e}getTile(t){return this.cacheTileId.get(+t)}}class qt{constructor(t,{basePath:e="",staticDir:i="",relativePath:r=""}={}){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 r=a=>qt.typeOfFile(a).isXml,l=a=>{if(!a)return i(null);if(r(a)){const g=new Ue(a,t,this.basePath);if(e=="map"){const S=g.parseMap();return i(S)}else if(e=="tileset"){const S=g.parseTileset();return i(S)}}return i(JSON.parse(a))};if(qt.typeOfFile(t).isObject)return i(t);const{isHttp:c}=qt.typeOfFile(t);if(r(t))l(t);else if(c||qt.isBrowser()){let a=c?t:ri(this.basePath,t);qt.isBrowser()&&window.urlCache&&(a=window.urlCache[t]),fetch(a,{headers:{"Content-Type":"application/xml"}}).then(g=>g.text()).then(l).catch(g=>i(null,g))}}parseFile(t,e={}){const{getOnlyBasename:i}=e,r=l=>l.substring(l.lastIndexOf("/")+1);i&&qt.typeOfFile(this.file).isPath&&(this.file=r(this.file)),this._parseFile(this.file,"map",(l,c)=>{let a=!1;if(c)return t(null,c);if(l.tilesets){const g=[],S=()=>{w++,w==l.tilesets.length&&!a&&(l.tilesets=g,t(l))};let w=0;for(let C=0;C<l.tilesets.length;C++){const M=l.tilesets[C];if(!M.source||M.tiles||M.image||M.tile){g[C]=M,S();continue}i&&qt.typeOfFile(M.source).isPath&&(M.source=r(M.source)),this._parseFile(M.source,"tileset",(N,F)=>{if(F)return a=!0,t(null,F);g[C]={...N,firstgid:M.firstgid},S()})}}})}parseFilePromise(t={}){return new Promise((e,i)=>{this.parseFile((r,l)=>{r?e(r):i(l)},t)})}}const Wt={TEXTURES_PER_TILEMAP:16,use32bitIndex:!1};var Mr=Object.defineProperty,Cr=(n,t,e)=>t in n?Mr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,$t=(n,t,e)=>(Cr(n,typeof t!="symbol"?t+"":t,e),e);const oe=class ue extends L.Geometry{constructor(t){const e=new L.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:L.BufferUsage.VERTEX|L.BufferUsage.COPY_DST,shrinkToFit:!1}),i=ue.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:e,format:"float32x2",stride:i,offset:0},aTextureCoord:{buffer:e,format:"float32x2",stride:i,offset:8},aFrame:{buffer:e,format:"float32x4",stride:i,offset:16},aAnim:{buffer:e,format:"float32x2",stride:i,offset:32},aTextureId:{buffer:e,format:"sint32",stride:i,offset:40},aAnimDivisor:{buffer:e,format:"float32",stride:i,offset:44},aAlpha:{buffer:e,format:"float32",stride:i,offset:48}}}),$t(this,"lastTimeAccess",0),$t(this,"vertSize",ue.vertSize),$t(this,"vertPerQuad",ue.vertPerQuad),$t(this,"stride",ue.stride),$t(this,"buf"),this.buf=e}};$t(oe,"vertSize",13),$t(oe,"vertPerQuad",4),$t(oe,"stride",oe.vertSize*4);let Fr=oe;var Br=Object.defineProperty,Nr=(n,t,e)=>t in n?Br(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ht=(n,t,e)=>(Nr(n,typeof t!="symbol"?t+"":t,e),e);class wi{constructor(){Ht(this,"pipe_uniforms",new L.UniformGroup({u_proj_trans:{value:new L.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class Ei{constructor(t,e){Ht(this,"renderer"),Ht(this,"tileAnim",[0,0]),Ht(this,"ibLen",0),Ht(this,"indexBuffer",null),Ht(this,"shader"),Ht(this,"adaptor"),this.renderer=t,this.adaptor=e,this.adaptor.init(),this.indexBuffer=new L.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:L.BufferUsage.INDEX|L.BufferUsage.COPY_DST}),this.indexBuffer.destroy=L.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const t=new Fr(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=Ir(t,Wt.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,r=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let l=this.tileAnim;const{u_anim_frame:c}=e.uniforms;r.uProjectionMatrix.copyTo(i).append(r.uWorldTransformMatrix).append(t.worldTransform),t.compositeParent&&(l=t.parent.tileAnim||l),c[0]=l[0],c[1]=l[1],e.update(),this.adaptor.execute(this,t)}}Ht(Ei,"extension",{type:[L.ExtensionType.WebGLPipes,L.ExtensionType.WebGPUPipes],name:"tilemap"});function Ir(n,t){const e=n*6;if(t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,r=0;i<e;i+=6,r+=4)t[i+0]=r+0,t[i+1]=r+1,t[i+2]=r+2,t[i+3]=r+0,t[i+4]=r+2,t[i+5]=r+3;return t}var Dr=Object.defineProperty,Or=(n,t,e)=>t in n?Dr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,jt=(n,t,e)=>(Or(n,typeof t!="symbol"?t+"":t,e),e);class Zt{constructor(t){jt(this,"max_textures"),jt(this,"arr",[]),jt(this,"count",0),jt(this,"dirty",!1),jt(this,"dirty_gpu",!1),jt(this,"bind_group",null),jt(this,"bind_group_resources",{}),jt(this,"tex_sizes",null),jt(this,"null_color",new Float32Array([0,0,0,.5])),jt(this,"tex_buf",null),this.max_textures=t,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new L.Buffer({usage:L.BufferUsage.UNIFORM|L.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:r,null_color:l}=this;for(let c=0;c<i;c++){const a=e[c];a&&(t[c*4]=a.pixelWidth,t[c*4+1]=a.pixelHeight,t[c*4+2]=1/a.pixelWidth,t[c*4+3]=1/a.pixelHeight)}t[r*4]=l[0],t[r*4+1]=l[1],t[r*4+2]=l[2],t[r*4+3]=l[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:r}=this;let l=0;t[l++]=new L.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 c=0;c<e;c++){const a=(c<r?i[c]:null)||L.Texture.EMPTY.source;t[l++]=a.source,t[l++]=a.style}return this.bind_group||(this.bind_group=new L.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(`
97
- `)}static generate_gl_textures(t){const e=[];e.push(`uniform vec4 u_texture_size[${t+1}];`),e.push(`uniform sampler2D u_textures[${t}];`),e.push("uniform vec4 u_null_color;"),e.push("vec4 sampleMultiTexture(float texture_id, vec2 uv) {"),e.push(`if(texture_id < -0.5) return u_texture_size[${t}];`);for(let i=0;i<t;i++)e.push(`if(texture_id < ${i}.5) return texture(u_textures[${i}], uv * u_texture_size[${i}].zw);`);return e.push(`return u_texture_size[${t}];`),e.push("}"),e.join(`
98
- `)}static gl_gen_resources(t){const e=[];for(let r=0;r<t;r++)e[r]=r;const i=[];for(let r=0;r<t;r++)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 Rr=Object.defineProperty,Pr=(n,t,e)=>t in n?Rr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Ye=(n,t,e)=>(Pr(n,typeof t!="symbol"?t+"":t,e),e);const Ur=`
86
+ `,k=24,A=180,j=.75,M=.5,N=.35,P=new Float32Array([.08,.08,.14]),F=e=>{if(typeof e==`string`){let t=e.replace(/^#/,``);t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);let n=parseInt(t,16);return new Float32Array([(n>>16&255)/255,(n>>8&255)/255,(n&255)/255])}if(typeof e==`number`)return new Float32Array([(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]);if(Array.isArray(e)&&e.length>=3){let t=e.every(e=>e<=1);return new Float32Array(t?e:e.map(e=>e/255))}return new Float32Array([0,0,0])};function I(e,t){let r=new Float32Array(k*4),i={value:r,type:`vec4<f32>`,size:k},a={value:t?.darkness??j,type:`f32`},o={value:t?.fogColor?F(t.fogColor):P,type:`vec3<f32>`},s={value:t?.fogRadius??M,type:`f32`},c={value:t?.fogSoftness??N,type:`f32`},l={value:t?.darkColor?F(t.darkColor):new Float32Array([0,0,0]),type:`vec3<f32>`},u=t?.spots?[...t.spots]:[],d=t?.lightWorldPosition??null,f=n.Filter.from({gl:{vertex:O,fragment:D},resources:{nightUniforms:{uSpots:i,uDarkness:a,uDarkColor:l,uFogColor:o,uFogRadius:s,uFogSoftness:c}}}),p=(e,t,n)=>Math.min(Math.max(e,t),n),m=()=>Date.now()/1e3,h=()=>d?[{x:d.x,y:d.y},...u]:u,g=()=>{let n=h(),a=Math.min(n.length,k),o=e?.getVisibleBounds?.()??t?.getBounds?.(),s=!!o&&o.width>0&&o.height>0,c=e?.toScreen?.bind(e),l=s&&typeof c==`function`,u=0,d=0;if(l){let e=c(o.x,o.y);R(e?.x)&&R(e?.y)&&(u=e.x,d=e.y)}let f=m();r.fill(0);for(let e=0;e<a;e++){let t=n[e],i=t.radius??A,a=p(t.intensity??1,0,2),m=t.phase??e*.7,h=a;if(t.flicker){let e=t.flickerSpeed??12;h*=.88+.12*Math.sin(f*e+m)}if(t.pulse){let e=t.pulseSpeed??2;h*=.8+.2*Math.sin(f*e+m)}let g=t.x,_=t.y,v=i;if(l){let e=c(t.x,t.y);g=e.x-u,_=e.y-d}else s&&(g=t.x-o.x,_=t.y-o.y);let y=e*4;r[y]=g,r[y+1]=_,r[y+2]=v,r[y+3]=p(h,0,2)}i.value=r},_=f.apply.bind(f);f.apply=((...e)=>(g(),_(...e)));let v=f;return v.setLightWorldPosition=e=>{d=e,g()},v.getLightWorldPosition=()=>d,v.setSpots=e=>{u=[...e],g()},v.getSpots=()=>h().map(e=>({...e})),v.syncLightToViewport=g,v.setDarkness=e=>{a.value=e},v.setDarkColor=e=>{l.value=F(e)},v.setFogColor=e=>{o.value=F(e)},v.setFogRadius=e=>{s.value=e},v.setFogSoftness=e=>{c.value=e},g(),v}var L=e=>typeof e==`function`?e():e,R=e=>typeof e==`number`&&Number.isFinite(e),ee=e=>{let t=L(e);if(!t)return null;let n=L(t.x),r=L(t.y);if(!R(n)||!R(r))return null;let i=L(t.radius),a=L(t.intensity),o=L(t.flickerSpeed),s=L(t.pulseSpeed),c=L(t.phase);return{x:n,y:r,radius:R(i)?i:void 0,intensity:R(a)?a:void 0,flicker:!!L(t.flicker),flickerSpeed:R(o)?o:void 0,pulse:!!L(t.pulse),pulseSpeed:R(s)?s:void 0,phase:R(c)?c:void 0}},te=e=>{let t=L(e);return Array.isArray(t)?t.map(ee).filter(e=>!!e):[]},ne=e=>{if(!e)return null;if(typeof e.getVisibleBounds==`function`){let t=e.getVisibleBounds();if(t)return t}if(typeof e.getLocalBounds==`function`){let t=e.getLocalBounds();if(t)return t}return R(e.width)&&R(e.height)?{x:0,y:0,width:e.width,height:e.height}:null};function re(e={}){let n=(0,t.useProps)(e),r=()=>n.lightSpots??n.spots;return(0,t.mount)(e=>{let i=e.props.context,a=i?.viewport,o=a??e.parent?.componentInstance;if(!o)return;let s=i?.canvasSize,c=()=>{if(!a&&typeof s==`function`){let e=s();if(e&&R(e.width)&&R(e.height)&&e.width>0&&e.height>0)return{x:0,y:0,width:e.width,height:e.height}}return ne(o)},l=L(n.darkness),u=L(n.darkColor),d=L(n.fogColor),f=L(n.fogRadius),p=L(n.fogSoftness),m=I(a,{spots:te(r()),getBounds:c,darkness:R(l)?l:void 0,darkColor:u??void 0,fogColor:d??void 0,fogRadius:R(f)?f:void 0,fogSoftness:R(p)?p:void 0}),h=Array.isArray(o.filters)?o.filters:[];return h.includes(m)||(o.filters=[...h,m]),(0,t.effect)(()=>{m.setSpots(te(r()))}),(0,t.effect)(()=>{let e=L(n.darkness);R(e)&&m.setDarkness(e)}),(0,t.effect)(()=>{let e=L(n.darkColor);e!==void 0&&m.setDarkColor(e)}),(0,t.effect)(()=>{let e=L(n.fogColor);e!==void 0&&m.setFogColor(e)}),(0,t.effect)(()=>{let e=L(n.fogRadius);R(e)&&m.setFogRadius(e)}),(0,t.effect)(()=>{let e=L(n.fogSoftness);R(e)&&m.setFogSoftness(e)}),()=>{let e=(Array.isArray(o.filters)?o.filters:[]).filter(e=>e!==m);o.filters=e.length>0?e:null}}),(0,t.h)(t.Container)}function ie(e={}){let{size:n=30,color:r=`#3498db`,backgroundColor:i,speed:a=180,segments:o=8,segmentWidth:s=3,inactiveAlpha:c=.15}=(0,t.useProps)(e,{size:30,color:`#3498db`,speed:180,segments:8,segmentWidth:3,inactiveAlpha:.15}),l=(0,t.signal)(0);(0,t.tick)(({deltaTime:e})=>{let t=(typeof a==`function`?a():a)*e/1e3;l.set(l()+t)});let u=e=>{let t=typeof n==`function`?n():n,a=typeof r==`function`?r():r,u=i?typeof i==`function`?i():i:null,d=typeof o==`function`?o():o;typeof s==`function`&&s();let f=typeof c==`function`?c():c,p=l();u&&e.circle(0,0,t).fill(u);let m=360/d,h=t*.4,g=t;for(let t=0;t<d;t++){let n=t*m,r=(p%360+360)%360,i=Math.abs(r-n);i>180&&(i=360-i);let o=i/120;o=Math.min(1,o),o=o*o*o;let s=f+(1-o)*(1-f),c=Math.PI/180*n,l=Math.PI/180*m,u=c-l/2,d=c+l/2;e.arc(0,0,h,u,d).arc(0,0,g,d,u,!0).fill({color:a,alpha:s})}},d=(typeof n==`function`?n():n)*2,f=(0,t.signal)(d),p=(0,t.signal)(d);return typeof n==`function`&&(0,t.effect)(()=>{let e=n();f.set(e*2),p.set(e*2)}),(0,t.h)(t.Container,e,[(0,t.h)(t.Graphics,{draw:u})])}var z=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),B=function(e){return e.Tile=`tilelayer`,e.ObjectGroup=`objectgroup`,e.Image=`imagelayer`,e.Group=`group`,e}({});function ae(...e){return e.filter(e=>e&&e.length>0).join(`/`).replace(/\/+/g,`/`)}var oe=z(((e,t)=>{t.exports={}})),V=z((e=>{(function(e){e.parser=function(e,t){return new n(e,t)},e.SAXParser=n,e.SAXStream=l,e.createStream=c,e.MAX_BUFFER_LENGTH=64*1024;var t=[`comment`,`sgmlDecl`,`textNode`,`tagName`,`doctype`,`procInstName`,`procInstBody`,`entity`,`attribName`,`attribValue`,`cdata`,`script`];e.EVENTS=[`text`,`processinginstruction`,`sgmldeclaration`,`doctype`,`comment`,`opentagstart`,`attribute`,`opentag`,`closetag`,`opencdata`,`cdata`,`closecdata`,`error`,`end`,`ready`,`script`,`opennamespace`,`closenamespace`];function n(t,r){if(!(this instanceof n))return new n(t,r);var a=this;i(a),a.q=a.c=``,a.bufferCheckPosition=e.MAX_BUFFER_LENGTH,a.opt=r||{},a.opt.lowercase=a.opt.lowercase||a.opt.lowercasetags,a.looseCase=a.opt.lowercase?`toLowerCase`:`toUpperCase`,a.tags=[],a.closed=a.closedRoot=a.sawRoot=!1,a.tag=a.error=null,a.strict=!!t,a.noscript=!!(t||a.opt.noscript),a.state=w.BEGIN,a.strictEntities=a.opt.strictEntities,a.ENTITIES=a.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),a.attribList=[],a.opt.xmlns&&(a.ns=Object.create(m)),a.opt.unquotedAttributeValues===void 0&&(a.opt.unquotedAttributeValues=!t),a.trackPosition=a.opt.position!==!1,a.trackPosition&&(a.position=a.line=a.column=0),E(a,`onready`)}Object.create||(Object.create=function(e){function t(){}return t.prototype=e,new t}),Object.keys||(Object.keys=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t});function r(n){for(var r=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,a=0,o=t.length;a<o;a++){var s=n[t[a]].length;if(s>r)switch(t[a]){case`textNode`:O(n);break;case`cdata`:D(n,`oncdata`,n.cdata),n.cdata=``;break;case`script`:D(n,`onscript`,n.script),n.script=``;break;default:A(n,`Max buffer length exceeded: `+t[a])}i=Math.max(i,s)}n.bufferCheckPosition=e.MAX_BUFFER_LENGTH-i+n.position}function i(e){for(var n=0,r=t.length;n<r;n++)e[t[n]]=``}function a(e){O(e),e.cdata!==``&&(D(e,`oncdata`,e.cdata),e.cdata=``),e.script!==``&&(D(e,`onscript`,e.script),e.script=``)}n.prototype={end:function(){j(this)},write:ne,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=oe().Stream}catch{o=function(){}}o||=function(){};var s=e.EVENTS.filter(function(e){return e!==`error`&&e!==`end`});function c(e,t){return new l(e,t)}function l(e,t){if(!(this instanceof l))return new l(e,t);o.apply(this),this._parser=new n(e,t),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit(`end`)},this._parser.onerror=function(e){r.emit(`error`,e),r._parser.error=null},this._decoder=null,s.forEach(function(e){Object.defineProperty(r,`on`+e,{get:function(){return r._parser[`on`+e]},set:function(t){if(!t)return r.removeAllListeners(e),r._parser[`on`+e]=t,t;r.on(e,t)},enumerable:!0,configurable:!1})})}l.prototype=Object.create(o.prototype,{constructor:{value:l}}),l.prototype.write=function(e){if(typeof Buffer==`function`&&typeof Buffer.isBuffer==`function`&&Buffer.isBuffer(e)){if(!this._decoder){var t=oe().StringDecoder;this._decoder=new t(`utf8`)}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit(`data`,e),!0},l.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},l.prototype.on=function(e,t){var n=this;return!n._parser[`on`+e]&&s.indexOf(e)!==-1&&(n._parser[`on`+e]=function(){var t=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),n.emit.apply(n,t)}),o.prototype.on.call(n,e,t)};var u=`[CDATA[`,d=`DOCTYPE`,f=`http://www.w3.org/XML/1998/namespace`,p=`http://www.w3.org/2000/xmlns/`,m={xml:f,xmlns:p},h=/[:_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]/,g=/[:_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-]/,_=/[#:_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]/,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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function y(e){return e===` `||e===`
87
+ `||e===`\r`||e===` `}function b(e){return e===`"`||e===`'`}function x(e){return e===`>`||y(e)}function S(e,t){return e.test(t)}function C(e,t){return!S(e,t)}var w=0;for(var T in e.STATE={BEGIN:w++,BEGIN_WHITESPACE:w++,TEXT:w++,TEXT_ENTITY:w++,OPEN_WAKA:w++,SGML_DECL:w++,SGML_DECL_QUOTED:w++,DOCTYPE:w++,DOCTYPE_QUOTED:w++,DOCTYPE_DTD:w++,DOCTYPE_DTD_QUOTED:w++,COMMENT_STARTING:w++,COMMENT:w++,COMMENT_ENDING:w++,COMMENT_ENDED:w++,CDATA:w++,CDATA_ENDING:w++,CDATA_ENDING_2:w++,PROC_INST:w++,PROC_INST_BODY:w++,PROC_INST_ENDING:w++,OPEN_TAG:w++,OPEN_TAG_SLASH:w++,ATTRIB:w++,ATTRIB_NAME:w++,ATTRIB_NAME_SAW_WHITE:w++,ATTRIB_VALUE:w++,ATTRIB_VALUE_QUOTED:w++,ATTRIB_VALUE_CLOSED:w++,ATTRIB_VALUE_UNQUOTED:w++,ATTRIB_VALUE_ENTITY_Q:w++,ATTRIB_VALUE_ENTITY_U:w++,CLOSE_TAG:w++,CLOSE_TAG_SAW_WHITE:w++,SCRIPT:w++,SCRIPT_ENDING:w++},e.XML_ENTITIES={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`},e.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(e.ENTITIES).forEach(function(t){var n=e.ENTITIES[t],r=typeof n==`number`?String.fromCharCode(n):n;e.ENTITIES[t]=r}),e.STATE)e.STATE[e.STATE[T]]=T;w=e.STATE;function E(e,t,n){e[t]&&e[t](n)}function D(e,t,n){e.textNode&&O(e),E(e,t,n)}function O(e){e.textNode=k(e.opt,e.textNode),e.textNode&&E(e,`ontext`,e.textNode),e.textNode=``}function k(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g,` `)),t}function A(e,t){return O(e),e.trackPosition&&(t+=`
88
+ Line: `+e.line+`
89
+ Column: `+e.column+`
90
+ Char: `+e.c),t=Error(t),e.error=t,E(e,`onerror`,t),e}function j(e){return e.sawRoot&&!e.closedRoot&&M(e,`Unclosed root tag`),e.state!==w.BEGIN&&e.state!==w.BEGIN_WHITESPACE&&e.state!==w.TEXT&&A(e,`Unexpected end`),O(e),e.c=``,e.closed=!0,E(e,`onend`),n.call(e,e.strict,e.opt),e}function M(e,t){if(typeof e!=`object`||!(e instanceof n))throw Error(`bad call to strictFail`);e.strict&&A(e,t)}function N(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,n=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(n.ns=t.ns),e.attribList.length=0,D(e,`onopentagstart`,n)}function P(e,t){var n=e.indexOf(`:`)<0?[``,e]:e.split(`:`),r=n[0],i=n[1];return t&&e===`xmlns`&&(r=`xmlns`,i=``),{prefix:r,local:i}}function F(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),e.attribList.indexOf(e.attribName)!==-1||e.tag.attributes.hasOwnProperty(e.attribName)){e.attribName=e.attribValue=``;return}if(e.opt.xmlns){var t=P(e.attribName,!0),n=t.prefix,r=t.local;if(n===`xmlns`)if(r===`xml`&&e.attribValue!==f)M(e,`xml: prefix must be bound to `+f+`
91
+ Actual: `+e.attribValue);else if(r===`xmlns`&&e.attribValue!==p)M(e,`xmlns: prefix must be bound to `+p+`
92
+ Actual: `+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.ns&&(i.ns=Object.create(a.ns)),i.ns[r]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,D(e,`onattribute`,{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=``}function I(e,t){if(e.opt.xmlns){var n=e.tag,r=P(e.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||``,n.prefix&&!n.uri&&(M(e,`Unbound namespace prefix: `+JSON.stringify(e.tagName)),n.uri=r.prefix);var i=e.tags[e.tags.length-1]||e;n.ns&&i.ns!==n.ns&&Object.keys(n.ns).forEach(function(t){D(e,`onopennamespace`,{prefix:t,uri:n.ns[t]})});for(var a=0,o=e.attribList.length;a<o;a++){var s=e.attribList[a],c=s[0],l=s[1],u=P(c,!0),d=u.prefix,f=u.local,p=d===``?``:n.ns[d]||``,m={name:c,value:l,prefix:d,local:f,uri:p};d&&d!==`xmlns`&&!p&&(M(e,`Unbound namespace prefix: `+JSON.stringify(d)),m.uri=d),e.tag.attributes[c]=m,D(e,`onattribute`,m)}e.attribList.length=0}e.tag.isSelfClosing=!!t,e.sawRoot=!0,e.tags.push(e.tag),D(e,`onopentag`,e.tag),t||(!e.noscript&&e.tagName.toLowerCase()===`script`?e.state=w.SCRIPT:e.state=w.TEXT,e.tag=null,e.tagName=``),e.attribName=e.attribValue=``,e.attribList.length=0}function L(e){if(!e.tagName){M(e,`Weird empty close tag.`),e.textNode+=`</>`,e.state=w.TEXT;return}if(e.script){if(e.tagName!==`script`){e.script+=`</`+e.tagName+`>`,e.tagName=``,e.state=w.SCRIPT;return}D(e,`onscript`,e.script),e.script=``}var t=e.tags.length,n=e.tagName;e.strict||(n=n[e.looseCase]());for(var r=n;t--&&e.tags[t].name!==r;)M(e,`Unexpected close tag`);if(t<0){M(e,`Unmatched closing tag: `+e.tagName),e.textNode+=`</`+e.tagName+`>`,e.state=w.TEXT;return}e.tagName=n;for(var i=e.tags.length;i-- >t;){var a=e.tag=e.tags.pop();e.tagName=e.tag.name,D(e,`onclosetag`,e.tagName);var o={};for(var s in a.ns)o[s]=a.ns[s];var c=e.tags[e.tags.length-1]||e;e.opt.xmlns&&a.ns!==c.ns&&Object.keys(a.ns).forEach(function(t){var n=a.ns[t];D(e,`onclosenamespace`,{prefix:t,uri:n})})}t===0&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName=``,e.attribList.length=0,e.state=w.TEXT}function R(e){var t=e.entity,n=t.toLowerCase(),r,i=``;return e.ENTITIES[t]?e.ENTITIES[t]:e.ENTITIES[n]?e.ENTITIES[n]:(t=n,t.charAt(0)===`#`&&(t.charAt(1)===`x`?(t=t.slice(2),r=parseInt(t,16),i=r.toString(16)):(t=t.slice(1),r=parseInt(t,10),i=r.toString(10))),t=t.replace(/^0+/,``),isNaN(r)||i.toLowerCase()!==t?(M(e,`Invalid character entity`),`&`+e.entity+`;`):String.fromCodePoint(r))}function ee(e,t){t===`<`?(e.state=w.OPEN_WAKA,e.startTagPosition=e.position):y(t)||(M(e,`Non-whitespace before first tag.`),e.textNode=t,e.state=w.TEXT)}function te(e,t){var n=``;return t<e.length&&(n=e.charAt(t)),n}function ne(t){var n=this;if(this.error)throw this.error;if(n.closed)return A(n,`Cannot write after close. Assign an onready handler.`);if(t===null)return j(n);typeof t==`object`&&(t=t.toString());for(var i=0,a=``;a=te(t,i++),n.c=a,a;)switch(n.trackPosition&&(n.position++,a===`
93
+ `?(n.line++,n.column=0):n.column++),n.state){case w.BEGIN:if(n.state=w.BEGIN_WHITESPACE,a===``)continue;ee(n,a);continue;case w.BEGIN_WHITESPACE:ee(n,a);continue;case w.TEXT:if(n.sawRoot&&!n.closedRoot){for(var o=i-1;a&&a!==`<`&&a!==`&`;)a=te(t,i++),a&&n.trackPosition&&(n.position++,a===`
94
+ `?(n.line++,n.column=0):n.column++);n.textNode+=t.substring(o,i-1)}a===`<`&&!(n.sawRoot&&n.closedRoot&&!n.strict)?(n.state=w.OPEN_WAKA,n.startTagPosition=n.position):(!y(a)&&(!n.sawRoot||n.closedRoot)&&M(n,`Text data outside of root node.`),a===`&`?n.state=w.TEXT_ENTITY:n.textNode+=a);continue;case w.SCRIPT:a===`<`?n.state=w.SCRIPT_ENDING:n.script+=a;continue;case w.SCRIPT_ENDING:a===`/`?n.state=w.CLOSE_TAG:(n.script+=`<`+a,n.state=w.SCRIPT);continue;case w.OPEN_WAKA:if(a===`!`)n.state=w.SGML_DECL,n.sgmlDecl=``;else if(!y(a))if(S(h,a))n.state=w.OPEN_TAG,n.tagName=a;else if(a===`/`)n.state=w.CLOSE_TAG,n.tagName=``;else if(a===`?`)n.state=w.PROC_INST,n.procInstName=n.procInstBody=``;else{if(M(n,`Unencoded <`),n.startTagPosition+1<n.position){var s=n.position-n.startTagPosition;a=Array(s).join(` `)+a}n.textNode+=`<`+a,n.state=w.TEXT}continue;case w.SGML_DECL:if(n.sgmlDecl+a===`--`){n.state=w.COMMENT,n.comment=``,n.sgmlDecl=``;continue}n.doctype&&n.doctype!==!0&&n.sgmlDecl?(n.state=w.DOCTYPE_DTD,n.doctype+=`<!`+n.sgmlDecl+a,n.sgmlDecl=``):(n.sgmlDecl+a).toUpperCase()===u?(D(n,`onopencdata`),n.state=w.CDATA,n.sgmlDecl=``,n.cdata=``):(n.sgmlDecl+a).toUpperCase()===d?(n.state=w.DOCTYPE,(n.doctype||n.sawRoot)&&M(n,`Inappropriately located doctype declaration`),n.doctype=``,n.sgmlDecl=``):a===`>`?(D(n,`onsgmldeclaration`,n.sgmlDecl),n.sgmlDecl=``,n.state=w.TEXT):(b(a)&&(n.state=w.SGML_DECL_QUOTED),n.sgmlDecl+=a);continue;case w.SGML_DECL_QUOTED:a===n.q&&(n.state=w.SGML_DECL,n.q=``),n.sgmlDecl+=a;continue;case w.DOCTYPE:a===`>`?(n.state=w.TEXT,D(n,`ondoctype`,n.doctype),n.doctype=!0):(n.doctype+=a,a===`[`?n.state=w.DOCTYPE_DTD:b(a)&&(n.state=w.DOCTYPE_QUOTED,n.q=a));continue;case w.DOCTYPE_QUOTED:n.doctype+=a,a===n.q&&(n.q=``,n.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:a===`]`?(n.doctype+=a,n.state=w.DOCTYPE):a===`<`?(n.state=w.OPEN_WAKA,n.startTagPosition=n.position):b(a)?(n.doctype+=a,n.state=w.DOCTYPE_DTD_QUOTED,n.q=a):n.doctype+=a;continue;case w.DOCTYPE_DTD_QUOTED:n.doctype+=a,a===n.q&&(n.state=w.DOCTYPE_DTD,n.q=``);continue;case w.COMMENT:a===`-`?n.state=w.COMMENT_ENDING:n.comment+=a;continue;case w.COMMENT_ENDING:a===`-`?(n.state=w.COMMENT_ENDED,n.comment=k(n.opt,n.comment),n.comment&&D(n,`oncomment`,n.comment),n.comment=``):(n.comment+=`-`+a,n.state=w.COMMENT);continue;case w.COMMENT_ENDED:a===`>`?n.doctype&&n.doctype!==!0?n.state=w.DOCTYPE_DTD:n.state=w.TEXT:(M(n,`Malformed comment`),n.comment+=`--`+a,n.state=w.COMMENT);continue;case w.CDATA:a===`]`?n.state=w.CDATA_ENDING:n.cdata+=a;continue;case w.CDATA_ENDING:a===`]`?n.state=w.CDATA_ENDING_2:(n.cdata+=`]`+a,n.state=w.CDATA);continue;case w.CDATA_ENDING_2:a===`>`?(n.cdata&&D(n,`oncdata`,n.cdata),D(n,`onclosecdata`),n.cdata=``,n.state=w.TEXT):a===`]`?n.cdata+=`]`:(n.cdata+=`]]`+a,n.state=w.CDATA);continue;case w.PROC_INST:a===`?`?n.state=w.PROC_INST_ENDING:y(a)?n.state=w.PROC_INST_BODY:n.procInstName+=a;continue;case w.PROC_INST_BODY:if(!n.procInstBody&&y(a))continue;a===`?`?n.state=w.PROC_INST_ENDING:n.procInstBody+=a;continue;case w.PROC_INST_ENDING:a===`>`?(D(n,`onprocessinginstruction`,{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody=``,n.state=w.TEXT):(n.procInstBody+=`?`+a,n.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:S(g,a)?n.tagName+=a:(N(n),a===`>`?I(n):a===`/`?n.state=w.OPEN_TAG_SLASH:(y(a)||M(n,`Invalid character in tag name`),n.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:a===`>`?(I(n,!0),L(n)):(M(n,`Forward-slash in opening tag not followed by >`),n.state=w.ATTRIB);continue;case w.ATTRIB:if(y(a))continue;a===`>`?I(n):a===`/`?n.state=w.OPEN_TAG_SLASH:S(h,a)?(n.attribName=a,n.attribValue=``,n.state=w.ATTRIB_NAME):M(n,`Invalid attribute name`);continue;case w.ATTRIB_NAME:a===`=`?n.state=w.ATTRIB_VALUE:a===`>`?(M(n,`Attribute without value`),n.attribValue=n.attribName,F(n),I(n)):y(a)?n.state=w.ATTRIB_NAME_SAW_WHITE:S(g,a)?n.attribName+=a:M(n,`Invalid attribute name`);continue;case w.ATTRIB_NAME_SAW_WHITE:if(a===`=`)n.state=w.ATTRIB_VALUE;else if(y(a))continue;else M(n,`Attribute without value`),n.tag.attributes[n.attribName]=``,n.attribValue=``,D(n,`onattribute`,{name:n.attribName,value:``}),n.attribName=``,a===`>`?I(n):S(h,a)?(n.attribName=a,n.state=w.ATTRIB_NAME):(M(n,`Invalid attribute name`),n.state=w.ATTRIB);continue;case w.ATTRIB_VALUE:if(y(a))continue;b(a)?(n.q=a,n.state=w.ATTRIB_VALUE_QUOTED):(n.opt.unquotedAttributeValues||A(n,`Unquoted attribute value`),n.state=w.ATTRIB_VALUE_UNQUOTED,n.attribValue=a);continue;case w.ATTRIB_VALUE_QUOTED:if(a!==n.q){a===`&`?n.state=w.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=a;continue}F(n),n.q=``,n.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:y(a)?n.state=w.ATTRIB:a===`>`?I(n):a===`/`?n.state=w.OPEN_TAG_SLASH:S(h,a)?(M(n,`No whitespace between attributes`),n.attribName=a,n.attribValue=``,n.state=w.ATTRIB_NAME):M(n,`Invalid attribute name`);continue;case w.ATTRIB_VALUE_UNQUOTED:if(!x(a)){a===`&`?n.state=w.ATTRIB_VALUE_ENTITY_U:n.attribValue+=a;continue}F(n),a===`>`?I(n):n.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(n.tagName)a===`>`?L(n):S(g,a)?n.tagName+=a:n.script?(n.script+=`</`+n.tagName,n.tagName=``,n.state=w.SCRIPT):(y(a)||M(n,`Invalid tagname in closing tag`),n.state=w.CLOSE_TAG_SAW_WHITE);else{if(y(a))continue;C(h,a)?n.script?(n.script+=`</`+a,n.state=w.SCRIPT):M(n,`Invalid tagname in closing tag.`):n.tagName=a}continue;case w.CLOSE_TAG_SAW_WHITE:if(y(a))continue;a===`>`?L(n):M(n,`Invalid characters in closing tag`);continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var c,l;switch(n.state){case w.TEXT_ENTITY:c=w.TEXT,l=`textNode`;break;case w.ATTRIB_VALUE_ENTITY_Q:c=w.ATTRIB_VALUE_QUOTED,l=`attribValue`;break;case w.ATTRIB_VALUE_ENTITY_U:c=w.ATTRIB_VALUE_UNQUOTED,l=`attribValue`;break}if(a===`;`){var f=R(n);n.opt.unparsedEntities&&!Object.values(e.XML_ENTITIES).includes(f)?(n.entity=``,n.state=c,n.write(f)):(n[l]+=f,n.entity=``,n.state=c)}else S(n.entity.length?v:_,a)?n.entity+=a:(M(n,`Invalid character in entity name`),n[l]+=`&`+n.entity+a,n.entity=``,n.state=c);continue;default:throw Error(n,`Unknown state: `+n.state)}return n.position>=n.bufferCheckPosition&&r(n),n}String.fromCodePoint||(function(){var e=String.fromCharCode,t=Math.floor,n=function(){var n=16384,r=[],i,a,o=-1,s=arguments.length;if(!s)return``;for(var c=``;++o<s;){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||t(l)!==l)throw RangeError(`Invalid code point: `+l);l<=65535?r.push(l):(l-=65536,i=(l>>10)+55296,a=l%1024+56320,r.push(i,a)),(o+1===s||r.length>n)&&(c+=e.apply(null,r),r.length=0)}return c};Object.defineProperty?Object.defineProperty(String,`fromCodePoint`,{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n})()})(e===void 0?e.sax={}:e)})),se=z(((e,t)=>{t.exports={isArray:function(e){return Array.isArray?Array.isArray(e):Object.prototype.toString.call(e)===`[object Array]`}}})),ce=z(((e,t)=>{var n=se().isArray;t.exports={copyOptions:function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n},ensureFlagExists:function(e,t){(!(e in t)||typeof t[e]!=`boolean`)&&(t[e]=!1)},ensureSpacesExists:function(e){(!(`spaces`in e)||typeof e.spaces!=`number`&&typeof e.spaces!=`string`)&&(e.spaces=0)},ensureAlwaysArrayExists:function(e){(!(`alwaysArray`in e)||typeof e.alwaysArray!=`boolean`&&!n(e.alwaysArray))&&(e.alwaysArray=!1)},ensureKeyExists:function(e,t){(!(e+`Key`in t)||typeof t[e+`Key`]!=`string`)&&(t[e+`Key`]=t.compact?`_`+e:e)},checkFnExists:function(e,t){return e+`Fn`in t}}})),le=z(((e,t)=>{var n=V(),r={on:function(){},parse:function(){}},i=ce(),a=se().isArray,o,s=!0,c;function l(e){return o=i.copyOptions(e),i.ensureFlagExists(`ignoreDeclaration`,o),i.ensureFlagExists(`ignoreInstruction`,o),i.ensureFlagExists(`ignoreAttributes`,o),i.ensureFlagExists(`ignoreText`,o),i.ensureFlagExists(`ignoreComment`,o),i.ensureFlagExists(`ignoreCdata`,o),i.ensureFlagExists(`ignoreDoctype`,o),i.ensureFlagExists(`compact`,o),i.ensureFlagExists(`alwaysChildren`,o),i.ensureFlagExists(`addParent`,o),i.ensureFlagExists(`trim`,o),i.ensureFlagExists(`nativeType`,o),i.ensureFlagExists(`nativeTypeAttributes`,o),i.ensureFlagExists(`sanitize`,o),i.ensureFlagExists(`instructionHasAttributes`,o),i.ensureFlagExists(`captureSpacesBetweenElements`,o),i.ensureAlwaysArrayExists(o),i.ensureKeyExists(`declaration`,o),i.ensureKeyExists(`instruction`,o),i.ensureKeyExists(`attributes`,o),i.ensureKeyExists(`text`,o),i.ensureKeyExists(`comment`,o),i.ensureKeyExists(`cdata`,o),i.ensureKeyExists(`doctype`,o),i.ensureKeyExists(`type`,o),i.ensureKeyExists(`name`,o),i.ensureKeyExists(`elements`,o),i.ensureKeyExists(`parent`,o),i.checkFnExists(`doctype`,o),i.checkFnExists(`instruction`,o),i.checkFnExists(`cdata`,o),i.checkFnExists(`comment`,o),i.checkFnExists(`text`,o),i.checkFnExists(`instructionName`,o),i.checkFnExists(`elementName`,o),i.checkFnExists(`attributeName`,o),i.checkFnExists(`attributeValue`,o),i.checkFnExists(`attributes`,o),o}function u(e){var t=Number(e);if(!isNaN(t))return t;var n=e.toLowerCase();return n===`true`?!0:n===`false`?!1:e}function d(e,t){var n;if(o.compact){if(!c[o[e+`Key`]]&&(a(o.alwaysArray)?o.alwaysArray.indexOf(o[e+`Key`])!==-1:o.alwaysArray)&&(c[o[e+`Key`]]=[]),c[o[e+`Key`]]&&!a(c[o[e+`Key`]])&&(c[o[e+`Key`]]=[c[o[e+`Key`]]]),e+`Fn`in o&&typeof t==`string`&&(t=o[e+`Fn`](t,c)),e===`instruction`&&(`instructionFn`in o||`instructionNameFn`in o)){for(n in t)if(t.hasOwnProperty(n))if(`instructionFn`in o)t[n]=o.instructionFn(t[n],n,c);else{var r=t[n];delete t[n],t[o.instructionNameFn(n,r,c)]=r}}a(c[o[e+`Key`]])?c[o[e+`Key`]].push(t):c[o[e+`Key`]]=t}else{c[o.elementsKey]||(c[o.elementsKey]=[]);var i={};if(i[o.typeKey]=e,e===`instruction`){for(n in t)if(t.hasOwnProperty(n))break;i[o.nameKey]=`instructionNameFn`in o?o.instructionNameFn(n,t,c):n,o.instructionHasAttributes?(i[o.attributesKey]=t[n][o.attributesKey],`instructionFn`in o&&(i[o.attributesKey]=o.instructionFn(i[o.attributesKey],n,c))):(`instructionFn`in o&&(t[n]=o.instructionFn(t[n],n,c)),i[o.instructionKey]=t[n])}else e+`Fn`in o&&(t=o[e+`Fn`](t,c)),i[o[e+`Key`]]=t;o.addParent&&(i[o.parentKey]=c),c[o.elementsKey].push(i)}}function f(e){if(`attributesFn`in o&&e&&(e=o.attributesFn(e,c)),(o.trim||`attributeValueFn`in o||`attributeNameFn`in o||o.nativeTypeAttributes)&&e){for(var t in e)if(e.hasOwnProperty(t)&&(o.trim&&(e[t]=e[t].trim()),o.nativeTypeAttributes&&(e[t]=u(e[t])),`attributeValueFn`in o&&(e[t]=o.attributeValueFn(e[t],t,c)),`attributeNameFn`in o)){var n=e[t];delete e[t],e[o.attributeNameFn(t,e[t],c)]=n}}return e}function p(e){var t={};if(e.body&&(e.name.toLowerCase()===`xml`||o.instructionHasAttributes)){for(var n=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,r;(r=n.exec(e.body))!==null;)t[r[1]]=r[2]||r[3]||r[4];t=f(t)}if(e.name.toLowerCase()===`xml`){if(o.ignoreDeclaration)return;c[o.declarationKey]={},Object.keys(t).length&&(c[o.declarationKey][o.attributesKey]=t),o.addParent&&(c[o.declarationKey][o.parentKey]=c)}else{if(o.ignoreInstruction)return;o.trim&&(e.body=e.body.trim());var i={};o.instructionHasAttributes&&Object.keys(t).length?(i[e.name]={},i[e.name][o.attributesKey]=t):i[e.name]=e.body,d(`instruction`,i)}}function m(e,t){var n;if(typeof e==`object`&&(t=e.attributes,e=e.name),t=f(t),`elementNameFn`in o&&(e=o.elementNameFn(e,c)),o.compact){if(n={},!o.ignoreAttributes&&t&&Object.keys(t).length)for(var r in n[o.attributesKey]={},t)t.hasOwnProperty(r)&&(n[o.attributesKey][r]=t[r]);!(e in c)&&(a(o.alwaysArray)?o.alwaysArray.indexOf(e)!==-1:o.alwaysArray)&&(c[e]=[]),c[e]&&!a(c[e])&&(c[e]=[c[e]]),a(c[e])?c[e].push(n):c[e]=n}else c[o.elementsKey]||(c[o.elementsKey]=[]),n={},n[o.typeKey]=`element`,n[o.nameKey]=e,!o.ignoreAttributes&&t&&Object.keys(t).length&&(n[o.attributesKey]=t),o.alwaysChildren&&(n[o.elementsKey]=[]),c[o.elementsKey].push(n);n[o.parentKey]=c,c=n}function h(e){o.ignoreText||!e.trim()&&!o.captureSpacesBetweenElements||(o.trim&&(e=e.trim()),o.nativeType&&(e=u(e)),o.sanitize&&(e=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)),d(`text`,e))}function g(e){o.ignoreComment||(o.trim&&(e=e.trim()),d(`comment`,e))}function _(e){var t=c[o.parentKey];o.addParent||delete c[o.parentKey],c=t}function v(e){o.ignoreCdata||(o.trim&&(e=e.trim()),d(`cdata`,e))}function y(e){o.ignoreDoctype||(e=e.replace(/^ /,``),o.trim&&(e=e.trim()),d(`doctype`,e))}function b(e){e.note=e}t.exports=function(e,t){var i=s?n.parser(!0,{}):i=new r.Parser(`UTF-8`),a={};if(c=a,o=l(t),s?(i.opt={strictEntities:!0},i.onopentag=m,i.ontext=h,i.oncomment=g,i.onclosetag=_,i.onerror=b,i.oncdata=v,i.ondoctype=y,i.onprocessinginstruction=p):(i.on(`startElement`,m),i.on(`text`,h),i.on(`comment`,g),i.on(`endElement`,_),i.on(`error`,b)),s)i.write(e).close();else if(!i.parse(e))throw Error(`XML parsing error: `+i.getError());if(a[o.elementsKey]){var u=a[o.elementsKey];delete a[o.elementsKey],a[o.elementsKey]=u,delete a.text}return a}})),ue=z(((e,t)=>{var n=ce(),r=le();function i(e){var t=n.copyOptions(e);return n.ensureSpacesExists(t),t}t.exports=function(e,t){var n=i(t),a=r(e,n),o,s=`compact`in n&&n.compact?`_parent`:`parent`;return o=`addParent`in n&&n.addParent?JSON.stringify(a,function(e,t){return e===s?`_`:t},n.spaces):JSON.stringify(a,null,n.spaces),o.replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}})),de=z(((e,t)=>{var n=ce(),r=se().isArray,i,a;function o(e){var t=n.copyOptions(e);return n.ensureFlagExists(`ignoreDeclaration`,t),n.ensureFlagExists(`ignoreInstruction`,t),n.ensureFlagExists(`ignoreAttributes`,t),n.ensureFlagExists(`ignoreText`,t),n.ensureFlagExists(`ignoreComment`,t),n.ensureFlagExists(`ignoreCdata`,t),n.ensureFlagExists(`ignoreDoctype`,t),n.ensureFlagExists(`compact`,t),n.ensureFlagExists(`indentText`,t),n.ensureFlagExists(`indentCdata`,t),n.ensureFlagExists(`indentAttributes`,t),n.ensureFlagExists(`indentInstruction`,t),n.ensureFlagExists(`fullTagEmptyElement`,t),n.ensureFlagExists(`noQuotesForNativeAttributes`,t),n.ensureSpacesExists(t),typeof t.spaces==`number`&&(t.spaces=Array(t.spaces+1).join(` `)),n.ensureKeyExists(`declaration`,t),n.ensureKeyExists(`instruction`,t),n.ensureKeyExists(`attributes`,t),n.ensureKeyExists(`text`,t),n.ensureKeyExists(`comment`,t),n.ensureKeyExists(`cdata`,t),n.ensureKeyExists(`doctype`,t),n.ensureKeyExists(`type`,t),n.ensureKeyExists(`name`,t),n.ensureKeyExists(`elements`,t),n.checkFnExists(`doctype`,t),n.checkFnExists(`instruction`,t),n.checkFnExists(`cdata`,t),n.checkFnExists(`comment`,t),n.checkFnExists(`text`,t),n.checkFnExists(`instructionName`,t),n.checkFnExists(`elementName`,t),n.checkFnExists(`attributeName`,t),n.checkFnExists(`attributeValue`,t),n.checkFnExists(`attributes`,t),n.checkFnExists(`fullTagEmptyElement`,t),t}function s(e,t,n){return(!n&&e.spaces?`
95
+ `:``)+Array(t+1).join(e.spaces)}function c(e,t,n){if(t.ignoreAttributes)return``;`attributesFn`in t&&(e=t.attributesFn(e,a,i));var r,o,c,l,u=[];for(r in e)e.hasOwnProperty(r)&&e[r]!==null&&e[r]!==void 0&&(l=t.noQuotesForNativeAttributes&&typeof e[r]!=`string`?``:`"`,o=``+e[r],o=o.replace(/"/g,`&quot;`),c=`attributeNameFn`in t?t.attributeNameFn(r,o,a,i):r,u.push(t.spaces&&t.indentAttributes?s(t,n+1,!1):` `),u.push(c+`=`+l+(`attributeValueFn`in t?t.attributeValueFn(o,r,a,i):o)+l));return e&&Object.keys(e).length&&t.spaces&&t.indentAttributes&&u.push(s(t,n,!1)),u.join(``)}function l(e,t,n){return i=e,a=`xml`,t.ignoreDeclaration?``:`<?xml`+c(e[t.attributesKey],t,n)+`?>`}function u(e,t,n){if(t.ignoreInstruction)return``;for(var r in e)if(e.hasOwnProperty(r))break;var o=`instructionNameFn`in t?t.instructionNameFn(r,e[r],a,i):r;if(typeof e[r]==`object`)return i=e,a=o,`<?`+o+c(e[r][t.attributesKey],t,n)+`?>`;var s=e[r]?e[r]:``;return`instructionFn`in t&&(s=t.instructionFn(s,r,a,i)),`<?`+o+(s?` `+s:``)+`?>`}function d(e,t){return t.ignoreComment?``:`<!--`+(`commentFn`in t?t.commentFn(e,a,i):e)+`-->`}function f(e,t){return t.ignoreCdata?``:`<![CDATA[`+(`cdataFn`in t?t.cdataFn(e,a,i):e.replace(`]]>`,`]]]]><![CDATA[>`))+`]]>`}function p(e,t){return t.ignoreDoctype?``:`<!DOCTYPE `+(`doctypeFn`in t?t.doctypeFn(e,a,i):e)+`>`}function m(e,t){return t.ignoreText?``:(e=``+e,e=e.replace(/&amp;/g,`&`),e=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),`textFn`in t?t.textFn(e,a,i):e)}function h(e,t){var n;if(e.elements&&e.elements.length)for(n=0;n<e.elements.length;++n)switch(e.elements[n][t.typeKey]){case`text`:if(t.indentText)return!0;break;case`cdata`:if(t.indentCdata)return!0;break;case`instruction`:if(t.indentInstruction)return!0;break;case`doctype`:case`comment`:case`element`:return!0;default:return!0}return!1}function g(e,t,n){i=e,a=e.name;var r=[],o=`elementNameFn`in t?t.elementNameFn(e.name,e):e.name;r.push(`<`+o),e[t.attributesKey]&&r.push(c(e[t.attributesKey],t,n));var s=e[t.elementsKey]&&e[t.elementsKey].length||e[t.attributesKey]&&e[t.attributesKey][`xml:space`]===`preserve`;return s||=`fullTagEmptyElementFn`in t?t.fullTagEmptyElementFn(e.name,e):t.fullTagEmptyElement,s?(r.push(`>`),e[t.elementsKey]&&e[t.elementsKey].length&&(r.push(_(e[t.elementsKey],t,n+1)),i=e,a=e.name),r.push(t.spaces&&h(e,t)?`
96
+ `+Array(n+1).join(t.spaces):``),r.push(`</`+o+`>`)):r.push(`/>`),r.join(``)}function _(e,t,n,r){return e.reduce(function(e,i){var a=s(t,n,r&&!e);switch(i.type){case`element`:return e+a+g(i,t,n);case`comment`:return e+a+d(i[t.commentKey],t);case`doctype`:return e+a+p(i[t.doctypeKey],t);case`cdata`:return e+(t.indentCdata?a:``)+f(i[t.cdataKey],t);case`text`:return e+(t.indentText?a:``)+m(i[t.textKey],t);case`instruction`:var o={};return o[i[t.nameKey]]=i[t.attributesKey]?i:i[t.instructionKey],e+(t.indentInstruction?a:``)+u(o,t,n)}},``)}function v(e,t,n){for(var r in e)if(e.hasOwnProperty(r))switch(r){case t.parentKey:case t.attributesKey:break;case t.textKey:if(t.indentText||n)return!0;break;case t.cdataKey:if(t.indentCdata||n)return!0;break;case t.instructionKey:if(t.indentInstruction||n)return!0;break;case t.doctypeKey:case t.commentKey:return!0;default:return!0}return!1}function y(e,t,n,r,o){i=e,a=t;var l=`elementNameFn`in n?n.elementNameFn(t,e):t;if(e==null||e===``)return`fullTagEmptyElementFn`in n&&n.fullTagEmptyElementFn(t,e)||n.fullTagEmptyElement?`<`+l+`></`+l+`>`:`<`+l+`/>`;var u=[];if(t){if(u.push(`<`+l),typeof e!=`object`)return u.push(`>`+m(e,n)+`</`+l+`>`),u.join(``);e[n.attributesKey]&&u.push(c(e[n.attributesKey],n,r));var d=v(e,n,!0)||e[n.attributesKey]&&e[n.attributesKey][`xml:space`]===`preserve`;if(d||=`fullTagEmptyElementFn`in n?n.fullTagEmptyElementFn(t,e):n.fullTagEmptyElement,d)u.push(`>`);else return u.push(`/>`),u.join(``)}return u.push(b(e,n,r+1,!1)),i=e,a=t,t&&u.push((o?s(n,r,!1):``)+`</`+l+`>`),u.join(``)}function b(e,t,n,i){var a,o,c,h=[];for(o in e)if(e.hasOwnProperty(o))for(c=r(e[o])?e[o]:[e[o]],a=0;a<c.length;++a){switch(o){case t.declarationKey:h.push(l(c[a],t,n));break;case t.instructionKey:h.push((t.indentInstruction?s(t,n,i):``)+u(c[a],t,n));break;case t.attributesKey:case t.parentKey:break;case t.textKey:h.push((t.indentText?s(t,n,i):``)+m(c[a],t));break;case t.cdataKey:h.push((t.indentCdata?s(t,n,i):``)+f(c[a],t));break;case t.doctypeKey:h.push(s(t,n,i)+p(c[a],t));break;case t.commentKey:h.push(s(t,n,i)+d(c[a],t));break;default:h.push(s(t,n,i)+y(c[a],o,t,n,v(c[a],t)))}i&&=!h.length}return h.join(``)}t.exports=function(e,t){t=o(t);var n=[];return i=e,a=`_root_`,t.compact?n.push(b(e,t,0,!0)):(e[t.declarationKey]&&n.push(l(e[t.declarationKey],t,0)),e[t.elementsKey]&&e[t.elementsKey].length&&n.push(_(e[t.elementsKey],t,0,!n.length))),n.join(``)}})),fe=z(((e,t)=>{var n=de();t.exports=function(e,t){e instanceof Buffer&&(e=e.toString());var r=null;if(typeof e==`string`)try{r=JSON.parse(e)}catch{throw Error(`The JSON structure is invalid`)}else r=e;return n(r,t)}})),pe=z(((e,t)=>{t.exports={xml2js:le(),xml2json:ue(),js2xml:de(),json2xml:fe()}})),me=z((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),he=z((e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}})),ge=z((e=>{var t=me(),n=he(),r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=s,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;var i=2147483647;e.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.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 a(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,`parent`,{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,`offset`,{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function o(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return d(e)}return c(e,t,n)}s.poolSize=8192;function c(e,t,n){if(typeof e==`string`)return f(e,t);if(ArrayBuffer.isView(e))return m(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<`u`&&(H(e,SharedArrayBuffer)||e&&H(e.buffer,SharedArrayBuffer)))return h(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return s.from(r,t,n);let i=g(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return s.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}s.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function l(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function u(e,t,n){return l(e),e<=0||t===void 0?o(e):typeof n==`string`?o(e).fill(t,n):o(e).fill(t)}s.alloc=function(e,t,n){return u(e,t,n)};function d(e){return l(e),o(e<0?0:_(e)|0)}s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)};function f(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!s.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=y(e,t)|0,r=o(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function p(e){let t=e.length<0?0:_(e.length)|0,n=o(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function m(e){if(H(e,Uint8Array)){let t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return p(e)}function h(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new Uint8Array(e):n===void 0?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,s.prototype),r}function g(e){if(s.isBuffer(e)){let t=_(e.length)|0,n=o(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||ve(e.length)?o(0):p(e);if(e.type===`Buffer`&&Array.isArray(e.data))return p(e.data)}function _(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function v(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(H(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),H(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},s.isEncoding=function(e){switch(String(e).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}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=s.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(H(t,Uint8Array))i+t.length>r.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else if(s.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function y(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return de(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ge(e).length;default:if(i)return r?-1:de(e).length;t=(``+t).toLowerCase(),i=!0}}s.byteLength=y;function b(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return F(this,t,n);case`utf8`:case`utf-8`:return A(this,t,n);case`ascii`:return N(this,t,n);case`latin1`:case`binary`:return P(this,t,n);case`base64`:return k(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return I(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}s.prototype._isBuffer=!0;function x(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}s.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)x(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)x(this,t,t+7),x(this,t+1,t+6),x(this,t+2,t+5),x(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?A(this,0,e):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(e,t,n,r,i){if(H(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let a=i-r,o=n-t,c=Math.min(a,o),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){a=l[e],o=u[e];break}return a<o?-1:+(o<a)};function S(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,ve(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=s.from(t,r)),s.isBuffer(t))return t.length===0?-1:C(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof Uint8Array.prototype.indexOf==`function`?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):C(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function C(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},s.prototype.indexOf=function(e,t,n){return S(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return S(this,e,t,n,!1)};function w(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(ve(r))return o;e[n+o]=r}return o}function T(e,t,n,r){return _e(de(t,e.length-n),e,n,r)}function E(e,t,n,r){return _e(fe(t),e,n,r)}function D(e,t,n,r){return _e(ge(t),e,n,r)}function O(e,t,n,r){return _e(pe(t,e.length-n),e,n,r)}s.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return w(this,e,t,n);case`utf8`:case`utf-8`:return T(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return E(this,e,t,n);case`base64`:return D(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return O(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function k(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function A(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return M(r)}var j=4096;function M(e){let t=e.length;if(t<=j)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=j));return n}function N(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function P(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function F(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=ye[e[r]];return i}function I(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,s.prototype),r};function L(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||L(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=U(function(e){e>>>=0,se(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ce(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=U(function(e){e>>>=0,se(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ce(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||L(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||L(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||L(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||L(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||L(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=U(function(e){e>>>=0,se(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ce(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=U(function(e){e>>>=0,se(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ce(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||L(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||L(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||L(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||L(e,8,this.length),n.read(this,e,!1,52,8)};function R(e,t,n,r,i,a){if(!s.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;R(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;R(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ee(e,t,n,r,i){V(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function te(e,t,n,r,i){V(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}s.prototype.writeBigUInt64LE=U(function(e,t=0){return ee(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeBigUInt64BE=U(function(e,t=0){return te(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);R(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);R(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=U(function(e,t=0){return ee(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),s.prototype.writeBigInt64BE=U(function(e,t=0){return te(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ne(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function re(e,t,r,i,a){return t=+t,r>>>=0,a||ne(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,i,23,4),r+4}s.prototype.writeFloatLE=function(e,t,n){return re(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return re(this,e,t,!1,n)};function ie(e,t,r,i,a){return t=+t,r>>>=0,a||ne(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,i,52,8),r+8}s.prototype.writeDoubleLE=function(e,t,n){return ie(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return ie(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof Uint8Array.prototype.copyWithin==`function`?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},s.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!s.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=s.isBuffer(e)?e:s.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};var z={};function B(e,t,n){z[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}B(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),B(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),B(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=ae(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ae(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ae(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function oe(e,t,n){se(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&ce(t,e.length-(n+1))}function V(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new z.ERR_OUT_OF_RANGE(`value`,i,e)}oe(r,i,a)}function se(e,t){if(typeof e!=`number`)throw new z.ERR_INVALID_ARG_TYPE(t,`number`,e)}function ce(e,t,n){throw Math.floor(e)===e?t<0?new z.ERR_BUFFER_OUT_OF_BOUNDS:new z.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(se(e,n),new z.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}var le=/[^+/0-9A-Za-z-_]/g;function ue(e){if(e=e.split(`=`)[0],e=e.trim().replace(le,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function de(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function fe(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function pe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function ge(e){return t.toByteArray(ue(e))}function _e(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function H(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function ve(e){return e!==e}var ye=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function U(e){return typeof BigInt>`u`?be:e}function be(){throw Error(`BigInt not supported`)}})),_e=pe(),H=ge(),ve=class e{constructor(t,n=``,r=``){this.xml=t,this.filePath=n,this.basePath=r,this.layers=new Map,this.transform=t=>{if(!t)return;let n=t.attributes||t._attributes;if(!n)return t;let r={...t,...n,...e.propToNumber(n,`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`.split(`.`)),...e.propToBool(n,[`visible`,`infinite`,`locked`,`bold`,`italic`,`kerning`,`strikeout`,`underline`,`wrap`])};if(r.properties){let t=e.toArray(r.properties.property),n={};for(let e of t){let t=e._attributes;if(!t)continue;let r;switch(t.type){case`file`:r=this.getImagePath(t.value);break;case`object`:case`float`:case`int`:r=+t.value;break;case`bool`:r=t.value==`true`;break;case`class`:r={...this.transform(e)?.properties??{},_classname:t.propertytype};break;default:r=t.value}n[t.name]=r}r.properties=n}r.polygon&&=this.transform(r.polygon),r.polyline&&=this.transform(r.polyline),r.points&&(r=r.points.split(` `).map(e=>{let t=e.split(`,`);return{x:+t[0],y:+t[1]}})),r.point&&=!0,r.ellipse&&=!0,r.text&&(r.text={text:r.text._text,...this.transform(r.text)},delete r.text._text),r.image&&=this.transform(r.image),r.source&&(this.isTilesetSource(r)||(r.source=this.getImagePath(r.source)));let i=r.object||r.objectgroup?.object;return i&&(r.objects=e.toArray(i).map(e=>this.transform(e))),delete r._attributes,delete r.attributes,delete r.object,delete r.objectgroup,r}}static{this.propToNumber=(e,t)=>{for(let n of t)e[n]!==void 0&&(e[n]=+e[n]);return e}}static{this.propToBool=(e,t)=>{for(let n of t)e[n]!==void 0&&(e[n]=e[n]==`true`||e[n]==`1`);return e}}static toArray(e){return e?Array.isArray(e)?e:[e]:[]}getImagePath(e){return this.filePath.startsWith(`http`)?new URL(e,this.filePath).href:ae(this.basePath,e)}isTilesetSource(e){return e.firstgid!==void 0||e.tilewidth!==void 0||e.tileheight!==void 0||e.tilecount!==void 0||e.columns!==void 0}static unpackTileBytes(e,t){let n=t*4;if(e.length!==n)throw Error(`Expected `+n+` bytes of tile data; received `+e.length);let r=0,i=[];for(let t=0;t<n;t+=4)i[r]=e.readUInt32LE(t),r++;return i}static decode(t,n){let{encoding:r,data:i}=t;return r==`base64`?e.unpackTileBytes(H.Buffer.from(i.trim(),`base64`),n):r==`csv`?i.trim().split(`,`).map(e=>+e):i}parseMap(){let t=(0,_e.xml2js)(this.xml,{compact:!0}),n=(0,_e.xml2js)(this.xml),r=t.map.tileset;t.map.group;let i=t=>{let{objectgroup:n,group:r,layer:a,imagelayer:o}=t,s=t=>{t&&e.toArray(t).forEach(e=>{if(this.layers.has(+e._attributes.id))throw Error(`Tiled Parser Error: Layer with id ${e._attributes.id} already exists`);this.layers.set(+e._attributes.id,e)})};s(n),s(a),s(r),s(o),r&&i(r)};i(t.map);let a=(t,n=[])=>{if(!t)return n;for(let r of t){let{name:t}=r;if(![`layer`,`group`,`imagelayer`,`objectgroup`].includes(t))continue;let i=r.elements?.find(e=>e.name==`data`);r.layer=this.layers.get(+r.attributes.id);let o={...this.transform(i)??{},...this.transform(r),...this.transform(r.layer),layers:a(r.elements),data:i?i.elements[0].text:void 0,type:t==`layer`?`tilelayer`:t};delete o.elements,delete o.layer,o.data&&=e.decode(o,o.width*o.height),n.push(o)}return n},o=a(n.elements[0].elements),s=e.toArray(r).map(e=>this.transform(e)),c={...this.transform(t.map),layers:o,tilesets:s};return delete c.layer,delete c.tileset,delete c.group,delete c.imagelayer,c}parseTileset(){let{tileset:t}=(0,_e.xml2js)(this.xml,{compact:!0}),n={...this.transform(t),image:this.transform(t.image),tiles:e.toArray(t.tile).map(t=>{let n=this.transform(t);return t.animation&&(n.animations=e.toArray(t.animation.frame).map(this.transform)),delete n.animation,n})};return delete n.tile,n}},ye=class{constructor(e){this.properties={},this.properties=e?.properties??{}}getProperty(e,t){let n=this.properties[e];return n===void 0?t:n}hasProperty(e){return!!this.properties[e]}setProperty(e,t){this.properties[e]=t}getType(){return this.class||this.type}},U=2147483648,be=1073741824,xe=536870912,Se=268435456,Ce=class e extends ye{constructor(e){super(e),this.obj=e,this._gid=e?.gid}static getRealGid(e){return e&268435455}get horizontalFlip(){return!!(this._gid&U)}get verticalFlip(){return!!(this._gid&be)}get diagonalFlip(){return!!(this._gid&xe)}get rotatedHex120(){return!!(this._gid&Se)}get gid(){return e.getRealGid(this._gid)}set gid(e){this._gid=e}},we=class extends Ce{constructor(e){super(e),this.tile=e;let t=this.properties;Reflect.deleteProperty(e,`gid`),Object.assign(this,e),t&&Object.keys(t).length>0&&(this.properties={...t,...this.properties})}},Te=class extends Ce{constructor(e){super(e),this.layerName=``,Object.assign(this,e),e?.gid&&(this.y-=this.height)}},Ee=class e extends ye{get size(){return this.data.length}constructor(e,t,n){super(e),this.tilesets=t,this.parent=n,this.cacheTiles=!1,this.tiles=[],Object.assign(this,e),this.mapObjects(),this.mergePropertiesWithParent(),this.cacheTiles=this.getProperty(`cache-tiles`,!1),this.cacheTiles&&this.propertiesTiles()}createTile(t,n,r){if(t==0)return;let i=Ce.getRealGid(t),a=e.findTileSet(i,this.tilesets);if(!a)return;let o=a.getTile(i-a.firstgid);return o?new we({...o.tile,gid:t,index:n,layerIndex:r}):new we({gid:t,index:n,layerIndex:r})}mergePropertiesWithParent(){let e=this.getLayerParent();if(this.properties||={},e){for(let t in e.properties){let n=e.properties[t];if(this.properties[t]===void 0)this.properties[t]=n;else if(t==`z`)this.properties[t]+=n;else continue}this.opacity=Math.round((e.opacity??1)*(this.opacity??1)*100)/100,this.offsetx=(e.offsetx??0)+(this.offsetx??0),this.offsety=(e.offsety??0)+(this.offsety??0),this.locked=e.locked??!1}}propertiesTiles(){if(!this.data)return;let e=this.data;for(let t=0;t<e.length;t++){let n=e[t];this.tiles.push(this.createTile(n,t))}}mapObjects(){this.objects&&=this.objects.map(e=>{let t=new Te(e);return t.layerName=this.name,t})}getTileByIndex(e){return this.cacheTiles?this.tiles[e]:this.createTile(this.data[e],e)}static findTileSet(e,t){let n;for(let r=t.length-1;r>=0&&(n=t[r],!(n.firstgid&&n.firstgid<=e));r--);return n}getLayerParent(){return this.parent}tilesForEach(e){for(let t=0;t<this.data.length;t++){if(this.cacheTiles){e(this.tiles[t],t);continue}e(this.createTile(this.data[t],t),t)}}setData(e,t){this.data[e]=t}},De=class extends ye{constructor(e){super(e),this.tileset=e,this.cacheTileId=new Map,Object.assign(this,e),this.margin=this.margin??0,this.spacing=this.spacing??0;let t=e.tiles||e.tile||[];for(let e of t)this.addTile(e);Reflect.deleteProperty(this,`tiles`),Reflect.deleteProperty(this,`tile`)}addTile(e){let t=new we(e);return this.cacheTileId.set(t.id,t),t}getTile(e){return this.cacheTileId.get(+e)}},Oe=class e{constructor(e,{basePath:t=``,staticDir:n=``,relativePath:r=``}={}){this.file=e,this.basePath=t}static isBrowser(){return typeof window<`u`&&!window.useFileSystem}static typeOfFile(e){e=e.trim();let t=typeof e==`string`,n={isXml:t&&e.startsWith(`<?xml`),isObject:!!e.version,isHttp:t&&e.startsWith(`http`)};return{...n,isPath:!n.isXml&&!n.isObject&&!n.isHttp}}_parseFile(t,n,r){let i=t=>e.typeOfFile(t).isXml,a=e=>{if(!e)return r(null);if(i(e)){let i=new ve(e,t,this.basePath);if(n==`map`)return r(i.parseMap());if(n==`tileset`)return r(i.parseTileset())}return r(JSON.parse(e))};if(e.typeOfFile(t).isObject)return r(t);let{isHttp:o}=e.typeOfFile(t);if(i(t))a(t);else if(o||e.isBrowser()){let n=o?t:ae(this.basePath,t);e.isBrowser()&&window.urlCache&&(n=window.urlCache[t]),fetch(n,{headers:{"Content-Type":`application/xml`}}).then(e=>e.text()).then(a).catch(e=>r(null,e))}}parseFile(t,n={}){let{getOnlyBasename:r}=n,i=e=>e.substring(e.lastIndexOf(`/`)+1);r&&e.typeOfFile(this.file).isPath&&(this.file=i(this.file)),this._parseFile(this.file,`map`,(n,a)=>{let o=!1;if(a)return t(null,a);if(n.tilesets){let a=[],s=()=>{c++,c==n.tilesets.length&&!o&&(n.tilesets=a,t(n))},c=0;for(let c=0;c<n.tilesets.length;c++){let l=n.tilesets[c];if(!l.source||l.tiles||l.image||l.tile){a[c]=l,s();continue}r&&e.typeOfFile(l.source).isPath&&(l.source=i(l.source)),this._parseFile(l.source,`tileset`,(e,n)=>{if(n)return o=!0,t(null,n);a[c]={...e,firstgid:l.firstgid},s()})}}})}parseFilePromise(e={}){return new Promise((t,n)=>{this.parseFile((e,r)=>{e?t(e):n(r)},e)})}},ke={TEXTURES_PER_TILEMAP:16,TEXTILE_SCALE_MODE:`linear`,use32bitIndex:!1},Ae=Object.defineProperty,je=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Me=(e,t,n)=>(je(e,typeof t==`symbol`?t:t+``,n),n),Ne=class e extends n.Geometry{constructor(t){let r=new n.Buffer({data:new Float32Array(2),label:`tilemap-buffer`,usage:n.BufferUsage.VERTEX|n.BufferUsage.COPY_DST,shrinkToFit:!1}),i=e.stride;super({indexBuffer:t,attributes:{aVertexPosition:{buffer:r,format:`float32x2`,stride:i,offset:0},aTextureCoord:{buffer:r,format:`float32x2`,stride:i,offset:8},aFrame:{buffer:r,format:`float32x4`,stride:i,offset:16},aAnim:{buffer:r,format:`float32x2`,stride:i,offset:32},aTextureId:{buffer:r,format:`sint32`,stride:i,offset:40},aAnimDivisor:{buffer:r,format:`float32`,stride:i,offset:44},aAlpha:{buffer:r,format:`float32`,stride:i,offset:48}}}),Me(this,`lastTimeAccess`,0),Me(this,`vertSize`,e.vertSize),Me(this,`vertPerQuad`,e.vertPerQuad),Me(this,`stride`,e.stride),Me(this,`buf`),this.buf=r}};Me(Ne,`vertSize`,13),Me(Ne,`vertPerQuad`,4),Me(Ne,`stride`,Ne.vertSize*4);var Pe=Ne,Fe=Object.defineProperty,Ie=(e,t,n)=>t in e?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t,n)=>(Ie(e,typeof t==`symbol`?t:t+``,n),n),Re=class{constructor(){Le(this,`pipe_uniforms`,new n.UniformGroup({u_proj_trans:{value:new n.Matrix,type:`mat3x3<f32>`},u_anim_frame:{value:new Float32Array(2),type:`vec2<f32>`}}))}},ze=class{constructor(e,t){Le(this,`renderer`),Le(this,`tileAnim`,[0,0]),Le(this,`ibLen`,0),Le(this,`indexBuffer`,null),Le(this,`shader`),Le(this,`adaptor`),this.renderer=e,this.adaptor=t,this.adaptor.init(),this.indexBuffer=new n.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:`index-tilemap-buffer`,usage:n.BufferUsage.INDEX|n.BufferUsage.COPY_DST}),this.indexBuffer.destroy=n.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){let e=new Pe(this.indexBuffer);return e.lastTimeAccess=Date.now(),e}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(e){let t=e*6;t<=this.ibLen||(this.ibLen=t,this.indexBuffer.data=Be(e,ke.use32bitIndex?new Uint32Array(t):new Uint16Array(t)))}destroyRenderable(e){e.vb.destroy(!0),e.vb=null}addRenderable(e,t){let n=this.renderer.renderPipes.batch;e.updateBuffer(this),e.checkValid(),e.getTileset().update(),e.is_valid&&(n.break(t),t.add(e._instruction))}updateRenderable(e,t){e.updateBuffer(this),e.getTileset().update()}validateRenderable(e){return e.checkValid()}execute({tilemap:e}){if(!e.isRenderable)return;e.state.blendMode=e.groupBlendMode;let{pipe_uniforms:t}=this.adaptor,n=t.uniforms.u_proj_trans,r=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms,i=this.tileAnim,{u_anim_frame:a}=t.uniforms;r.uProjectionMatrix.copyTo(n).append(r.uWorldTransformMatrix).append(e.worldTransform),e.compositeParent&&(i=e.parent.tileAnim||i),a[0]=i[0],a[1]=i[1],t.update(),this.adaptor.execute(this,e)}};Le(ze,`extension`,{type:[n.ExtensionType.WebGLPipes,n.ExtensionType.WebGPUPipes],name:`tilemap`});function Be(e,t){let n=e*6;if(t.length!==n)throw Error(`Out buffer length is incorrect, got ${t.length} and expected ${n}`);for(let e=0,r=0;e<n;e+=6,r+=4)t[e+0]=r+0,t[e+1]=r+1,t[e+2]=r+2,t[e+3]=r+0,t[e+4]=r+2,t[e+5]=r+3;return t}var Ve=Object.defineProperty,He=(e,t,n)=>t in e?Ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ue=(e,t,n)=>(He(e,typeof t==`symbol`?t:t+``,n),n),We=class{constructor(e){Ue(this,`max_textures`),Ue(this,`arr`,[]),Ue(this,`count`,0),Ue(this,`dirty`,!1),Ue(this,`dirty_gpu`,!1),Ue(this,`bind_group`,null),Ue(this,`bind_group_resources`,{}),Ue(this,`tex_sizes`,null),Ue(this,`null_color`,new Float32Array([0,0,0,.5])),Ue(this,`tex_buf`,null),this.max_textures=e,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new n.Buffer({usage:n.BufferUsage.UNIFORM|n.BufferUsage.COPY_DST})}get length(){return this.count}push(e){this.arr[this.count++]=e,this.dirty=!0}at(e){return this.arr[e]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;let{tex_sizes:e,arr:t,count:n,max_textures:r,null_color:i}=this;for(let r=0;r<n;r++){let n=t[r];n&&(e[r*4]=n.pixelWidth,e[r*4+1]=n.pixelHeight,e[r*4+2]=1/n.pixelWidth,e[r*4+3]=1/n.pixelHeight)}e[r*4]=i[0],e[r*4+1]=i[1],e[r*4+2]=i[2],e[r*4+3]=i[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;let{bind_group_resources:e,max_textures:t,arr:r,count:i}=this,a=0;e[a++]=new n.UniformGroup({u_texture_size:{value:this.tex_sizes,type:`vec4<f32>`,size:t},u_null_color:{value:this.null_color,type:`vec4<f32>`}});for(let o=0;o<t;o++){let t=(o<i?r[o]:null)||n.Texture.EMPTY.source;e[a++]=t.source,e[a++]=t.style}return this.bind_group||=new n.BindGroup(e),this.bind_group}static generate_gpu_textures(e){let t=[];t.push(`struct TextureArrayFields {`),t.push(` u_texture_size: array<vec4f, ${e}>,`),t.push(` u_null_color: vec4f`),t.push(`}`),t.push(`@group(1) @binding(0) var<uniform> taf: TextureArrayFields;`);for(let n=0;n<e;n++)t.push(`@group(1) @binding(${n*2+1}) var u_texture_${n}: texture_2d<f32>;`),t.push(`@group(1) @binding(${n*2+2}) var u_sampler_${n}: sampler;`);t.push(`fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {`),t.push(`switch texture_id {`);for(let n=0;n<e;n++)t.push(` case ${n}: { return textureSampleGrad(u_texture_${n}, u_sampler_${n}, uv, dx, dy); }`);return t.push(` default: { return taf.u_null_color; }`),t.push(`} }`),t.join(`
97
+ `)}static generate_gl_textures(e){let t=[];t.push(`uniform vec4 u_texture_size[${e+1}];`),t.push(`uniform sampler2D u_textures[${e}];`),t.push(`uniform vec4 u_null_color;`),t.push(`vec4 sampleMultiTexture(float texture_id, vec2 uv) {`),t.push(`if(texture_id < -0.5) return u_texture_size[${e}];`);for(let n=0;n<e;n++)t.push(`if(texture_id < ${n}.5) return texture(u_textures[${n}], uv * u_texture_size[${n}].zw);`);return t.push(`return u_texture_size[${e}];`),t.push(`}`),t.join(`
98
+ `)}static gl_gen_resources(e){let t=[];for(let n=0;n<e;n++)t[n]=n;let n=[];for(let t=0;t<e;t++)n.push(2048),n.push(2048),n.push(1/2048),n.push(1/2048);return{u_textures:{value:t,type:`i32`,size:e},u_texture_size:{value:n,type:`vec4<f32>`,size:e}}}},Ge=Object.defineProperty,Ke=(e,t,n)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qe=(e,t,n)=>(Ke(e,typeof t==`symbol`?t:t+``,n),n),Je=`
99
99
  in vec2 aVertexPosition;
100
100
  in vec2 aTextureCoord;
101
101
  in vec4 aFrame;
@@ -126,7 +126,7 @@ void main(void)
126
126
  vTextureId = aTextureId;
127
127
  vAlpha = aAlpha;
128
128
  }
129
- `,kr=`
129
+ `,Ye=`
130
130
  #ifdef GL_FRAGMENT_PRECISION_HIGH
131
131
  precision highp float;
132
132
  #else
@@ -146,7 +146,7 @@ void main(void)
146
146
  vec4 color = sampleMultiTexture(textureId, textureCoord);
147
147
  finalColor = color * vAlpha;
148
148
  }
149
- `;class vi extends wi{constructor(){super(...arguments),Ye(this,"_shader",null),Ye(this,"max_textures",Wt.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,r=this._shader,l=e.getTileset(),c=r.resources.texture_uniforms;c.uniforms.u_texture_size!==l.tex_sizes&&(c.uniforms.u_texture_size=l.tex_sizes,c.update());for(let a=0;a<l.length;a++)i.texture.bind(l.arr[a],a);i.encoder.draw({geometry:e.vb,shader:r,state:e.state,size:e.rects_count*6})}init(){this._shader=new L.Shader({glProgram:L.GlProgram.from({vertex:Ur,fragment:kr.replace("//include_textures",Zt.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new L.UniformGroup(Zt.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}Ye(vi,"extension",{type:[L.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var Lr=Object.defineProperty,Vr=(n,t,e)=>t in n?Lr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,me=(n,t,e)=>(Vr(n,typeof t!="symbol"?t+"":t,e),e);const Yr=`
149
+ `,Xe=class extends Re{constructor(){super(...arguments),qe(this,`_shader`,null),qe(this,`max_textures`,ke.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(e,t){let n=e.renderer,r=this._shader,i=t.getTileset(),a=r.resources.texture_uniforms;a.uniforms.u_texture_size!==i.tex_sizes&&(a.uniforms.u_texture_size=i.tex_sizes,a.update());for(let e=0;e<i.length;e++)n.texture.bind(i.arr[e],e);n.encoder.draw({geometry:t.vb,shader:r,state:t.state,size:t.rects_count*6})}init(){this._shader=new n.Shader({glProgram:n.GlProgram.from({vertex:Je,fragment:Ye.replace(`//include_textures`,We.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new n.UniformGroup(We.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}};qe(Xe,`extension`,{type:[n.ExtensionType.WebGLPipesAdaptor],name:`tilemap`});var Ze=Object.defineProperty,Qe=(e,t,n)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$e=(e,t,n)=>(Qe(e,typeof t==`symbol`?t:t+``,n),n),et=`
150
150
  struct GlobalUniforms {
151
151
  uProjectionMatrix:mat3x3f,
152
152
  uWorldTransformMatrix:mat3x3f,
@@ -192,7 +192,7 @@ fn mainVert(
192
192
 
193
193
  return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
194
194
  };
195
- `,zr=`
195
+ `,tt=`
196
196
  //include_textures
197
197
 
198
198
  @fragment
@@ -209,7 +209,7 @@ fn mainFrag(
209
209
  var color = sampleMultiTexture(vTextureId, uv, dx, dy);
210
210
  return color * vAlpha;
211
211
  };
212
- `;class bi extends wi{constructor(){super(...arguments),me(this,"_shader",null),me(this,"max_textures",Wt.TEXTURES_PER_TILEMAP),me(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(t,e){const i=t.renderer,r=this._shader;r.groups[0]=i.globalUniforms.bindGroup,r.groups[1]=e.getTileset().getBindGroup(),r.groups[2]=this.bind_group,i.encoder.draw({geometry:e.vb,shader:r,state:e.state,size:e.rects_count*6})}init(){this._shader=new L.Shader({gpuProgram:L.GpuProgram.from({vertex:{source:Yr,entryPoint:"mainVert"},fragment:{source:zr.replace("//include_textures",Zt.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new L.BindGroup({ut:this.pipe_uniforms})}}me(bi,"extension",{type:[L.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var Gr=Object.defineProperty,jr=(n,t,e)=>t in n?Gr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Bt=(n,t,e)=>(jr(n,typeof t!="symbol"?t+"":t,e),e),Si=(n=>(n[n.U=0]="U",n[n.V=1]="V",n[n.X=2]="X",n[n.Y=3]="Y",n[n.TILE_WIDTH=4]="TILE_WIDTH",n[n.TILE_HEIGHT=5]="TILE_HEIGHT",n[n.ROTATE=6]="ROTATE",n[n.ANIM_X=7]="ANIM_X",n[n.ANIM_Y=8]="ANIM_Y",n[n.TEXTURE_INDEX=9]="TEXTURE_INDEX",n[n.ANIM_COUNT_X=10]="ANIM_COUNT_X",n[n.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",n[n.ANIM_DIVISOR=12]="ANIM_DIVISOR",n[n.ALPHA=13]="ALPHA",n))(Si||{});const kt=Object.keys(Si).length/2;class Ai extends L.ViewContainer{constructor(t){super({}),Bt(this,"shadowColor",new Float32Array([0,0,0,.5])),Bt(this,"state",L.State.for2d()),Bt(this,"is_valid",!1),Bt(this,"renderPipeId","tilemap"),Bt(this,"canBundle",!0),Bt(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),Bt(this,"tileAnim",null),Bt(this,"rects_count",0),Bt(this,"compositeParent",!1),Bt(this,"tileset",new Zt(Wt.TEXTURES_PER_TILEMAP)),Bt(this,"tilemapBounds",new L.Bounds),Bt(this,"hasAnimatedTile",!1),Bt(this,"pointsBuf",[]),Bt(this,"batched"),Bt(this,"vbId",0),Bt(this,"vb",null),Bt(this,"vbBuffer",null),Bt(this,"vbArray",null),Bt(this,"vbInts",null),this.setTileset(t)}checkValid(){const t=this.tileset.count>0&&this.pointsBuf.length>0,e=this.is_valid!==t;return this.is_valid=t,e!==t}updateBounds(){const t=this.tilemapBounds;this._bounds.minX=t.minX,this._bounds.maxX=t.maxX,this._bounds.minY=t.minY,this._bounds.maxY=t.maxY}getTileset(){return this.tileset}setTileset(t=[]){let e=this.tileset;if(t instanceof Zt)this.tileset=t,this.didViewUpdate=!0;else if(t instanceof L.TextureSource){if(e.count===1&&e.arr[0]===t)return this;e=this.tileset=new Zt(Wt.TEXTURES_PER_TILEMAP),e.push(t),this.didViewUpdate=!0}else{if(t.length===e.count){let i=!0;for(let r=0;r<t.length;r++)if(t[r]?.source!==e.arr[r]){i=!1;break}if(i)return this}e=this.tileset=new Zt(Wt.TEXTURES_PER_TILEMAP);for(let i=0;i<t.length;i++)e.push(t[i]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(t,e,i,r={}){this.didViewUpdate=!0;let l,c=-1,a=!1;if(typeof t=="number")c=t,a=!0,l=this.tileset.arr[c];else{let f;typeof t=="string"?f=L.Texture.from(t):f=t;const A=this.tileset;for(let P=0;P<A.count;P++)if(A.arr[P]===f.source){c=P;break}"frame"in f&&(r.u=r.u??f.frame.x,r.v=r.v??f.frame.y,r.tileWidth=r.tileWidth??f.orig.width,r.tileHeight=r.tileHeight??f.orig.height),l=f.source}if(!a&&!l)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:g=0,v:S=0,tileWidth:w=l.width,tileHeight:C=l.height,animX:M=0,animY:N=0,rotate:F=0,animCountX:k=1024,animCountY:R=1024,animDivisor:m=1,alpha:x=1}=r,y=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||M>0||N>0,y.push(g),y.push(S),y.push(e),y.push(i),y.push(w),y.push(C),y.push(F),y.push(M|0),y.push(N|0),y.push(c),y.push(k),y.push(R),y.push(m),y.push(x),this.tilemapBounds.addFrame(e,i,e+w,i+C),this}tileRotate(t){const e=this.pointsBuf;e[e.length-(kt-9)]=t}tileAnimX(t,e){const i=this.pointsBuf;i[i.length-(kt-7)]=t,i[i.length-(kt-10)]=e}tileAnimY(t,e){const i=this.pointsBuf;i[i.length-(kt-8)]=t,i[i.length-(kt-11)]=e}tileAnimDivisor(t){const e=this.pointsBuf;e[e.length-(kt-12)]=t}tileAlpha(t){const e=this.pointsBuf;e[e.length-(kt-13)]=t}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(t){const e=this.pointsBuf,i=e.length/kt;let r=this.vb;if(this.tileset.count===0||i===0||this.rects_count===i&&r)return;this.rects_count=i,r||(r=t.createVb(),this.vb=r,this.vbId=r.id,this.vbBuffer=null);const l=i*r.vertPerQuad;t.checkIndexBuffer(i);const c=r.getBuffer("aVertexPosition"),a=r.stride*l;if(!this.vbBuffer||this.vbBuffer.byteLength<a){let M=r.stride;for(;M<a;)M*=2;this.vbBuffer=new ArrayBuffer(M),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const g=this.vbArray,S=this.vbInts;let w=0,C=0;for(let M=0;M<e.length;M+=kt){this.compositeParent&&(C=e[M+9]);const F=e[M+2],k=e[M+3],R=e[M+4],m=e[M+5],x=e[M+0],y=e[M+1];let f=e[M+6];const A=e[M+7],P=e[M+8],I=e[M+10]||1024,O=e[M+11]||1024,_=A+I*2048,U=P+O*2048,V=e[M+12],z=e[M+13];let K,et,Q,W,Y,Z,yt,ct;if(f===0)K=x,et=y,Q=x+R,W=y,Y=x+R,Z=y+m,yt=x,ct=y+m;else{let H=R/2,it=m/2;f%4!==0&&(H=m/2,it=R/2);const vt=x+H,j=y+it;f=L.groupD8.add(f,L.groupD8.NW),K=vt+H*L.groupD8.uX(f),et=j+it*L.groupD8.uY(f),f=L.groupD8.add(f,2),Q=vt+H*L.groupD8.uX(f),W=j+it*L.groupD8.uY(f),f=L.groupD8.add(f,2),Y=vt+H*L.groupD8.uX(f),Z=j+it*L.groupD8.uY(f),f=L.groupD8.add(f,2),yt=vt+H*L.groupD8.uX(f),ct=j+it*L.groupD8.uY(f)}g[w++]=F,g[w++]=k,g[w++]=K,g[w++]=et,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z,g[w++]=F+R,g[w++]=k,g[w++]=Q,g[w++]=W,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z,g[w++]=F+R,g[w++]=k+m,g[w++]=Y,g[w++]=Z,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z,g[w++]=F,g[w++]=k+m,g[w++]=yt,g[w++]=ct,g[w++]=x+.5,g[w++]=y+.5,g[w++]=x+R-.5,g[w++]=y+m-.5,g[w++]=_,g[w++]=U,S[w++]=C,g[w++]=V,g[w++]=z}c.data=g}isModified(t){return!!(this.rects_count*kt!==this.pointsBuf.length||t&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/kt}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,r,l){return this.tile(t,e,i,{animX:r,animY:l}),!0}addRect(t,e,i,r,l,c,a,g=0,S=0,w=0,C=1024,M=1024,N=1,F=1){return this.tile(t,r,l,{u:e,v:i,tileWidth:c,tileHeight:a,animX:g,animY:S,rotate:w,animCountX:C,animCountY:M,animDivisor:N,alpha:F})}}var Kr=Object.defineProperty,qr=(n,t,e)=>t in n?Kr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,ae=(n,t,e)=>(qr(n,typeof t!="symbol"?t+"":t,e),e);class Wr extends L.Container{constructor(t){super(),ae(this,"texturesPerTilemap"),ae(this,"tileAnim",null),ae(this,"lastModifiedTilemap",null),ae(this,"modificationMarker",0),ae(this,"setBitmaps",this.tileset),this.texturesPerTilemap=Wt.TEXTURES_PER_TILEMAP,this.tileset(t)}tileset(t){t||(t=[]);const e=this.texturesPerTilemap,i=this.children.length,r=Math.ceil(t.length/e);for(let l=0;l<Math.min(i,r);l++)this.children[l].setTileset(t.slice(l*e,(l+1)*e));for(let l=i;l<r;l++){const c=new Ai(t.slice(l*e,(l+1)*e));c.compositeParent=!0,this.addChild(c)}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,r={}){let l=null;const c=this.children;if(this.lastModifiedTilemap=null,typeof t=="number"){const a=t/this.texturesPerTilemap>>0;let g=0;if(l=c[a],l)g=t%this.texturesPerTilemap;else{if(l=c[0],!l)return this;g=0}l.tile(g,e,i,r)}else{typeof t=="string"&&(t=L.Texture.from(t));for(let a=0;a<c.length;a++){const g=c[a],S=g.getTileset().arr;for(let w=0;w<S.length;w++)if(S[w]===t.source){l=g;break}if(l)break}if(!l){for(let a=c.length-1;a>=0;a--){const g=c[a];if(g.getTileset().count<this.texturesPerTilemap){l=g,g.getTileset().push(t.source);break}}l||(l=new Ai(t.source),l.compositeParent=!0,this.addChild(l))}l.tile(t,e,i,r)}return this.lastModifiedTilemap=l,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,r,l,c,a,g,S){return this.tile(t,e,i,{animX:r,animY:l,animCountX:c,animCountY:a,animDivisor:g,alpha:S})}addRect(t,e,i,r,l,c,a,g,S,w,C,M){const N=t/this.texturesPerTilemap>>0,F=t%this.texturesPerTilemap;return this.children[N]&&this.children[N].getTileset().count>0?(this.lastModifiedTilemap=this.children[N],this.lastModifiedTilemap.addRect(F,e,i,r,l,c,a,g,S,w,C,M)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}L.extensions.add(Ei),L.extensions.add(vi),L.extensions.add(bi);class ye extends L.AnimatedSprite{constructor(t,e){super(ye.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=ye.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(r=>{i.push(e.textures[r.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=r=>{e++,t?t=L.groupD8.add(t,r):t=r};this.tile.horizontalFlip&&i(L.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&i(L.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(e%2==0?i(L.groupD8.MAIN_DIAGONAL):i(L.groupD8.REVERSE_DIAGONAL))}}Wt.use32bitIndex=!0;class ze extends D.DisplayObject(Wr){constructor(){super(...arguments),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(t,e){let i;for(let r=e.length-1;r>=0&&(i=e[r],!(i.firstgid&&i.firstgid<=t));r--);return i}createTile(t,e,i={}){const{real:r,filter:l}=i,{tilewidth:c,tileheight:a,width:g}=this._layer;r&&(t=Math.floor(t/c),e=Math.floor(e/a));const S=t+e*g,w=this._layer.getTileByIndex(S);if(!w||w&&w.gid==0)return;const C=ze.findTileSet(w.gid,this.tileSets);if(!C)return;const M=new ye(w,C);if(M.x=t*c,M.y=e*a+(a-M.texture.height),M._x=t,M._y=e,C.tileoffset&&(M.x+=C.tileoffset.x??0,M.y+=C.tileoffset.y??0),!(l&&!l(M)))return M}_addFrame(t,e,i){const r=this.tile(t.texture,t.x,t.y,{rotate:t.texture.rotate});t.setAnimation(r),this._tiles[e+";"+i]=t}async onMount(t){const{props:e}=t;this.tileSets=e.tilesets,this._layer=new Ve({...e},this.tileSets);const i=e.context.tick;this.subscriptionTick=i.observable.subscribe(({value:r})=>{r.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 r=this.createTile(i,e);r&&this._addFrame(r,i,e)}}}async onDestroy(t){this.subscriptionTick.unsubscribe(),await super.onDestroy(t)}}D.registerComponent("CompositeTileLayer",ze);function $r(n){return D.createComponent("CompositeTileLayer",n)}class Hr extends Tr{constructor(t){super(t),this.textures=[],this.tileGroups={}}loadGroup(){}async load(t){const e=await L.Assets.load(t);for(let i=this.margin;i<this.image.height;i+=this.tileheight+this.spacing)for(let r=this.margin;r<this.image.width;r+=this.tilewidth+this.spacing)this.textures.push(new L.Texture({source:e.source,frame:new L.Rectangle(+r,+i,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}}function Xr(n,t,e){const i=[];for(const r of n){if(r.type!==ee.Tile){i.push(r);continue}const l=new Map;let c;if(Array.isArray(r.data))c=r.data.map(g=>typeof g=="number"?g:parseInt(String(g),10));else{i.push(r);continue}for(let g=0;g<c.length;g++){const S=c[g];if(S===0)continue;let w;for(let F=t.length-1;F>=0;F--)if(t[F].firstgid&&t[F].firstgid<=S){w=t[F];break}if(!w){l.has(0)||l.set(0,new Array(c.length).fill(0)),l.get(0)[g]=S;continue}const C=S-w.firstgid,M=w.tileset.tiles?.[C]?.properties,N=M?.z??0;M?.z,l.has(N)||l.set(N,new Array(c.length).fill(0)),l.get(N)[g]=S}const a=Array.from(l.keys()).sort((g,S)=>g-S);for(const g of a){const S=l.get(g);if(S.some(w=>w!==0)){const w={...r,name:`${r.name}_z${g}`,data:S,properties:{...r.properties,z:g}};i.push(w)}}}return i.sort((r,l)=>{const c=r.properties?.z??.5,a=l.properties?.z??.5;return c-a}),i}function Qr(n){const{map:t,basePath:e,createLayersPerTilesZ:i}=D.useProps(n,{createLayersPerTilesZ:!1,basePath:""}),r=D.signal([]),l=n.objectLayer;let c=[],a={};const g=async(w,C="")=>typeof w!="string"?w:await new qt(w,{basePath:C}).parseFilePromise({getOnlyBasename:!1});D.effect(async()=>{const w=t();if(w){a=await g(w,e()),c=[];for(let M of a.tilesets)M.tile&&(M.tiles=M.tile),M.tiles||(M.tiles=[]),c.push(await new Hr(M).load(M.image.source));let C=a.layers;i()&&(C=Xr(a.layers,c)),r.set(C)}});const S=(w,C={})=>D.h(D.Container,C,D.loop(w,M=>{switch(M.type){case ee.Tile:return D.h($r,{tilewidth:a.tilewidth,tileheight:a.tileheight,width:a.width,height:a.height,...M,tilesets:c});case ee.Image:const{width:N,height:F,source:k}=M.image;return D.h(D.TilingSprite,{image:k,...M,width:M.repeatx?M.width*M.tilewidth:N,height:M.repeaty?M.height*M.tileheight:F});case ee.Group:return S(D.signal(M.layers),M);case ee.ObjectGroup:const R=l?.(M);return D.h(D.Container,M,R);default:return D.h(D.Container)}}));return D.h(D.Container,n,S(r))}function Zr(){const n=`
212
+ `,nt=class extends Re{constructor(){super(...arguments),$e(this,`_shader`,null),$e(this,`max_textures`,ke.TEXTURES_PER_TILEMAP),$e(this,`bind_group`,null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(e,t){let n=e.renderer,r=this._shader;r.groups[0]=n.globalUniforms.bindGroup,r.groups[1]=t.getTileset().getBindGroup(),r.groups[2]=this.bind_group,n.encoder.draw({geometry:t.vb,shader:r,state:t.state,size:t.rects_count*6})}init(){this._shader=new n.Shader({gpuProgram:n.GpuProgram.from({vertex:{source:et,entryPoint:`mainVert`},fragment:{source:tt.replace(`//include_textures`,We.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new n.BindGroup({ut:this.pipe_uniforms})}};$e(nt,`extension`,{type:[n.ExtensionType.WebGPUPipesAdaptor],name:`tilemap`});var rt=Object.defineProperty,it=(e,t,n)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t,n)=>(it(e,typeof t==`symbol`?t:t+``,n),n),at=(e=>(e[e.U=0]=`U`,e[e.V=1]=`V`,e[e.X=2]=`X`,e[e.Y=3]=`Y`,e[e.TILE_WIDTH=4]=`TILE_WIDTH`,e[e.TILE_HEIGHT=5]=`TILE_HEIGHT`,e[e.ROTATE=6]=`ROTATE`,e[e.ANIM_X=7]=`ANIM_X`,e[e.ANIM_Y=8]=`ANIM_Y`,e[e.TEXTURE_INDEX=9]=`TEXTURE_INDEX`,e[e.ANIM_COUNT_X=10]=`ANIM_COUNT_X`,e[e.ANIM_COUNT_Y=11]=`ANIM_COUNT_Y`,e[e.ANIM_DIVISOR=12]=`ANIM_DIVISOR`,e[e.ALPHA=13]=`ALPHA`,e))(at||{}),G=Object.keys(at).length/2,ot=class extends n.ViewContainer{constructor(e){super({}),W(this,`shadowColor`,new Float32Array([0,0,0,.5])),W(this,`state`,n.State.for2d()),W(this,`is_valid`,!1),W(this,`renderPipeId`,`tilemap`),W(this,`canBundle`,!0),W(this,`_instruction`,{renderPipeId:`tilemap`,tilemap:this}),W(this,`tileAnim`,null),W(this,`rects_count`,0),W(this,`compositeParent`,!1),W(this,`tileset`,new We(ke.TEXTURES_PER_TILEMAP)),W(this,`tilemapBounds`,new n.Bounds),W(this,`hasAnimatedTile`,!1),W(this,`pointsBuf`,[]),W(this,`batched`),W(this,`vbId`,0),W(this,`vb`,null),W(this,`vbBuffer`,null),W(this,`vbArray`,null),W(this,`vbInts`,null),this.setTileset(e)}checkValid(){let e=this.tileset.count>0&&this.pointsBuf.length>0,t=this.is_valid!==e;return this.is_valid=e,t!==e}updateBounds(){let e=this.tilemapBounds;this._bounds.minX=e.minX,this._bounds.maxX=e.maxX,this._bounds.minY=e.minY,this._bounds.maxY=e.maxY}getTileset(){return this.tileset}setTileset(e=[]){let t=this.tileset;if(e instanceof We)this.tileset=e,this.didViewUpdate=!0;else if(e instanceof n.TextureSource){if(t.count===1&&t.arr[0]===e)return this;t=this.tileset=new We(ke.TEXTURES_PER_TILEMAP),t.push(e),this.didViewUpdate=!0}else{if(e.length===t.count){let n=!0;for(let r=0;r<e.length;r++)if(e[r]?.source!==t.arr[r]){n=!1;break}if(n)return this}t=this.tileset=new We(ke.TEXTURES_PER_TILEMAP);for(let n=0;n<e.length;n++)t.push(e[n]?.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(e,t,r,i={}){this.didViewUpdate=!0;let a,o=-1,s=!1;if(typeof e==`number`)o=e,s=!0,a=this.tileset.arr[o];else{let t;t=typeof e==`string`?n.Texture.from(e):e;let r=this.tileset;for(let e=0;e<r.count;e++)if(r.arr[e]===t.source){o=e;break}`frame`in t&&(i.u=i.u??t.frame.x,i.v=i.v??t.frame.y,i.tileWidth=i.tileWidth??t.orig.width,i.tileHeight=i.tileHeight??t.orig.height),a=t.source}if(!s&&!a)return console.error(`The tile texture was not found in the tilemap tileset.`),this;let{u:c=0,v:l=0,tileWidth:u=a.width,tileHeight:d=a.height,animX:f=0,animY:p=0,rotate:m=0,animCountX:h=1024,animCountY:g=1024,animDivisor:_=1,alpha:v=1}=i,y=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||f>0||p>0,y.push(c),y.push(l),y.push(t),y.push(r),y.push(u),y.push(d),y.push(m),y.push(f|0),y.push(p|0),y.push(o),y.push(h),y.push(g),y.push(_),y.push(v),this.tilemapBounds.addFrame(t,r,t+u,r+d),this}tileRotate(e){let t=this.pointsBuf;t[t.length-(G-9)]=e}tileAnimX(e,t){let n=this.pointsBuf;n[n.length-(G-7)]=e,n[n.length-(G-10)]=t}tileAnimY(e,t){let n=this.pointsBuf;n[n.length-(G-8)]=e,n[n.length-(G-11)]=t}tileAnimDivisor(e){let t=this.pointsBuf;t[t.length-(G-12)]=e}tileAlpha(e){let t=this.pointsBuf;t[t.length-(G-13)]=e}destroyVb(){this.vb&&=(this.vb.destroy(),null)}updateBuffer(e){let t=this.pointsBuf,r=t.length/G,i=this.vb;if(this.tileset.count===0||r===0||this.rects_count===r&&i)return;this.rects_count=r,i||(i=e.createVb(),this.vb=i,this.vbId=i.id,this.vbBuffer=null);let a=r*i.vertPerQuad;e.checkIndexBuffer(r);let o=i.getBuffer(`aVertexPosition`),s=i.stride*a;if(!this.vbBuffer||this.vbBuffer.byteLength<s){let e=i.stride;for(;e<s;)e*=2;this.vbBuffer=new ArrayBuffer(e),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}let c=this.vbArray,l=this.vbInts,u=0,d=0;for(let e=0;e<t.length;e+=G){let r=.5;this.compositeParent&&(d=t[e+9]);let i=t[e+2],a=t[e+3],o=t[e+4],s=t[e+5],f=t[e+0],p=t[e+1],m=t[e+6],h=t[e+7],g=t[e+8],_=t[e+10]||1024,v=t[e+11]||1024,y=h+_*2048,b=g+v*2048,x=t[e+12],S=t[e+13],C,w,T,E,D,O,k,A;if(m===0)C=f,w=p,T=f+o,E=p,D=f+o,O=p+s,k=f,A=p+s;else{let e=o/2,t=s/2;m%4!=0&&(e=s/2,t=o/2);let r=f+e,i=p+t;m=n.groupD8.add(m,n.groupD8.NW),C=r+e*n.groupD8.uX(m),w=i+t*n.groupD8.uY(m),m=n.groupD8.add(m,2),T=r+e*n.groupD8.uX(m),E=i+t*n.groupD8.uY(m),m=n.groupD8.add(m,2),D=r+e*n.groupD8.uX(m),O=i+t*n.groupD8.uY(m),m=n.groupD8.add(m,2),k=r+e*n.groupD8.uX(m),A=i+t*n.groupD8.uY(m)}c[u++]=i,c[u++]=a,c[u++]=C,c[u++]=w,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S,c[u++]=i+o,c[u++]=a,c[u++]=T,c[u++]=E,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S,c[u++]=i+o,c[u++]=a+s,c[u++]=D,c[u++]=O,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S,c[u++]=i,c[u++]=a+s,c[u++]=k,c[u++]=A,c[u++]=f+r,c[u++]=p+r,c[u++]=f+o-r,c[u++]=p+s-r,c[u++]=y,c[u++]=b,l[u++]=d,c[u++]=x,c[u++]=S}o.data=c}isModified(e){return!!(this.rects_count*G!==this.pointsBuf.length||e&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/G}addBounds(e){let t=this.tilemapBounds;e.addFrame(t.minX,t.minY,t.maxX,t.maxY)}get bounds(){return this.tilemapBounds}destroy(e){super.destroy(e),this.destroyVb()}addFrame(e,t,n,r,i){return this.tile(e,t,n,{animX:r,animY:i}),!0}addRect(e,t,n,r,i,a,o,s=0,c=0,l=0,u=1024,d=1024,f=1,p=1){return this.tile(e,r,i,{u:t,v:n,tileWidth:a,tileHeight:o,animX:s,animY:c,rotate:l,animCountX:u,animCountY:d,animDivisor:f,alpha:p})}},st=Object.defineProperty,ct=(e,t,n)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n)=>(ct(e,typeof t==`symbol`?t:t+``,n),n),ut=class extends n.Container{constructor(e){super(),lt(this,`texturesPerTilemap`),lt(this,`tileAnim`,null),lt(this,`lastModifiedTilemap`,null),lt(this,`modificationMarker`,0),lt(this,`setBitmaps`,this.tileset),this.texturesPerTilemap=ke.TEXTURES_PER_TILEMAP,this.tileset(e)}tileset(e){e||=[];let t=this.texturesPerTilemap,n=this.children.length,r=Math.ceil(e.length/t);for(let i=0;i<Math.min(n,r);i++)this.children[i].setTileset(e.slice(i*t,(i+1)*t));for(let i=n;i<r;i++){let n=new ot(e.slice(i*t,(i+1)*t));n.compositeParent=!0,this.addChild(n)}return this}clear(){for(let e=0;e<this.children.length;e++)this.children[e].clear();return this.modificationMarker=0,this}tileRotate(e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(e),this}tileAnimX(e,t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(e,t),this}tileAnimY(e,t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(e,t),this}tileAnimDivisor(e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(e),this}tile(e,t,r,i={}){let a=null,o=this.children;if(this.lastModifiedTilemap=null,typeof e==`number`){let n=e/this.texturesPerTilemap>>0,s=0;if(a=o[n],a)s=e%this.texturesPerTilemap;else{if(a=o[0],!a)return this;s=0}a.tile(s,t,r,i)}else{typeof e==`string`&&(e=n.Texture.from(e));for(let t=0;t<o.length;t++){let n=o[t],r=n.getTileset().arr;for(let t=0;t<r.length;t++)if(r[t]===e.source){a=n;break}if(a)break}if(!a){for(let t=o.length-1;t>=0;t--){let n=o[t];if(n.getTileset().count<this.texturesPerTilemap){a=n,n.getTileset().push(e.source);break}}a||(a=new ot(e.source),a.compositeParent=!0,this.addChild(a))}a.tile(e,t,r,i)}return this.lastModifiedTilemap=a,this}isModified(e){let t=this.children;if(this.modificationMarker!==t.length)return!0;for(let n=0;n<t.length;n++)if(t[n].isModified(e))return!0;return!1}clearModify(){let e=this.children;this.modificationMarker=e.length;for(let t=0;t<e.length;t++)e[t].clearModify()}addFrame(e,t,n,r,i,a,o,s,c){return this.tile(e,t,n,{animX:r,animY:i,animCountX:a,animCountY:o,animDivisor:s,alpha:c})}addRect(e,t,n,r,i,a,o,s,c,l,u,d){let f=e/this.texturesPerTilemap>>0,p=e%this.texturesPerTilemap;return this.children[f]&&this.children[f].getTileset().count>0?(this.lastModifiedTilemap=this.children[f],this.lastModifiedTilemap.addRect(p,t,n,r,i,a,o,s,c,l,u,d)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}};n.extensions.add(ze),n.extensions.add(Xe),n.extensions.add(nt);var dt=class e extends n.AnimatedSprite{static getTextures(e,t){let n=[];return e.animations&&e.animations.length?e.animations.forEach(e=>{n.push(t.textures[e.tileid])}):n.push(t.textures[e.gid-t.firstgid]),n}constructor(t,n){super(e.getTextures(t,n)),this.tile=t,this.tileSet=n,this.animations=[],this._x=0,this._y=0,this.properties={},this.animations=t.animations||[],this.properties=t.properties,this.textures=e.getTextures(t,n),this.texture=this.textures[0],this.flip()}get z(){return this.properties.z??0}get gid(){return this.tile.gid}setAnimation(e){let t=this.animations.length;if(t>1){let n=(this.animations[1].tileid-this.animations[0].tileid)*this.width;e.tileAnimX(n,t)}}flip(){let e,t=0,r=r=>{t++,e=e?n.groupD8.add(e,r):r};this.tile.horizontalFlip&&r(n.groupD8.MIRROR_HORIZONTAL),this.tile.verticalFlip&&r(n.groupD8.MIRROR_VERTICAL),this.tile.diagonalFlip&&(t%2==0?r(n.groupD8.MAIN_DIAGONAL):r(n.groupD8.REVERSE_DIAGONAL))}};ke.use32bitIndex=!0;var ft=class e extends (0,t.DisplayObject)(ut){constructor(...e){super(...e),this._tiles={},this.frameTile=0,this.frameRateAnimation=10}static findTileSet(e,t){let n;for(let r=t.length-1;r>=0&&(n=t[r],!(n.firstgid&&n.firstgid<=e));r--);return n}createTile(t,n,r={}){let{real:i,filter:a}=r,{tilewidth:o,tileheight:s,width:c}=this._layer;i&&(t=Math.floor(t/o),n=Math.floor(n/s));let l=t+n*c,u=this._layer.getTileByIndex(l);if(!u||u&&u.gid==0)return;let d=e.findTileSet(u.gid,this.tileSets);if(!d)return;let f=new dt(u,d);if(f.x=t*o,f.y=n*s+(s-f.texture.height),f._x=t,f._y=n,d.tileoffset&&(f.x+=d.tileoffset.x??0,f.y+=d.tileoffset.y??0),!(a&&!a(f)))return f}_addFrame(e,t,n){let r=this.tile(e.texture,e.x,e.y,{rotate:e.texture.rotate});e.setAnimation(r),this._tiles[t+`;`+n]=e}async onMount(e){let{props:t}=e;this.tileSets=t.tilesets,this._layer=new Ee({...t},this.tileSets);let n=t.context.tick;this.subscriptionTick=n.observable.subscribe(({value:e})=>{e.frame%this.frameRateAnimation==0&&(this.tileAnim=[this.frameTile,this.frameTile],this.frameTile++)}),super.onMount(e)}onUpdate(e){if(super.onUpdate(e),this.isMounted){e.tileheight&&(this._layer.tileheight=e.tileheight),e.tilewidth&&(this._layer.tilewidth=e.tilewidth),e.width&&(this._layer.width=e.width),e.height&&(this._layer.height=e.height),e.parallaxX&&(this._layer.parallaxX=e.parallaxx),e.parallaxY&&(this._layer.parallaxY=e.parallaxy),this.removeChildren();for(let e=0;e<this._layer.height;e++)for(let t=0;t<this._layer.width;t++){let n=this.createTile(t,e);n&&this._addFrame(n,t,e)}}}async onDestroy(e){this.subscriptionTick.unsubscribe(),await super.onDestroy(e)}};(0,t.registerComponent)(`CompositeTileLayer`,ft);function pt(e){return(0,t.createComponent)(`CompositeTileLayer`,e)}var mt=class extends De{constructor(e){super(e),this.textures=[],this.tileGroups={}}loadGroup(){}async load(e){let t=await n.Assets.load(e);for(let e=this.margin;e<this.image.height;e+=this.tileheight+this.spacing)for(let r=this.margin;r<this.image.width;r+=this.tilewidth+this.spacing)this.textures.push(new n.Texture({source:t.source,frame:new n.Rectangle(+r,+e,+this.tilewidth,+this.tileheight)}));return this.loadGroup(),this}};function ht(e,t,n){let r=[];for(let n of e){if(n.type!==B.Tile){r.push(n);continue}let e=new Map,i;if(Array.isArray(n.data))i=n.data.map(e=>typeof e==`number`?e:parseInt(String(e),10));else{r.push(n);continue}let a=0,o=0;for(let n=0;n<i.length;n++){let r=i[n];if(r===0)continue;a++;let s;for(let e=t.length-1;e>=0;e--)if(t[e].firstgid&&t[e].firstgid<=r){s=t[e];break}if(!s){e.has(0)||e.set(0,Array(i.length).fill(0)),e.get(0)[n]=r;continue}let c=r-s.firstgid,l=s.tileset.tiles?.[c]?.properties,u=l?.z??0;l?.z!==void 0&&o++,e.has(u)||e.set(u,Array(i.length).fill(0)),e.get(u)[n]=r}let s=Array.from(e.keys()).sort((e,t)=>e-t);for(let t of s){let i=e.get(t);if(i.some(e=>e!==0)){let e={...n,name:`${n.name}_z${t}`,data:i,properties:{...n.properties,z:t}};r.push(e)}}}return r.sort((e,t)=>(e.properties?.z??.5)-(t.properties?.z??.5)),r}function gt(e){let{map:n,basePath:r,createLayersPerTilesZ:i}=(0,t.useProps)(e,{createLayersPerTilesZ:!1,basePath:``}),a=(0,t.signal)([]),o=e.objectLayer,s=[],c={},l=async(e,t=``)=>typeof e==`string`?await new Oe(e,{basePath:t}).parseFilePromise({getOnlyBasename:!1}):e;(0,t.effect)(async()=>{let e=n();if(e){c=await l(e,r()),s=[];for(let e of c.tilesets)e.tile&&(e.tiles=e.tile),e.tiles||=[],s.push(await new mt(e).load(e.image.source));let t=c.layers;i()&&(t=ht(c.layers,s,c)),a.set(t)}});let u=(e,n={})=>(0,t.h)(t.Container,n,(0,t.loop)(e,e=>{switch(e.type){case B.Tile:return(0,t.h)(pt,{tilewidth:c.tilewidth,tileheight:c.tileheight,width:c.width,height:c.height,...e,tilesets:s});case B.Image:let{width:n,height:r,source:i}=e.image;return(0,t.h)(t.TilingSprite,{image:i,...e,width:e.repeatx?e.width*e.tilewidth:n,height:e.repeaty?e.height*e.tileheight:r});case B.Group:return u((0,t.signal)(e.layers),e);case B.ObjectGroup:let a=o?.(e);return(0,t.h)(t.Container,e,a);default:return(0,t.h)(t.Container)}}));return(0,t.h)(t.Container,e,u(a))}function _t(){return new n.GlProgram({vertex:`
213
213
  precision mediump float;
214
214
  in vec2 aPosition;
215
215
  in vec2 aUV;
@@ -222,7 +222,7 @@ fn mainFrag(
222
222
  mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
223
223
  gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
224
224
  }
225
- `,t=`
225
+ `,fragment:`
226
226
  precision mediump float;
227
227
  in vec2 vUV;
228
228
  out vec4 finalColor;
@@ -303,7 +303,7 @@ fn mainFrag(
303
303
  float alpha = clamp(rain * 1.15, 0.0, 0.95);
304
304
  finalColor = vec4(rainColor * alpha, alpha);
305
305
  }
306
- `;return new L.GlProgram({vertex:n,fragment:t})}function Jr(){const n=`
306
+ `})}function vt(){return new n.GlProgram({vertex:`
307
307
  precision mediump float;
308
308
  in vec2 aPosition;
309
309
  in vec2 aUV;
@@ -316,7 +316,7 @@ fn mainFrag(
316
316
  mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
317
317
  gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
318
318
  }
319
- `,t=`
319
+ `,fragment:`
320
320
  precision mediump float;
321
321
  in vec2 vUV;
322
322
  out vec4 finalColor;
@@ -404,7 +404,7 @@ fn mainFrag(
404
404
  float alpha = clamp(snow * 1.1, 0.0, 0.92);
405
405
  finalColor = vec4(snowColor * alpha, alpha);
406
406
  }
407
- `;return new L.GlProgram({vertex:n,fragment:t})}function tn(){const n=`
407
+ `})}function yt(){return new n.GlProgram({vertex:`
408
408
  precision mediump float;
409
409
  in vec2 aPosition;
410
410
  in vec2 aUV;
@@ -417,7 +417,7 @@ fn mainFrag(
417
417
  mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
418
418
  gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
419
419
  }
420
- `,t=`
420
+ `,fragment:`
421
421
  precision mediump float;
422
422
  in vec2 vUV;
423
423
  out vec4 finalColor;
@@ -512,7 +512,7 @@ fn mainFrag(
512
512
  vec3 fogColor = mix(baseColor, brightColor, detail * 0.45);
513
513
  finalColor = vec4(fogColor * alpha, alpha);
514
514
  }
515
- `;return new L.GlProgram({vertex:n,fragment:t})}function en(){const n=`
515
+ `})}function bt(){return new n.GlProgram({vertex:`
516
516
  precision mediump float;
517
517
  in vec2 aPosition;
518
518
  in vec2 aUV;
@@ -525,7 +525,7 @@ fn mainFrag(
525
525
  mat3 modelViewProjectionMatrix = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;
526
526
  gl_Position = vec4((modelViewProjectionMatrix * vec3(aPosition, 1.0)).xy, 0.0, 1.0);
527
527
  }
528
- `,t=`
528
+ `,fragment:`
529
529
  precision mediump float;
530
530
  in vec2 vUV;
531
531
  out vec4 finalColor;
@@ -648,7 +648,7 @@ fn mainFrag(
648
648
  }
649
649
  finalColor = vec4(premulColor, alpha);
650
650
  }
651
- `;return new L.GlProgram({vertex:n,fragment:t})}const Ti={lightRain:{effect:"rain",speed:.35,windDirection:.1,windStrength:.15,density:110,maxDrops:90},steadyRain:{effect:"rain",speed:.6,windDirection:.2,windStrength:.3,density:180,maxDrops:120},stormRain:{effect:"rain",speed:1.4,windDirection:.7,windStrength:.75,density:300,maxDrops:150}},Mi={lightSnow:{effect:"snow",speed:.35,windDirection:.1,windStrength:.18,density:90,maxDrops:100},winterSnow:{effect:"snow",speed:.5,windDirection:.2,windStrength:.28,density:150,maxDrops:130},blizzardSnow:{effect:"snow",speed:1.1,windDirection:.8,windStrength:.75,density:290,maxDrops:160}},Ci={rpgMorningMist:{effect:"fog",speed:.16,density:.75,height:.45,scale:1.35},rpgForestFog:{effect:"fog",speed:.22,density:1,height:.62,scale:1.75},rpgSwampFog:{effect:"fog",speed:.14,density:1.3,height:.55,scale:2.1},rpgNightFog:{effect:"fog",speed:.12,density:1.15,height:.58,scale:1.9},rpgHeavyFog:{effect:"fog",speed:.1,density:1.7,height:.72,scale:2.3}},Fi={lightClouds:{effect:"cloud",speed:.16,density:.55,height:.72,scale:1.35,sunIntensity:1,sunAngle:.84,raySpread:.92,rayTwinkle:.25,rayTwinkleSpeed:.9},overcastClouds:{effect:"cloud",speed:.12,density:.95,height:.86,scale:1.85,sunIntensity:.4,sunAngle:.95,raySpread:1.15,rayTwinkle:.18,rayTwinkleSpeed:.7},stormClouds:{effect:"cloud",speed:.2,density:1.25,height:.94,scale:2.2,sunIntensity:.12,sunAngle:1.08,raySpread:1.35,rayTwinkle:.12,rayTwinkleSpeed:.6},goldenHourRays:{effect:"cloud",speed:.14,density:.72,height:.82,scale:1.5,sunIntensity:1.3,sunAngle:.72,raySpread:.78,rayTwinkle:.78,rayTwinkleSpeed:1.4},sunnySoftRays:{effect:"cloud",speed:.13,density:.62,height:.76,scale:1.4,sunIntensity:1.05,sunAngle:.8,raySpread:.95,rayTwinkle:.35,rayTwinkleSpeed:.95},sunsetTwinkleRays:{effect:"cloud",speed:.1,density:.74,height:.84,scale:1.55,sunIntensity:1.35,sunAngle:.64,raySpread:.8,rayTwinkle:1,rayTwinkleSpeed:1.6},dramaticCrepuscularRays:{effect:"cloud",speed:.11,density:.9,height:.9,scale:1.9,sunIntensity:1.5,sunAngle:.7,raySpread:.68,rayTwinkle:.6,rayTwinkleSpeed:1.2},morningHazeRays:{effect:"cloud",speed:.09,density:.52,height:.7,scale:1.3,sunIntensity:.9,sunAngle:.9,raySpread:1.05,rayTwinkle:.42,rayTwinkleSpeed:.8}},rn={rain:Ti,snow:Mi,fog:Ci,cloud:Fi},Bi=n=>{const{effect:t=D.signal("rain"),speed:e=D.signal(.5),windDirection:i=D.signal(0),windStrength:r=D.signal(.2),density:l=D.signal(120),maxDrops:c=D.signal(80),height:a=D.signal(1),scale:g=D.signal(2),sunIntensity:S=D.signal(.85),sunAngle:w=D.signal(.85),raySpread:C=D.signal(1),rayTwinkle:M=D.signal(.45),rayTwinkleSpeed:N=D.signal(1),resolution:F,...k}=D.useProps(n),R=D.signal([1e3,1e3]),m=D.signal(R()[0]),x=D.signal(R()[1]),y=D.signal(0),f=D.signal(0);let A;const P=typeof t=="function"?t:D.signal(t),I=F?typeof F=="function"?F:D.signal(F):R;D.mount(o=>{const p=o.props.context;let v=o.parent,b=!1;for(;v;){if(v.tag==="Viewport"){b=!0;break}v=v.parent}if(A=b?p?.viewport:void 0,A?.getVisibleBounds){const T=A.getVisibleBounds();T&&T.width>0&&T.height>0&&(R.set([T.width,T.height]),m.set(T.width),x.set(T.height),y.set(T.x),f.set(T.y))}p?.canvasSize&&D.effect(()=>{const T=p.canvasSize();T&&T.width>0&&T.height>0&&(A?.getVisibleBounds||(R.set([T.width,T.height]),m.set(T.width),x.set(T.height),y.set(0),f.set(0)))})});const O=typeof e=="function"?e:D.signal(e),_=typeof i=="function"?i:D.signal(i),U=typeof r=="function"?r:D.signal(r),V=typeof l=="function"?l:D.signal(l),z=typeof c=="function"?c:D.signal(c),K=typeof a=="function"?a:D.signal(a),et=typeof g=="function"?g:D.signal(g),Q=typeof S=="function"?S:D.signal(S),W=typeof w=="function"?w:D.signal(w),Y=typeof C=="function"?C:D.signal(C),Z=typeof M=="function"?M:D.signal(M),yt=typeof N=="function"?N:D.signal(N),ct=o=>typeof o=="number"&&Number.isFinite(o)?o:1,H=o=>typeof o=="number"&&Number.isFinite(o)?Math.max(0,o):.85,it=o=>typeof o=="number"&&Number.isFinite(o)?o:.85,vt=o=>typeof o=="number"&&Number.isFinite(o)&&o>0?o:1,j=o=>typeof o=="number"&&Number.isFinite(o)?Math.max(0,o):.45,Mt=o=>typeof o=="number"&&Number.isFinite(o)&&o>0?o:1,bt=o=>[Math.cos(o),Math.sin(o)],d=o=>{if(!Array.isArray(o))return[1,1];const p=typeof o[0]=="number"&&Number.isFinite(o[0])&&o[0]>0?o[0]:1,v=typeof o[1]=="number"&&Number.isFinite(o[1])&&o[1]>0?o[1]:1;return[p,v]};let u,B;if(P()==="rain")u=Zr(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uRainSpeed:{value:O(),type:"f32"},uWindDirection:{value:_(),type:"f32"},uWindStrength:{value:U(),type:"f32"},uRainDensity:{value:V(),type:"f32"},uMaxDrops:{value:z(),type:"f32"}};else if(P()==="snow")u=Jr(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uSnowSpeed:{value:O(),type:"f32"},uWindDirection:{value:_(),type:"f32"},uWindStrength:{value:U(),type:"f32"},uSnowDensity:{value:V(),type:"f32"},uMaxFlakes:{value:z(),type:"f32"}};else if(P()==="fog")u=tn(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uSpeed:{value:O(),type:"f32"},uScale:{value:et(),type:"f32"},uDensity:{value:V(),type:"f32"},uHeight:{value:ct(K()),type:"f32"},uViewportOrigin:{value:[y(),f()],type:"vec2<f32>"}};else if(P()==="cloud"){const o=it(W());u=en(),B={uTime:{value:0,type:"f32"},uResolution:{value:d(I()),type:"vec2<f32>"},uSpeed:{value:O(),type:"f32"},uScale:{value:et(),type:"f32"},uDensity:{value:V(),type:"f32"},uHeight:{value:ct(K()),type:"f32"},uViewportOrigin:{value:[y(),f()],type:"vec2<f32>"},uSunIntensity:{value:H(Q()),type:"f32"},uSunDirection:{value:bt(o),type:"vec2<f32>"},uRaySpread:{value:vt(Y()),type:"f32"},uRayTwinkle:{value:j(Z()),type:"f32"},uRayTwinkleSpeed:{value:Mt(yt()),type:"f32"}}}else throw new Error(`Unknown weather effect: ${P()}. Supported: rain, snow, fog, cloud`);const E=new L.UniformGroup(B),J=new L.Shader({glProgram:u,resources:{uniforms:E}}),ut=new L.Geometry({attributes:{aPosition:[0,0,1,0,1,1,0,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]});let rt=Math.random()*10,G=[...d(I())],X=_(),tt=U(),q=O(),ot=V(),xt=z(),wt=K(),ft=et(),Et=H(Q()),Kt=it(W()),Jt=vt(Y()),Nt=j(Z()),ie=Mt(yt()),h=y(),s=f();return D.tick(({deltaTime:o})=>{if(A?.getVisibleBounds){const b=A.getVisibleBounds();if(b&&b.width>0&&b.height>0){const T=b.width,$=b.height,at=b.x,lt=b.y;T!==m()&&m.set(T),$!==x()&&x.set($),at!==y()&&y.set(at),lt!==f()&&f.set(lt);const dt=R();(dt[0]!==T||dt[1]!==$)&&R.set([T,$])}}rt+=o/600,E.uniforms.uTime=rt;const p=d(I());if((p[0]!==G[0]||p[1]!==G[1])&&(E.uniforms.uResolution=p,G=[...p]),P()==="fog"||P()==="cloud"){const b=y(),T=f();(b!==h||T!==s)&&(E.uniforms.uViewportOrigin=[b,T],h=b,s=T)}const v=_();if(v!==X&&(E.uniforms.uWindDirection=v,X=v),P()==="rain"||P()==="snow"){const b=U();b!==tt&&(E.uniforms.uWindStrength=b,tt=b)}if(P()==="rain"){const b=O();b!==q&&(E.uniforms.uRainSpeed=b,q=b);const T=V();T!==ot&&(E.uniforms.uRainDensity=T,ot=T);const $=z();$!==xt&&(E.uniforms.uMaxDrops=$,xt=$)}else if(P()==="snow"){const b=O();b!==q&&(E.uniforms.uSnowSpeed=b,q=b);const T=V();T!==ot&&(E.uniforms.uSnowDensity=T,ot=T);const $=z();$!==xt&&(E.uniforms.uMaxFlakes=$,xt=$)}else if(P()==="fog"||P()==="cloud"){const b=O();b!==q&&(E.uniforms.uSpeed=b,q=b);const T=et();T!==ft&&(E.uniforms.uScale=T,ft=T);const $=V();$!==ot&&(E.uniforms.uDensity=$,ot=$);const at=ct(K());if(at!==wt&&(E.uniforms.uHeight=at,wt=at),P()==="cloud"){const lt=H(Q());lt!==Et&&(E.uniforms.uSunIntensity=lt,Et=lt);const dt=it(W());dt!==Kt&&(E.uniforms.uSunDirection=bt(dt),Kt=dt);const ht=vt(Y());ht!==Jt&&(E.uniforms.uRaySpread=ht,Jt=ht);const $e=j(Z());$e!==Nt&&(E.uniforms.uRayTwinkle=$e,Nt=$e);const He=Mt(yt());He!==ie&&(E.uniforms.uRayTwinkleSpeed=He,ie=He)}}}),D.h(D.Mesh,{...k,geometry:ut,shader:J,width:m,height:x,x:y,y:f})},nn=Bi,sn=[0,0,0,1],on=[0,0,0,.55],Ge={clarity:0,explored:!1},je=()=>Ge,Ni=new WeakMap,Lt=(n,t,e)=>Math.max(t,Math.min(e,n)),an=(n,t,e)=>{if(t<=n)return e>=t?1:0;const i=Lt((e-n)/(t-n),0,1);return i*i*(3-2*i)},St=n=>typeof n=="function"?n():n;function ln(){const n=D.signal(0);let t=je;const e=(r,l)=>(n(),!Number.isFinite(r)||!Number.isFinite(l)?Ge:t(r,l)),i={version:()=>n(),clarityAt:(r,l)=>Lt(e(r,l).clarity,0,1),isVisibleAt:(r,l,c=.65)=>e(r,l).clarity>=Lt(c,0,1),isExploredAt:(r,l)=>{const c=e(r,l);return c.explored||c.clarity>0},stateAt:(r,l,c=.65)=>{const a=e(r,l);return a.clarity>=Lt(c,0,1)?"visible":a.explored||a.clarity>0?"explored":"unknown"}};return Ni.set(i,{setSampler(r){t=typeof r=="function"?r:je},notifyUpdate(){n.update(r=>r+1)}}),i}const Ii=(n,t)=>{const e=Array.isArray(n)?n:t,[i,r,l,c]=e,a=(g,S=!1)=>Number.isFinite(g)?g>=0&&g<=1?Math.round(g*255):Lt(Math.round(g),0,255):S?255:0;return{r:a(i),g:a(r),b:a(l),a:a(c,!0)}},cn=n=>{const t=St(n);return Array.isArray(t)?t:[]};function un(n){const{mapWidth:t,mapHeight:e,tileSize:i=D.signal(32),smooth:r=D.signal(!0),renderScale:l=D.signal(2),edgeSoftness:c=D.signal(22),visionSources:a=D.signal([]),colors:g=D.signal({}),updateHz:S=D.signal(15),initialExplored:w=D.signal(!1),controller:C=void 0,obstacleMap:M=void 0,...N}=D.useProps(n);let F,k=null,R=L.Texture.WHITE,m=null,x=null,y=new Float32Array(0),f=new Uint8Array(0),A=1,P=1,I=1,O=1,_=1,U=1,V=1,z=1,K=0,et=!0,Q=null,W=null,Y=[];if(F=(()=>{if(typeof document>"u")throw new Error("FogOfWar: document is undefined, canvas cannot be created.");const G=document.createElement("canvas");return G.width=1,G.height=1,G})(),k=F.getContext("2d",{willReadFrequently:!0}),!k)throw new Error("FogOfWar: unable to create 2D context for fog canvas.");R=L.Texture.from(F);const yt=()=>{const X=St(r)!==!1?2:1,tt=Number(St(l));return Number.isFinite(tt)?Lt(Math.round(tt),1,8):X},ct=()=>{if(St(r)===!1)return 0;const G=Number(St(c));return Number.isFinite(G)?Math.max(0,G):Math.max(V*.9,2)},H=()=>{const G=St(C);return G&&typeof G=="object"?G:void 0},it=()=>{const G=cn(a),X=[];for(let tt=0;tt<G.length;tt++){const q=G[tt];X.push({x:Number(St(q.x)),y:Number(St(q.y)),radius:Number(St(q.radius)),enabled:St(q.enabled)!==!1})}return X},vt=G=>{const X=new Array(G.length*4);let tt=0;for(let ot=0;ot<G.length;ot++){const xt=G[ot];X[tt++]=xt.x,X[tt++]=xt.y,X[tt++]=xt.radius,X[tt++]=xt.enabled?1:0}let q=X.length!==Y.length;if(!q)for(let ot=0;ot<X.length;ot++){const xt=X[ot],wt=Y[ot];if(Number.isNaN(xt)!==Number.isNaN(wt)||Math.abs(xt-wt)>.01){q=!0;break}}return Y=X,q},j=(G,X)=>{if(!Number.isFinite(G)||!Number.isFinite(X)||I<=0||A<=0||P<=0)return Ge;const tt=Lt(G,0,Math.max(0,O-1)),q=Lt(X,0,Math.max(0,_-1)),ot=Math.min(A-1,Math.max(0,Math.floor(tt/V))),wt=Math.min(P-1,Math.max(0,Math.floor(q/V)))*A+ot;return{clarity:Lt(y[wt]??0,0,1),explored:f[wt]===1}},Mt=G=>{const X=H()??null;X!==Q&&(W&&W.setSampler(je),Q=X,W=Q?Ni.get(Q)??null:null,W&&W.setSampler(j),G=!0),G&&W&&W.notifyUpdate()},bt=()=>{const G=R.source;G&&(G.scaleMode=St(r)===!1?"nearest":"linear")},d=(G,X,tt,q)=>{O=Math.max(1,Math.floor(G)),_=Math.max(1,Math.floor(X)),U=Math.max(1,Math.floor(tt)),z=Lt(q,1,8),V=Math.max(1,U/z),A=Math.max(1,Math.ceil(O/V)),P=Math.max(1,Math.ceil(_/V)),I=A*P,"width"in F&&(F.width=A,F.height=P),y=new Float32Array(I),f=new Uint8Array(I),St(w)&&f.fill(1),m=k?.createImageData(A,P)??null,x=m?.data??null,bt(),et=!0},u=(G,X)=>{if(G.enabled===!1||!Number.isFinite(G.x)||!Number.isFinite(G.y)||!Number.isFinite(G.radius)||G.radius<=0)return;const tt=G.x,q=G.y,xt=G.radius/V,wt=Math.max(0,xt-X),ft=Math.max(xt,xt+X),Et=wt*wt,Kt=ft*ft,Jt=Math.max(0,Math.floor(tt/V-ft)),Nt=Math.min(A-1,Math.ceil(tt/V+ft)),ie=Math.max(0,Math.floor(q/V-ft)),h=Math.min(P-1,Math.ceil(q/V+ft));for(let s=ie;s<=h;s++)for(let o=Jt;o<=Nt;o++){const p=(o+.5)*V,v=(s+.5)*V,b=p-tt,T=v-q,$=(b*b+T*T)/(V*V);if($>Kt)continue;let at=1;if(ft>wt&&$>Et){const dt=Math.sqrt($);at=1-an(wt,ft,dt)}if(at<=.001)continue;const lt=s*A+o;at>y[lt]&&(y[lt]=at),at>.02&&(f[lt]=1)}},B=G=>{if(!m||!x||!k)return;const X=St(g)||{},tt=Ii(X.unknown,sn),q=Ii(X.explored,on);y.fill(0);const ot=G??it(),xt=ct()/V;for(let ft=0;ft<ot.length;ft++)u(ot[ft],xt);for(let ft=0;ft<I;ft++){const Et=ft*4,Kt=Lt(y[ft],0,1),Nt=f[ft]===1?q:tt;x[Et]=Nt.r,x[Et+1]=Nt.g,x[Et+2]=Nt.b,x[Et+3]=Math.round(Nt.a*(1-Kt))}k.putImageData(m,0,0);const wt=R.source;wt&&typeof wt.update=="function"?wt.update():typeof R.update=="function"&&R.update(),Mt(!0)},E=Number(St(t))||1,J=Number(St(e))||1,ut=Number(St(i))||32,rt=yt();return d(E,J,ut,rt),B(),D.tick(({deltaTime:G})=>{if(!k)return;const X=Math.max(1,Number(St(t))||1),tt=Math.max(1,Number(St(e))||1),q=Math.max(1,Number(St(i))||32),ot=yt();(X!==O||tt!==_||q!==U||ot!==z)&&d(X,tt,q,ot),bt(),Mt(!1);const xt=it(),wt=vt(xt);wt&&(et=!0);const Et=1e3/Math.max(1,Number(St(S))||15);K+=G,(et||wt||K>=Et)&&(K=0,et=!1,B(xt))}),D.h(D.Sprite,{...N,texture:R,x:0,y:0,width:Math.max(1,Number(St(t))||1),height:Math.max(1,Number(St(e))||1),roundPixels:!0})}const hn=`/**
651
+ `})}var xt={lightRain:{effect:`rain`,speed:.35,windDirection:.1,windStrength:.15,density:110,maxDrops:90},steadyRain:{effect:`rain`,speed:.6,windDirection:.2,windStrength:.3,density:180,maxDrops:120},stormRain:{effect:`rain`,speed:1.4,windDirection:.7,windStrength:.75,density:300,maxDrops:150}},St={lightSnow:{effect:`snow`,speed:.35,windDirection:.1,windStrength:.18,density:90,maxDrops:100},winterSnow:{effect:`snow`,speed:.5,windDirection:.2,windStrength:.28,density:150,maxDrops:130},blizzardSnow:{effect:`snow`,speed:1.1,windDirection:.8,windStrength:.75,density:290,maxDrops:160}},Ct={rpgMorningMist:{effect:`fog`,speed:.16,density:.75,height:.45,scale:1.35},rpgForestFog:{effect:`fog`,speed:.22,density:1,height:.62,scale:1.75},rpgSwampFog:{effect:`fog`,speed:.14,density:1.3,height:.55,scale:2.1},rpgNightFog:{effect:`fog`,speed:.12,density:1.15,height:.58,scale:1.9},rpgHeavyFog:{effect:`fog`,speed:.1,density:1.7,height:.72,scale:2.3}},wt={lightClouds:{effect:`cloud`,speed:.16,density:.55,height:.72,scale:1.35,sunIntensity:1,sunAngle:.84,raySpread:.92,rayTwinkle:.25,rayTwinkleSpeed:.9},overcastClouds:{effect:`cloud`,speed:.12,density:.95,height:.86,scale:1.85,sunIntensity:.4,sunAngle:.95,raySpread:1.15,rayTwinkle:.18,rayTwinkleSpeed:.7},stormClouds:{effect:`cloud`,speed:.2,density:1.25,height:.94,scale:2.2,sunIntensity:.12,sunAngle:1.08,raySpread:1.35,rayTwinkle:.12,rayTwinkleSpeed:.6},goldenHourRays:{effect:`cloud`,speed:.14,density:.72,height:.82,scale:1.5,sunIntensity:1.3,sunAngle:.72,raySpread:.78,rayTwinkle:.78,rayTwinkleSpeed:1.4},sunnySoftRays:{effect:`cloud`,speed:.13,density:.62,height:.76,scale:1.4,sunIntensity:1.05,sunAngle:.8,raySpread:.95,rayTwinkle:.35,rayTwinkleSpeed:.95},sunsetTwinkleRays:{effect:`cloud`,speed:.1,density:.74,height:.84,scale:1.55,sunIntensity:1.35,sunAngle:.64,raySpread:.8,rayTwinkle:1,rayTwinkleSpeed:1.6},dramaticCrepuscularRays:{effect:`cloud`,speed:.11,density:.9,height:.9,scale:1.9,sunIntensity:1.5,sunAngle:.7,raySpread:.68,rayTwinkle:.6,rayTwinkleSpeed:1.2},morningHazeRays:{effect:`cloud`,speed:.09,density:.52,height:.7,scale:1.3,sunIntensity:.9,sunAngle:.9,raySpread:1.05,rayTwinkle:.42,rayTwinkleSpeed:.8}},Tt={rain:xt,snow:St,fog:Ct,cloud:wt},Et=e=>{let{effect:r=(0,t.signal)(`rain`),speed:i=(0,t.signal)(.5),windDirection:a=(0,t.signal)(0),windStrength:o=(0,t.signal)(.2),density:s=(0,t.signal)(120),maxDrops:c=(0,t.signal)(80),height:l=(0,t.signal)(1),scale:u=(0,t.signal)(2),sunIntensity:d=(0,t.signal)(.85),sunAngle:f=(0,t.signal)(.85),raySpread:p=(0,t.signal)(1),rayTwinkle:m=(0,t.signal)(.45),rayTwinkleSpeed:h=(0,t.signal)(1),resolution:g,..._}=(0,t.useProps)(e),v=(0,t.signal)([1e3,1e3]),y=(0,t.signal)(v()[0]),b=(0,t.signal)(v()[1]),x=(0,t.signal)(0),S=(0,t.signal)(0),C,w=typeof r==`function`?r:(0,t.signal)(r),T=g?typeof g==`function`?g:(0,t.signal)(g):v;(0,t.mount)(e=>{let n=e.props.context,r=e.parent,i=!1;for(;r;){if(r.tag===`Viewport`){i=!0;break}r=r.parent}if(C=i?n?.viewport:void 0,C?.getVisibleBounds){let e=C.getVisibleBounds();e&&e.width>0&&e.height>0&&(v.set([e.width,e.height]),y.set(e.width),b.set(e.height),x.set(e.x),S.set(e.y))}n?.canvasSize&&(0,t.effect)(()=>{let e=n.canvasSize();e&&e.width>0&&e.height>0&&(C?.getVisibleBounds||(v.set([e.width,e.height]),y.set(e.width),b.set(e.height),x.set(0),S.set(0)))})});let E=typeof i==`function`?i:(0,t.signal)(i),D=typeof a==`function`?a:(0,t.signal)(a),O=typeof o==`function`?o:(0,t.signal)(o),k=typeof s==`function`?s:(0,t.signal)(s),A=typeof c==`function`?c:(0,t.signal)(c),j=typeof l==`function`?l:(0,t.signal)(l),M=typeof u==`function`?u:(0,t.signal)(u),N=typeof d==`function`?d:(0,t.signal)(d),P=typeof f==`function`?f:(0,t.signal)(f),F=typeof p==`function`?p:(0,t.signal)(p),I=typeof m==`function`?m:(0,t.signal)(m),L=typeof h==`function`?h:(0,t.signal)(h),R=e=>typeof e==`number`&&Number.isFinite(e)?e:1,ee=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,e):.85,te=e=>typeof e==`number`&&Number.isFinite(e)?e:.85,ne=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:1,re=e=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,e):.45,ie=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:1,z=e=>[Math.cos(e),Math.sin(e)],B=e=>Array.isArray(e)?[typeof e[0]==`number`&&Number.isFinite(e[0])&&e[0]>0?e[0]:1,typeof e[1]==`number`&&Number.isFinite(e[1])&&e[1]>0?e[1]:1]:[1,1],ae,oe;if(w()===`rain`)ae=_t(),oe={uTime:{value:0,type:`f32`},uResolution:{value:B(T()),type:`vec2<f32>`},uRainSpeed:{value:E(),type:`f32`},uWindDirection:{value:D(),type:`f32`},uWindStrength:{value:O(),type:`f32`},uRainDensity:{value:k(),type:`f32`},uMaxDrops:{value:A(),type:`f32`}};else if(w()===`snow`)ae=vt(),oe={uTime:{value:0,type:`f32`},uResolution:{value:B(T()),type:`vec2<f32>`},uSnowSpeed:{value:E(),type:`f32`},uWindDirection:{value:D(),type:`f32`},uWindStrength:{value:O(),type:`f32`},uSnowDensity:{value:k(),type:`f32`},uMaxFlakes:{value:A(),type:`f32`}};else if(w()===`fog`)ae=yt(),oe={uTime:{value:0,type:`f32`},uResolution:{value:B(T()),type:`vec2<f32>`},uSpeed:{value:E(),type:`f32`},uScale:{value:M(),type:`f32`},uDensity:{value:k(),type:`f32`},uHeight:{value:R(j()),type:`f32`},uViewportOrigin:{value:[x(),S()],type:`vec2<f32>`}};else if(w()===`cloud`){let e=te(P());ae=bt(),oe={uTime:{value:0,type:`f32`},uResolution:{value:B(T()),type:`vec2<f32>`},uSpeed:{value:E(),type:`f32`},uScale:{value:M(),type:`f32`},uDensity:{value:k(),type:`f32`},uHeight:{value:R(j()),type:`f32`},uViewportOrigin:{value:[x(),S()],type:`vec2<f32>`},uSunIntensity:{value:ee(N()),type:`f32`},uSunDirection:{value:z(e),type:`vec2<f32>`},uRaySpread:{value:ne(F()),type:`f32`},uRayTwinkle:{value:re(I()),type:`f32`},uRayTwinkleSpeed:{value:ie(L()),type:`f32`}}}else throw Error(`Unknown weather effect: ${w()}. Supported: rain, snow, fog, cloud`);let V=new n.UniformGroup(oe),se=new n.Shader({glProgram:ae,resources:{uniforms:V}}),ce=new n.Geometry({attributes:{aPosition:[0,0,1,0,1,1,0,1],aUV:[0,0,1,0,1,1,0,1]},indexBuffer:[0,1,2,0,2,3]}),le=Math.random()*10,ue=[...B(T())],de=D(),fe=O(),pe=E(),me=k(),he=A(),ge=j(),_e=M(),H=ee(N()),ve=te(P()),ye=ne(F()),U=re(I()),be=ie(L()),xe=x(),Se=S();return(0,t.tick)(({deltaTime:e})=>{if(C?.getVisibleBounds){let e=C.getVisibleBounds();if(e&&e.width>0&&e.height>0){let t=e.width,n=e.height,r=e.x,i=e.y;t!==y()&&y.set(t),n!==b()&&b.set(n),r!==x()&&x.set(r),i!==S()&&S.set(i);let a=v();(a[0]!==t||a[1]!==n)&&v.set([t,n])}}le+=e/600,V.uniforms.uTime=le;let t=B(T());if((t[0]!==ue[0]||t[1]!==ue[1])&&(V.uniforms.uResolution=t,ue=[...t]),w()===`fog`||w()===`cloud`){let e=x(),t=S();(e!==xe||t!==Se)&&(V.uniforms.uViewportOrigin=[e,t],xe=e,Se=t)}let n=D();if(n!==de&&(V.uniforms.uWindDirection=n,de=n),w()===`rain`||w()===`snow`){let e=O();e!==fe&&(V.uniforms.uWindStrength=e,fe=e)}if(w()===`rain`){let e=E();e!==pe&&(V.uniforms.uRainSpeed=e,pe=e);let t=k();t!==me&&(V.uniforms.uRainDensity=t,me=t);let n=A();n!==he&&(V.uniforms.uMaxDrops=n,he=n)}else if(w()===`snow`){let e=E();e!==pe&&(V.uniforms.uSnowSpeed=e,pe=e);let t=k();t!==me&&(V.uniforms.uSnowDensity=t,me=t);let n=A();n!==he&&(V.uniforms.uMaxFlakes=n,he=n)}else if(w()===`fog`||w()===`cloud`){let e=E();e!==pe&&(V.uniforms.uSpeed=e,pe=e);let t=M();t!==_e&&(V.uniforms.uScale=t,_e=t);let n=k();n!==me&&(V.uniforms.uDensity=n,me=n);let r=R(j());if(r!==ge&&(V.uniforms.uHeight=r,ge=r),w()===`cloud`){let e=ee(N());e!==H&&(V.uniforms.uSunIntensity=e,H=e);let t=te(P());t!==ve&&(V.uniforms.uSunDirection=z(t),ve=t);let n=ne(F());n!==ye&&(V.uniforms.uRaySpread=n,ye=n);let r=re(I());r!==U&&(V.uniforms.uRayTwinkle=r,U=r);let i=ie(L());i!==be&&(V.uniforms.uRayTwinkleSpeed=i,be=i)}}}),(0,t.h)(t.Mesh,{..._,geometry:ce,shader:se,width:y,height:b,x,y:S})},Dt=Et,Ot=[0,0,0,1],kt=[0,0,0,.55],At={clarity:0,explored:!1},jt=()=>At,Mt=new WeakMap,Nt=(e,t,n)=>Math.max(t,Math.min(n,e)),Pt=(e,t,n)=>{if(t<=e)return+(n>=t);let r=Nt((n-e)/(t-e),0,1);return r*r*(3-2*r)},K=e=>typeof e==`function`?e():e;function Ft(){let e=(0,t.signal)(0),n=jt,r=(t,r)=>(e(),!Number.isFinite(t)||!Number.isFinite(r)?At:n(t,r)),i={version:()=>e(),clarityAt:(e,t)=>Nt(r(e,t).clarity,0,1),isVisibleAt:(e,t,n=.65)=>r(e,t).clarity>=Nt(n,0,1),isExploredAt:(e,t)=>{let n=r(e,t);return n.explored||n.clarity>0},stateAt:(e,t,n=.65)=>{let i=r(e,t);return i.clarity>=Nt(n,0,1)?`visible`:i.explored||i.clarity>0?`explored`:`unknown`}};return Mt.set(i,{setSampler(e){n=typeof e==`function`?e:jt},notifyUpdate(){e.update(e=>e+1)}}),i}var It=(e,t)=>{let[n,r,i,a]=Array.isArray(e)?e:t,o=(e,t=!1)=>Number.isFinite(e)?e>=0&&e<=1?Math.round(e*255):Nt(Math.round(e),0,255):t?255:0;return{r:o(n),g:o(r),b:o(i),a:o(a,!0)}},Lt=e=>{let t=K(e);return Array.isArray(t)?t:[]};function Rt(e){let{mapWidth:r,mapHeight:i,tileSize:a=(0,t.signal)(32),smooth:o=(0,t.signal)(!0),renderScale:s=(0,t.signal)(2),edgeSoftness:c=(0,t.signal)(22),visionSources:l=(0,t.signal)([]),colors:u=(0,t.signal)({}),updateHz:d=(0,t.signal)(15),initialExplored:f=(0,t.signal)(!1),controller:p=void 0,obstacleMap:m=void 0,...h}=(0,t.useProps)(e),g,_=null,v=n.Texture.WHITE,y=null,b=null,x=new Float32Array,S=new Uint8Array,C=1,w=1,T=1,E=1,D=1,O=1,k=1,A=1,j=0,M=!0,N=null,P=null,F=[];if(g=(()=>{if(typeof document>`u`)throw Error(`FogOfWar: document is undefined, canvas cannot be created.`);let e=document.createElement(`canvas`);return e.width=1,e.height=1,e})(),_=g.getContext(`2d`,{willReadFrequently:!0}),!_)throw Error(`FogOfWar: unable to create 2D context for fog canvas.`);v=n.Texture.from(g);let I=()=>{let e=K(o)===!1?1:2,t=Number(K(s));return Number.isFinite(t)?Nt(Math.round(t),1,8):e},L=()=>{if(K(o)===!1)return 0;let e=Number(K(c));return Number.isFinite(e)?Math.max(0,e):Math.max(k*.9,2)},R=()=>{let e=K(p);return e&&typeof e==`object`?e:void 0},ee=()=>{let e=Lt(l),t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push({x:Number(K(r.x)),y:Number(K(r.y)),radius:Number(K(r.radius)),enabled:K(r.enabled)!==!1})}return t},te=e=>{let t=Array(e.length*4),n=0;for(let r=0;r<e.length;r++){let i=e[r];t[n++]=i.x,t[n++]=i.y,t[n++]=i.radius,t[n++]=+!!i.enabled}let r=t.length!==F.length;if(!r)for(let e=0;e<t.length;e++){let n=t[e],i=F[e];if(Number.isNaN(n)!==Number.isNaN(i)||Math.abs(n-i)>.01){r=!0;break}}return F=t,r},ne=(e,t)=>{if(!Number.isFinite(e)||!Number.isFinite(t)||T<=0||C<=0||w<=0)return At;let n=Nt(e,0,Math.max(0,E-1)),r=Nt(t,0,Math.max(0,D-1)),i=Math.min(C-1,Math.max(0,Math.floor(n/k))),a=Math.min(w-1,Math.max(0,Math.floor(r/k)))*C+i;return{clarity:Nt(x[a]??0,0,1),explored:S[a]===1}},re=e=>{let t=R()??null;t!==N&&(P&&P.setSampler(jt),N=t,P=N?Mt.get(N)??null:null,P&&P.setSampler(ne),e=!0),e&&P&&P.notifyUpdate()},ie=()=>{let e=v.source;e&&(e.scaleMode=K(o)===!1?`nearest`:`linear`)},z=(e,t,n,r)=>{E=Math.max(1,Math.floor(e)),D=Math.max(1,Math.floor(t)),O=Math.max(1,Math.floor(n)),A=Nt(r,1,8),k=Math.max(1,O/A),C=Math.max(1,Math.ceil(E/k)),w=Math.max(1,Math.ceil(D/k)),T=C*w,`width`in g&&(g.width=C,g.height=w),x=new Float32Array(T),S=new Uint8Array(T),K(f)&&S.fill(1),y=_?.createImageData(C,w)??null,b=y?.data??null,ie(),M=!0},B=(e,t)=>{if(e.enabled===!1||!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.radius)||e.radius<=0)return;let n=e.x,r=e.y,i=e.radius/k,a=Math.max(0,i-t),o=Math.max(i,i+t),s=a*a,c=o*o,l=Math.max(0,Math.floor(n/k-o)),u=Math.min(C-1,Math.ceil(n/k+o)),d=Math.max(0,Math.floor(r/k-o)),f=Math.min(w-1,Math.ceil(r/k+o));for(let e=d;e<=f;e++)for(let t=l;t<=u;t++){let i=(t+.5)*k,l=(e+.5)*k,u=i-n,d=l-r,f=(u*u+d*d)/(k*k);if(f>c)continue;let p=1;if(o>a&&f>s&&(p=1-Pt(a,o,Math.sqrt(f))),p<=.001)continue;let m=e*C+t;p>x[m]&&(x[m]=p),p>.02&&(S[m]=1)}},ae=e=>{if(!y||!b||!_)return;let t=K(u)||{},n=It(t.unknown,Ot),r=It(t.explored,kt);x.fill(0);let i=e??ee(),a=L()/k;for(let e=0;e<i.length;e++)B(i[e],a);for(let e=0;e<T;e++){let t=e*4,i=Nt(x[e],0,1),a=S[e]===1?r:n;b[t]=a.r,b[t+1]=a.g,b[t+2]=a.b,b[t+3]=Math.round(a.a*(1-i))}_.putImageData(y,0,0);let o=v.source;o&&typeof o.update==`function`?o.update():typeof v.update==`function`&&v.update(),re(!0)};return z(Number(K(r))||1,Number(K(i))||1,Number(K(a))||32,I()),ae(),(0,t.tick)(({deltaTime:e})=>{if(!_)return;let t=Math.max(1,Number(K(r))||1),n=Math.max(1,Number(K(i))||1),o=Math.max(1,Number(K(a))||32),s=I();(t!==E||n!==D||o!==O||s!==A)&&z(t,n,o,s),ie(),re(!1);let c=ee(),l=te(c);l&&(M=!0);let u=1e3/Math.max(1,Number(K(d))||15);j+=e,(M||l||j>=u)&&(j=0,M=!1,ae(c))}),(0,t.h)(t.Sprite,{...h,texture:v,x:0,y:0,width:Math.max(1,Number(K(r))||1),height:Math.max(1,Number(K(i))||1),roundPixels:!0})}var zt=`/**
652
652
  * Gradient alpha for projected sprite shadows.
653
653
  * Strong alpha near the caster's feet (vTextureCoord.y ~ 1),
654
654
  * softer alpha at the shadow tip (vTextureCoord.y ~ 0).
@@ -669,5 +669,5 @@ void main() {
669
669
  float alphaMul = mix(clamp(uFloor, 0.0, 1.0), 1.0, gradient);
670
670
  finalColor = vec4(color.rgb, color.a * alphaMul);
671
671
  }
672
- `,le="__spriteShadowManaged",Di=220,fn=360,dn=1,pn="strongest",mn=30,yn=0,Vt={height:72,footOffset:{x:0,y:0},footAnchor:{x:.5,y:1},alpha:.56,blur:3.5,gradientPower:2,hardness:.42,minLength:10,maxLength:280,contactAlpha:.28,contactScale:.28},gt=(n,t,e)=>Math.max(t,Math.min(e,n)),nt=n=>typeof n=="number"&&Number.isFinite(n),_t=n=>{if(n&&typeof n=="object"&&"value"in n&&Object.keys(n).length<=2)return n.value;if(typeof n=="function")try{return n()}catch{return}return n},gn=n=>{if(typeof n=="number"&&Number.isFinite(n))return Math.max(0,Math.floor(n))&16777215;if(typeof n=="string"){const t=n.trim().replace(/^#/,""),e=t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:t,i=parseInt(e,16);if(Number.isFinite(i))return i&16777215}return yn},Oi=(n,t)=>{const e=_t(n),i=Number(e?.x),r=Number(e?.y);return{x:nt(i)?i:t.x,y:nt(r)?r:t.y}},Ri=(n,t)=>{if(n&&typeof n.toGlobal=="function"){const e=n.toGlobal(t);if(nt(e?.x)&&nt(e?.y))return{x:e.x,y:e.y}}return t},Pi=(n,t)=>{if(n&&typeof n.toLocal=="function"){const e=n.toLocal(t);if(nt(e?.x)&&nt(e?.y))return{x:e.x,y:e.y}}return t},Ui=(n=2,t=.06)=>{const e={value:n,type:"f32"},i={value:t,type:"f32"},r=L.Filter.from({gl:{vertex:ti,fragment:hn},resources:{shadowGradientUniforms:{uPower:e,uFloor:i}}});return r.setGradient=(l,c)=>{e.value=nt(l)?Math.max(.001,l):2,i.value=nt(c)?gt(c,0,1):.06},r},_n=n=>{if(n===!1||n===null||n===void 0)return null;const t=n===!0||typeof n!="object"?{}:n;if(_t(t.enabled)===!1)return null;const i=Number(_t(t.height)),r=Number(_t(t.alpha)),l=Number(_t(t.blur)),c=Number(_t(t.gradientPower)),a=Number(_t(t.hardness)),g=Number(_t(t.minLength)),S=Number(_t(t.maxLength)),w=Number(_t(t.contactAlpha)),C=Number(_t(t.contactScale)),M=Number(_t(t.anchorX));return{height:nt(i)?Math.max(2,i):Vt.height,footOffset:Oi(t.footOffset,Vt.footOffset),footAnchor:Oi(t.footAnchor,Vt.footAnchor),alpha:nt(r)?gt(r,0,1.5):Vt.alpha,blur:nt(l)?Math.max(0,l):Vt.blur,gradientPower:nt(c)?gt(c,.2,8):Vt.gradientPower,hardness:nt(a)?gt(a,0,1):Vt.hardness,minLength:nt(g)?Math.max(0,g):Vt.minLength,maxLength:nt(S)?Math.max(2,S):Vt.maxLength,contactAlpha:nt(w)?gt(w,0,1):Vt.contactAlpha,contactScale:nt(C)?Math.max(.05,C):Vt.contactScale,anchorX:nt(M)?gt(M,0,1):void 0}},xn=n=>{if(!n||n[le])return null;const t=typeof n.getElement=="function"?n.getElement():null,e=_t(n.shadowCaster)??_t(n.fullProps?.shadowCaster)??_t(t?.props?.shadowCaster)??_t(t?.propObservables?.shadowCaster);return e===void 0?null:_n(e)},wn=n=>{const t=[],e=[n];for(;e.length>0;){const i=e.pop(),r=Array.isArray(i?.children)?i.children:[];for(let l=0;l<r.length;l++){const c=r[l];if(!c||c[le])continue;const a=xn(c);a&&c.parent&&t.push({instance:c,caster:a}),Array.isArray(c.children)&&c.children.length>0&&e.push(c)}}return t},En=(n,t)=>{const e=_t(n);if(!Array.isArray(e))return[];const i=[];for(let r=0;r<e.length;r++){const l=e[r];if(_t(l.enabled)===!1)continue;const a=Number(_t(l.x)),g=Number(_t(l.y));if(!nt(a)||!nt(g))continue;const S=Number(_t(l.z)),w=Number(_t(l.radius)),C=Number(_t(l.intensity)),M=Number(_t(l.shadowWeight)),N=Ri(t,{x:a,y:g});i.push({x:a,y:g,globalX:N.x,globalY:N.y,z:nt(S)?Math.max(2,S):Di,radius:nt(w)?Math.max(1,w):fn,intensity:nt(C)?gt(C,0,2):dn,shadowWeight:nt(M)?gt(M,0,4):1})}return i},vn=(n,t)=>{if(n.length===0)return null;if(n.sort((g,S)=>S.influence-g.influence),t==="strongest"||n.length===1)return n[0];const e=n.slice(0,2);let i=0,r=0,l=0,c=0;for(let g=0;g<e.length;g++){const S=e[g],w=Math.max(.001,S.influence);i+=S.dirX*w,r+=S.dirY*w,l+=S.length*w,c+=w}if(c<=0)return null;const a=Math.hypot(i,r);return a<=1e-4?null:{dirX:i/a,dirY:r/a,length:l/c,influence:gt(c/e.length,0,2)}},ce=n=>{n.near.visible=!1,n.far.visible=!1,n.contact.visible=!1},Ke=n=>{n.near.destroy(),n.far.destroy(),n.contact.destroy()},bn=(n,t,e)=>{const i=new L.Sprite,r=new L.Sprite,l=new L.Sprite,c=new L.BlurFilter({strength:2.5,quality:2}),a=new L.BlurFilter({strength:4.2,quality:3}),g=new L.BlurFilter({strength:2.8,quality:2}),S=Ui(2,.08),w=Ui(2.8,.02);return i.filters=[S,c],r.filters=[w,a],l.filters=[g],i.tint=e,r.tint=e,l.tint=e,i.blendMode="multiply",r.blendMode="multiply",l.blendMode="multiply",i.eventMode="none",r.eventMode="none",l.eventMode="none",i.roundPixels=!0,r.roundPixels=!0,l.roundPixels=!0,i.visible=!1,r.visible=!1,l.visible=!1,i.alpha=0,r.alpha=0,i[le]=!0,r[le]=!0,l[le]=!0,t.addChild(l),t.addChild(r),t.addChild(i),{caster:n,parent:t,near:i,far:r,contact:l,nearBlur:c,farBlur:a,contactBlur:g,nearGradient:S,farGradient:w,dirX:0,dirY:1,length:0}},Sn=n=>{const{caster:t,parent:e,near:i,far:r,contact:l}=n;if(!t||t.destroyed||!e)return;const c=nt(t.zIndex)?t.zIndex:0;if(l.zIndex=c-.32,r.zIndex=c-.26,i.zIndex=c-.22,e.sortableChildren||!Array.isArray(e.children)||!e.children.includes(t))return;const a=g=>{if(!g||g.destroyed||!e.children.includes(g))return;const S=e.getChildIndex(t),w=Math.max(0,S-1);e.getChildIndex(g)!==w&&e.setChildIndex(g,w)};a(l),a(r),a(i)},An=(n,t,e,i,r)=>{const l=n.caster,c=n.parent;if(!l||l.destroyed||!c||c.destroyed){ce(n);return}if(l.visible===!1||nt(l.worldAlpha)&&l.worldAlpha<=.001){ce(n);return}const a=typeof l.getBounds=="function"?l.getBounds():null;if(!(!!a&&nt(a.x)&&nt(a.y)&&nt(a.width)&&nt(a.height)&&a.width>0&&a.height>0)){ce(n);return}const S=Math.max(1,Math.abs(Number(l.width))||Math.abs(a.width)),w=Math.max(1,Math.abs(Number(l.height))||Math.abs(a.height)),C=Number(l.anchor?.x),M=Number(l.anchor?.y),N=nt(C)?gt(C,0,1):.5,F=nt(M)?gt(M,0,1):1,k=nt(t.anchorX)?t.anchorX:N,R={x:(t.footAnchor.x-N)*S+t.footOffset.x,y:(t.footAnchor.y-F)*w+t.footOffset.y},m=Ri(l,R),x=Pi(c,m),y=[];for(let Mt=0;Mt<e.length;Mt++){const bt=e[Mt];if(bt.intensity<=.001||bt.radius<=.001)continue;const d=Pi(c,{x:bt.globalX,y:bt.globalY}),u=x.x-d.x,B=x.y-d.y,E=Math.hypot(u,B),J=gt(1-E/bt.radius,0,1),ut=gt(Di/Math.max(12,bt.z),.35,2.4),rt=gt(J*J*bt.intensity*bt.shadowWeight*ut,0,2.2);if(rt<=.001)continue;const G=E>1e-4?E:1,X=u/G,tt=B/G,q=gt(E*t.height/Math.max(14,bt.z),t.minLength,t.maxLength);y.push({dirX:nt(X)?X:0,dirY:nt(tt)?tt:1,influence:rt,length:nt(q)?q:t.minLength})}const f=vn(y,i);if(!f){ce(n);return}const A=l.texture;if(!A){ce(n);return}const P=.34,I=.32,O=n.dirX+(f.dirX-n.dirX)*P,_=n.dirY+(f.dirY-n.dirY)*P,U=Math.hypot(O,_),V=U>1e-4?O/U:f.dirX,z=U>1e-4?_/U:f.dirY,K=n.length+(f.length-n.length)*I;n.dirX=V,n.dirY=z,n.length=K;const et=gt(K/w,.08,6),Q=gt(.62+et*.08,.5,1.2),W=gt(t.hardness,0,1),Y=gt(f.influence,0,1.35),Z=gt(t.alpha*Y,0,1),yt=Math.max(0,t.blur*(1.15-W*.55)),ct=gt(t.gradientPower+(1-W)*.7,.2,8),H=Math.atan2(z,V)+Math.PI/2;n.near.texture=A,n.far.texture=A,n.contact.texture=A,n.near.tint=r,n.far.tint=r,n.contact.tint=r,n.near.anchor.set(k,1),n.far.anchor.set(k,1),n.contact.anchor.set(k,1),n.near.width=S*Q,n.near.height=w*Math.max(.12,et*1.06),n.far.width=n.near.width*1.02,n.far.height=n.near.height*1.22,n.near.position.set(x.x,x.y),n.far.position.set(x.x+V*K*.34,x.y+z*K*.34),n.contact.position.set(x.x+V*Math.min(4,K*.06),x.y+z*Math.min(4,K*.06)),n.near.rotation=H,n.far.rotation=H,n.contact.rotation=H,n.near.alpha=gt(Z*(.74+W*.2),0,1),n.far.alpha=gt(Z*(.3+(1-W)*.2),0,1),n.near.visible=n.near.alpha>.001,n.far.visible=n.far.alpha>.001,n.nearBlur.strength=yt*(.72+(1-Y)*.45),n.farBlur.strength=yt*(1.45+(1-Y)*1.1),n.nearGradient.setGradient(ct,.08),n.farGradient.setGradient(ct+.65,.03);const it=gt(t.contactAlpha*Y*.85,0,1),vt=Math.max(4,S*gt(t.contactScale*1.8,.25,1.3)),j=Math.max(2,w*gt(t.contactScale*.62,.08,.56));n.contact.width=vt*(.92+et*.18),n.contact.height=j,n.contact.alpha=gt(it*(.6+W*.2),0,1),n.contactBlur.strength=yt*(.85+(1-W)*.25),n.contact.visible=n.contact.alpha>.001,Sn(n)};function Tn(n={}){const t=D.useProps(n),e=()=>t.lights??t.sources;return D.mount(i=>{const r=i.props.context,c=r?.viewport??i.parent?.componentInstance;if(!c||typeof c.addChild!="function")return;const a=r?.tick,g=new Map;let S=0,w=!0,C=null;const M=()=>{const N=gn(_t(t.shadowColor)),k=_t(t.mode)==="blend2"?"blend2":pn,R=En(e(),c),m=wn(c),x=new Set;for(let y=0;y<m.length;y++){const{instance:f,caster:A}=m[y];if(!f||!f.parent||f.destroyed)continue;x.add(f);let P=g.get(f);(!P||P.parent!==f.parent)&&(P&&Ke(P),P=bn(f,f.parent,N),g.set(f,P)),An(P,A,R,k,N)}for(const[y,f]of g.entries())(!x.has(y)||!y||y.destroyed)&&(Ke(f),g.delete(y))};return C=a?.observable?.subscribe(N=>{const F=N?.value??N,k=Number(F?.deltaTime),R=nt(k)?k:16.67,m=Number(_t(t.updateHz)),y=1e3/gt(nt(m)?m:mn,1,120);S+=R,(w||S>=y)&&(S=0,w=!1,M())}),M(),()=>{C?.unsubscribe?.();for(const N of g.values())Ke(N);g.clear()}}),D.h(D.Container)}const qe="__footprintManaged",ge="default",Mn=30,Cn=260,Yt={footAnchor:{x:.5,y:1},leftOffset:{x:-10,y:1},rightOffset:{x:10,y:1},minStepDistance:18,minSpeed:36,stepIntervalMs:85,size:1,alpha:1,blur:0,angleOffset:0,jitter:8},Ut={lifetimeMs:1800,startAlpha:.32,endAlpha:0,tint:2959910,blendMode:"multiply",scale:1,blurStart:.45,blurEnd:1.9,erosionStart:.54,depth:.58,rimStrength:.14},Fn={[ge]:Ut,sand:{lifetimeMs:1650,startAlpha:.31,endAlpha:0,tint:9334086,blendMode:"multiply",scale:1,blurStart:.35,blurEnd:1.5,erosionStart:.62,depth:.54,rimStrength:.12},snow:{lifetimeMs:2550,startAlpha:.24,endAlpha:0,tint:8228771,blendMode:"multiply",scale:1.05,blurStart:.6,blurEnd:2.25,erosionStart:.45,depth:.72,rimStrength:.28}},At=(n,t,e)=>Math.max(t,Math.min(e,n)),_e=(n,t,e)=>n+(t-n)*e,ki=(n,t,e)=>{const i=At((e-n)/Math.max(1e-4,t-n),0,1);return i*i*(3-2*i)},mt=n=>typeof n=="number"&&Number.isFinite(n),Bn=n=>n==="left"?"right":"left",Li=n=>n*Math.PI/180,pt=n=>{if(n&&typeof n=="object"&&"value"in n&&Object.keys(n).length<=2)return n.value;if(typeof n=="function")try{return n()}catch{return}return n},Nn=(n,t)=>{if(typeof n=="number"&&Number.isFinite(n))return Math.max(0,Math.floor(n))&16777215;if(typeof n=="string"){const e=n.trim().replace(/^#/,""),i=e.length===3?`${e[0]}${e[0]}${e[1]}${e[1]}${e[2]}${e[2]}`:e,r=parseInt(i,16);if(Number.isFinite(r))return r&16777215}return t},In=(n,t)=>{const e=At(t,0,1),i=Math.round((n>>16&255)*(1-e)),r=Math.round((n>>8&255)*(1-e)),l=Math.round((n&255)*(1-e));return i<<16|r<<8|l},Dn=(n,t)=>{const e=At(t,0,1),i=Math.round((n>>16&255)+(255-(n>>16&255))*e),r=Math.round((n>>8&255)+(255-(n>>8&255))*e),l=Math.round((n&255)+(255-(n&255))*e);return i<<16|r<<8|l},We=(n,t)=>{const e=pt(n),i=Number(e?.x),r=Number(e?.y);return{x:mt(i)?i:t.x,y:mt(r)?r:t.y}},On=(n,t)=>{if(n&&typeof n.toGlobal=="function"){const e=n.toGlobal(t);if(mt(e?.x)&&mt(e?.y))return{x:e.x,y:e.y}}return t},Rn=(n,t)=>{if(n&&typeof n.toLocal=="function"){const e=n.toLocal(t);if(mt(e?.x)&&mt(e?.y))return{x:e.x,y:e.y}}return t},Vi=(n,t)=>{const e=Number(pt(n?.lifetimeMs)),i=Number(pt(n?.startAlpha)),r=Number(pt(n?.endAlpha)),l=Number(pt(n?.scale)),c=Number(pt(n?.blurStart)),a=Number(pt(n?.blurEnd)),g=Number(pt(n?.erosionStart)),S=Number(pt(n?.depth)),w=Number(pt(n?.rimStrength)),C=pt(n?.tint),M=pt(n?.blendMode);return{lifetimeMs:mt(e)?Math.max(120,e):t.lifetimeMs,startAlpha:mt(i)?At(i,0,1.5):t.startAlpha,endAlpha:mt(r)?At(r,0,1.5):t.endAlpha,tint:Nn(C,t.tint),blendMode:M??t.blendMode,scale:mt(l)?Math.max(.05,l):t.scale,blurStart:mt(c)?Math.max(0,c):t.blurStart,blurEnd:mt(a)?Math.max(0,a):t.blurEnd,erosionStart:mt(g)?At(g,.05,.95):t.erosionStart,depth:mt(S)?At(S,0,1):t.depth,rimStrength:mt(w)?At(w,0,1):t.rimStrength}},Pn=n=>{const t=pt(n)??{},e={};for(const[i,r]of Object.entries(Fn))e[i]=Vi(t[i],r);for(const[i,r]of Object.entries(t))e[i]||(e[i]=Vi(r,Ut));return e[ge]||(e[ge]=Ut),e},Un=(n,t)=>{if(n===!1||n===null||n===void 0)return null;const e=n===!0||typeof n!="object"?{}:n;if(pt(e.enabled)===!1)return null;const r=Number(pt(e.minStepDistance)),l=Number(pt(e.minSpeed)),c=Number(pt(e.stepIntervalMs)),a=Number(pt(e.size)),g=Number(pt(e.alpha)),S=Number(pt(e.blur)),w=Number(pt(e.angleOffset)),C=Number(pt(e.jitter)),M=pt(e.surface);return{footAnchor:We(e.footAnchor,Yt.footAnchor),leftOffset:We(e.leftOffset,Yt.leftOffset),rightOffset:We(e.rightOffset,Yt.rightOffset),minStepDistance:mt(r)?Math.max(2,r):Yt.minStepDistance,minSpeed:mt(l)?Math.max(0,l):Yt.minSpeed,stepIntervalMs:mt(c)?Math.max(0,c):Yt.stepIntervalMs,size:mt(a)?Math.max(.1,a):Yt.size,alpha:mt(g)?At(g,0,2):Yt.alpha,blur:mt(S)?Math.max(0,S):Yt.blur,surface:typeof M=="string"&&M.trim().length>0?M.trim():t,angleOffset:mt(w)?w:Yt.angleOffset,jitter:mt(C)?Math.max(0,C):Yt.jitter}},kn=(n,t)=>{if(!n||n[qe])return null;const e=typeof n.getElement=="function"?n.getElement():null,i=pt(n.footprintCaster)??pt(n.fullProps?.footprintCaster)??pt(e?.props?.footprintCaster)??pt(e?.propObservables?.footprintCaster);return i===void 0?null:Un(i,t)},Ln=(n,t)=>{const e=[],i=[n];for(;i.length>0;){const r=i.pop(),l=Array.isArray(r?.children)?r.children:[];for(let c=0;c<l.length;c++){const a=l[c];if(!a||a[qe])continue;const g=kn(a,t);g&&a.parent&&e.push({instance:a,caster:g}),Array.isArray(a.children)&&a.children.length>0&&i.push(a)}}return e},Vn=n=>{const t=n?.app;if(typeof t=="function")try{const i=t();if(i?.renderer&&typeof i.renderer.generateTexture=="function")return i.renderer}catch{}const e=globalThis.__PIXI_RENDERER__;return e&&typeof e.generateTexture=="function"?e:null},Yn=n=>{const t=new L.Graphics;t.ellipse(0,10,8.4,6.1).fill(16777215),t.ellipse(0,-1.4,6.8,9.4).fill(16777215),t.circle(-4.7,-12.8,2).fill(16777215),t.circle(-1.5,-14.6,1.9).fill(16777215),t.circle(1.5,-15.3,1.75).fill(16777215),t.circle(4.5,-14.1,1.45).fill(16777215);const e=n.generateTexture(t);return t.destroy(),e},Yi=(n,t,e)=>{const i=typeof n.getBounds=="function"?n.getBounds():null,r=Math.max(1,Math.abs(Number(n.width))||Math.abs(Number(i?.width))||1),l=Math.max(1,Math.abs(Number(n.height))||Math.abs(Number(i?.height))||1),c=Number(n.anchor?.x),a=Number(n.anchor?.y),g=mt(c)?At(c,0,1):.5,S=mt(a)?At(a,0,1):1,w={x:(e.footAnchor.x-g)*r,y:(e.footAnchor.y-S)*l},C=On(n,w);return Rn(t,C)},zn=(n,t,e)=>{const i=mt(t?.zIndex)?t.zIndex:0;if(n.rimSprite.zIndex=i-.2,n.baseSprite.zIndex=i-.18,n.depthSprite.zIndex=i-.16,e.sortableChildren||!Array.isArray(e.children)||!e.children.includes(t))return;const r=[n.rimSprite,n.baseSprite,n.depthSprite];for(let l=0;l<r.length;l++){const c=r[l];if(!e.children.includes(c))continue;const a=e.getChildIndex(t),g=Math.max(0,a-1);e.getChildIndex(c)!==g&&e.setChildIndex(c,g)}};function Gn(n={}){const t=D.useProps(n);return D.mount(e=>{const i=e.props.context,l=i?.viewport??e.parent?.componentInstance;if(!l||typeof l.addChild!="function")return;const c=i?.tick,a=new Map,g=[],S=[];let w=0,C=0,M=!0,N=null,F=null;const k=()=>{if(F&&!F.destroyed)return F;const I=Vn(i);return I?(F=Yn(I),F):null},R=I=>{const O=[I.baseSprite,I.depthSprite,I.rimSprite];for(let _=0;_<O.length;_++){const U=O[_];U.visible=!1,U.alpha=0,U.parent&&U.parent.removeChild(U)}S.push(I)},m=I=>{const O=[I.baseSprite,I.depthSprite,I.rimSprite];for(let _=0;_<O.length;_++){const U=O[_];U.parent&&U.parent.removeChild(U),U.destroy()}},x=I=>{let O=S.pop();if(O)O.baseSprite.texture=I,O.depthSprite.texture=I,O.rimSprite.texture=I;else{const _=new L.Sprite(I),U=new L.Sprite(I),V=new L.Sprite(I),z=new L.BlurFilter({strength:0,quality:1}),K=new L.BlurFilter({strength:0,quality:1}),et=new L.BlurFilter({strength:0,quality:1}),Q=[_,U,V];for(let W=0;W<Q.length;W++){const Y=Q[W];Y.anchor.set(.5,.84),Y.roundPixels=!0,Y.eventMode="none",Y.visible=!1,Y[qe]=!0}_.filters=[z],U.filters=[K],V.filters=[et],U.blendMode="multiply",V.blendMode="screen",O={baseSprite:_,depthSprite:U,rimSprite:V,baseBlurFilter:z,depthBlurFilter:K,rimBlurFilter:et,bornAt:0,lifetimeMs:Ut.lifetimeMs,startAlpha:Ut.startAlpha,endAlpha:Ut.endAlpha,baseScaleX:1,baseScaleY:1,blurStart:Ut.blurStart,blurEnd:Ut.blurEnd,erosionStart:Ut.erosionStart,depth:Ut.depth,rimStrength:Ut.rimStrength}}return O},y=I=>{for(;g.length>I;){const O=g.shift();if(!O)break;R(O)}},f=I=>{for(let O=g.length-1;O>=0;O--){const _=g[O],U=_.baseSprite,V=_.depthSprite,z=_.rimSprite;if(!U||!V||!z||U.destroyed||V.destroyed||z.destroyed){g.splice(O,1);continue}const K=At((I-_.bornAt)/Math.max(1,_.lifetimeMs),0,1),et=1-ki(0,1,K),Q=K<=_.erosionStart?1:1-ki(_.erosionStart,1,K),W=At(_e(_.startAlpha,_.endAlpha,K)*et*Q,0,1.5);if(K>=1||W<=.001){g.splice(O,1),R(_);continue}const Y=1+K*.08,Z=1+K*.05,yt=1+K*.12,ct=.78-_.depth*.1,H=1.05+_.depth*.12;U.scale.set(_.baseScaleX*Y,_.baseScaleY*Y),V.scale.set(_.baseScaleX*ct*Z,_.baseScaleY*ct*Z),z.scale.set(_.baseScaleX*H*yt,_.baseScaleY*H*yt),U.alpha=W,V.alpha=At(W*(.58+_.depth*.34),0,1.2),z.alpha=At(W*_.rimStrength,0,.65),_.baseBlurFilter.strength=_e(_.blurStart,_.blurEnd,K),_.depthBlurFilter.strength=_e(_.blurStart*(.45+(1-_.depth)*.25),_.blurEnd*(.72+(1-_.depth)*.22),K),_.rimBlurFilter.strength=_e(_.blurStart*.8,_.blurEnd*(1.28+_.depth*.24),K),U.visible=!0,V.visible=!0,z.visible=z.alpha>.001}},A=(I,O,_,U,V,z)=>{const K=k(),et=I.parent;if(!K||!et||et.destroyed)return;const Q=Yi(I,et,O),W=_.nextFoot==="left"?O.leftOffset:O.rightOffset,Y=_.heading,Z=-Math.sin(Y),yt=Math.cos(Y),ct=Math.cos(Y),H=Math.sin(Y),it=Q.x+Z*W.x+ct*W.y,vt=Q.y+yt*W.x+H*W.y,j=x(K),Mt=[j.rimSprite,j.baseSprite,j.depthSprite];for(let tt=0;tt<Mt.length;tt++){const q=Mt[tt];q.parent&&q.parent!==et&&q.parent.removeChild(q),q.parent||et.addChild(q)}const bt=Li(O.jitter),d=(Math.random()*2-1)*bt,u=Li(O.angleOffset),B=Y-Math.PI/2+u+d,E=U.scale*O.size,J=(_.nextFoot==="left"?1:-1)*Math.max(.01,E),ut=Math.max(.01,E),rt=At(U.startAlpha*O.alpha,0,1.5),G=In(U.tint,.38+U.depth*.26),X=Dn(U.tint,.22+U.depth*.38);j.baseSprite.position.set(it,vt),j.depthSprite.position.set(it,vt),j.rimSprite.position.set(it,vt),j.baseSprite.rotation=B,j.depthSprite.rotation=B,j.rimSprite.rotation=B,j.baseSprite.scale.set(J,ut),j.depthSprite.scale.set(J*.82,ut*.82),j.rimSprite.scale.set(J*1.08,ut*1.08),j.baseSprite.tint=U.tint,j.depthSprite.tint=G,j.rimSprite.tint=X,j.baseSprite.blendMode=U.blendMode,j.baseSprite.alpha=rt,j.depthSprite.alpha=At(rt*(.58+U.depth*.34),0,1.2),j.rimSprite.alpha=At(rt*U.rimStrength,0,.65),j.baseSprite.visible=!0,j.depthSprite.visible=!0,j.rimSprite.visible=j.rimSprite.alpha>.001,zn(j,I,et),j.bornAt=V,j.lifetimeMs=U.lifetimeMs,j.startAlpha=rt,j.endAlpha=At(U.endAlpha*O.alpha,0,1.5),j.baseScaleX=J,j.baseScaleY=ut,j.blurStart=Math.max(0,U.blurStart+O.blur),j.blurEnd=Math.max(j.blurStart,U.blurEnd+O.blur),j.depth=U.depth,j.rimStrength=U.rimStrength,j.erosionStart=At(U.erosionStart+(Math.random()*2-1)*.11,.05,.95),j.baseBlurFilter.strength=j.blurStart,j.depthBlurFilter.strength=j.blurStart*(.45+(1-U.depth)*.25),j.rimBlurFilter.strength=j.blurStart*.8,g.push(j),y(z),_.nextFoot=Bn(_.nextFoot),_.lastStepMs=V,_.distanceSinceStep=Math.max(0,_.distanceSinceStep-O.minStepDistance)},P=I=>{const O=pt(t.defaultSurface),_=typeof O=="string"&&O.trim().length>0?O.trim():ge,U=Pn(t.profiles),V=Number(pt(t.maxFootprints)),z=At(mt(V)?V:Cn,10,1200),K=Ln(l,_),et=new Set;for(let Q=0;Q<K.length;Q++){const{instance:W,caster:Y}=K[Q];if(!W||W.destroyed||!W.parent)continue;et.add(W);let Z=a.get(W);Z||(Z={lastPoint:null,lastUpdateMs:I,distanceSinceStep:0,lastStepMs:-1/0,nextFoot:"left",heading:Number(W.rotation)||0},a.set(W,Z));const yt=W.parent,ct=Yi(W,yt,Y);if(!Z.lastPoint){Z.lastPoint=ct,Z.lastUpdateMs=I;continue}const H=Math.max(1,I-Z.lastUpdateMs),it=ct.x-Z.lastPoint.x,vt=ct.y-Z.lastPoint.y,j=Math.hypot(it,vt);j>1e-4&&(Z.heading=Math.atan2(vt,it)),Z.distanceSinceStep+=j;const Mt=j*1e3/H,bt=U[Y.surface]??U[_]??Ut;Mt>=Y.minSpeed&&Z.distanceSinceStep>=Y.minStepDistance&&I-Z.lastStepMs>=Y.stepIntervalMs&&A(W,Y,Z,bt,I,z),Z.lastPoint=ct,Z.lastUpdateMs=I}for(const[Q]of a.entries())(!et.has(Q)||Q?.destroyed)&&a.delete(Q);f(I)};return N=c?.observable?.subscribe(I=>{const O=I?.value??I,_=Number(O?.deltaTime),U=mt(_)?_:16.67;C+=U,w+=U;const V=Number(pt(t.updateHz)),K=1e3/At(mt(V)?V:Mn,1,120);(M||w>=K)&&(w=0,M=!1,P(C))}),P(0),()=>{N?.unsubscribe?.();for(let I=0;I<g.length;I++)m(g[I]);for(let I=0;I<S.length;I++)m(S[I]);g.length=0,S.length=0,a.clear(),F&&!F.destroyed&&F.destroy(!0),F=null}}),D.h(D.Container)}return Ct.Bar=ji,Ct.CLOUD_PRESETS=Fi,Ct.FOG_PRESETS=Ci,Ct.FogOfWar=un,Ct.Footprints=Gn,Ct.Loading=cr,Ct.NightAmbiant=lr,Ct.Particle=Ji,Ct.RAIN_PRESETS=Ti,Ct.SNOW_PRESETS=Mi,Ct.SpriteShadows=Tn,Ct.TiledMap=Qr,Ct.WEATHER_PRESETS=rn,Ct.Weather=nn,Ct.WeatherEffect=Bi,Ct.createFogOfWarController=ln,Ct.createNightFilter=ei,Object.defineProperty(Ct,Symbol.toStringTag,{value:"Module"}),Ct})({},CanvasEngine,PIXI);
673
- //# sourceMappingURL=index.global.js.map
672
+ `,Bt=`__spriteShadowManaged`,Vt=220,Ht=360,Ut=1,Wt=`strongest`,Gt=30,Kt=0,qt={height:72,footOffset:{x:0,y:0},footAnchor:{x:.5,y:1},alpha:.56,blur:3.5,gradientPower:2,hardness:.42,minLength:10,maxLength:280,contactAlpha:.28,contactScale:.28},q=(e,t,n)=>Math.max(t,Math.min(n,e)),J=e=>typeof e==`number`&&Number.isFinite(e),Y=e=>{if(e&&typeof e==`object`&&`value`in e&&Object.keys(e).length<=2)return e.value;if(typeof e==`function`)try{return e()}catch{return}return e},Jt=e=>{if(typeof e==`number`&&Number.isFinite(e))return Math.max(0,Math.floor(e))&16777215;if(typeof e==`string`){let t=e.trim().replace(/^#/,``),n=t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:t,r=parseInt(n,16);if(Number.isFinite(r))return r&16777215}return Kt},Yt=(e,t)=>{let n=Y(e),r=Number(n?.x),i=Number(n?.y);return{x:J(r)?r:t.x,y:J(i)?i:t.y}},Xt=(e,t)=>{if(e&&typeof e.toGlobal==`function`){let n=e.toGlobal(t);if(J(n?.x)&&J(n?.y))return{x:n.x,y:n.y}}return t},Zt=(e,t)=>{if(e&&typeof e.toLocal==`function`){let n=e.toLocal(t);if(J(n?.x)&&J(n?.y))return{x:n.x,y:n.y}}return t},Qt=(e=2,t=.06)=>{let r={value:e,type:`f32`},i={value:t,type:`f32`},a=n.Filter.from({gl:{vertex:O,fragment:zt},resources:{shadowGradientUniforms:{uPower:r,uFloor:i}}});return a.setGradient=(e,t)=>{r.value=J(e)?Math.max(.001,e):2,i.value=J(t)?q(t,0,1):.06},a},$t=e=>{if(e===!1||e==null)return null;let t=e===!0||typeof e!=`object`?{}:e;if(Y(t.enabled)===!1)return null;let n=Number(Y(t.height)),r=Number(Y(t.alpha)),i=Number(Y(t.blur)),a=Number(Y(t.gradientPower)),o=Number(Y(t.hardness)),s=Number(Y(t.minLength)),c=Number(Y(t.maxLength)),l=Number(Y(t.contactAlpha)),u=Number(Y(t.contactScale)),d=Number(Y(t.anchorX));return{height:J(n)?Math.max(2,n):qt.height,footOffset:Yt(t.footOffset,qt.footOffset),footAnchor:Yt(t.footAnchor,qt.footAnchor),alpha:J(r)?q(r,0,1.5):qt.alpha,blur:J(i)?Math.max(0,i):qt.blur,gradientPower:J(a)?q(a,.2,8):qt.gradientPower,hardness:J(o)?q(o,0,1):qt.hardness,minLength:J(s)?Math.max(0,s):qt.minLength,maxLength:J(c)?Math.max(2,c):qt.maxLength,contactAlpha:J(l)?q(l,0,1):qt.contactAlpha,contactScale:J(u)?Math.max(.05,u):qt.contactScale,anchorX:J(d)?q(d,0,1):void 0}},en=e=>{if(!e||e[Bt])return null;let t=typeof e.getElement==`function`?e.getElement():null,n=Y(e.shadowCaster)??Y(e.fullProps?.shadowCaster)??Y(t?.props?.shadowCaster)??Y(t?.propObservables?.shadowCaster);return n===void 0?null:$t(n)},tn=e=>{let t=[],n=[e];for(;n.length>0;){let e=n.pop(),r=Array.isArray(e?.children)?e.children:[];for(let e=0;e<r.length;e++){let i=r[e];if(!i||i[Bt])continue;let a=en(i);a&&i.parent&&t.push({instance:i,caster:a}),Array.isArray(i.children)&&i.children.length>0&&n.push(i)}}return t},nn=(e,t)=>{let n=Y(e);if(!Array.isArray(n))return[];let r=[];for(let e=0;e<n.length;e++){let i=n[e];if(Y(i.enabled)===!1)continue;let a=Number(Y(i.x)),o=Number(Y(i.y));if(!J(a)||!J(o))continue;let s=Number(Y(i.z)),c=Number(Y(i.radius)),l=Number(Y(i.intensity)),u=Number(Y(i.shadowWeight)),d=Xt(t,{x:a,y:o});r.push({x:a,y:o,globalX:d.x,globalY:d.y,z:J(s)?Math.max(2,s):Vt,radius:J(c)?Math.max(1,c):Ht,intensity:J(l)?q(l,0,2):Ut,shadowWeight:J(u)?q(u,0,4):1})}return r},rn=(e,t)=>{if(e.length===0)return null;if(e.sort((e,t)=>t.influence-e.influence),t===`strongest`||e.length===1)return e[0];let n=e.slice(0,2),r=0,i=0,a=0,o=0;for(let e=0;e<n.length;e++){let t=n[e],s=Math.max(.001,t.influence);r+=t.dirX*s,i+=t.dirY*s,a+=t.length*s,o+=s}if(o<=0)return null;let s=Math.hypot(r,i);return s<=1e-4?null:{dirX:r/s,dirY:i/s,length:a/o,influence:q(o/n.length,0,2)}},an=e=>{e.near.visible=!1,e.far.visible=!1,e.contact.visible=!1},on=e=>{e.near.destroy(),e.far.destroy(),e.contact.destroy()},sn=(e,t,r)=>{let i=new n.Sprite,a=new n.Sprite,o=new n.Sprite,s=new n.BlurFilter({strength:2.5,quality:2}),c=new n.BlurFilter({strength:4.2,quality:3}),l=new n.BlurFilter({strength:2.8,quality:2}),u=Qt(2,.08),d=Qt(2.8,.02);return i.filters=[u,s],a.filters=[d,c],o.filters=[l],i.tint=r,a.tint=r,o.tint=r,i.blendMode=`multiply`,a.blendMode=`multiply`,o.blendMode=`multiply`,i.eventMode=`none`,a.eventMode=`none`,o.eventMode=`none`,i.roundPixels=!0,a.roundPixels=!0,o.roundPixels=!0,i.visible=!1,a.visible=!1,o.visible=!1,i.alpha=0,a.alpha=0,i[Bt]=!0,a[Bt]=!0,o[Bt]=!0,t.addChild(o),t.addChild(a),t.addChild(i),{caster:e,parent:t,near:i,far:a,contact:o,nearBlur:s,farBlur:c,contactBlur:l,nearGradient:u,farGradient:d,dirX:0,dirY:1,length:0}},cn=e=>{let{caster:t,parent:n,near:r,far:i,contact:a}=e;if(!t||t.destroyed||!n)return;let o=J(t.zIndex)?t.zIndex:0;if(a.zIndex=o-.32,i.zIndex=o-.26,r.zIndex=o-.22,n.sortableChildren||!Array.isArray(n.children)||!n.children.includes(t))return;let s=e=>{if(!e||e.destroyed||!n.children.includes(e))return;let r=n.getChildIndex(t),i=Math.max(0,r-1);n.getChildIndex(e)!==i&&n.setChildIndex(e,i)};s(a),s(i),s(r)},ln=(e,t,n,r,i)=>{let a=e.caster,o=e.parent;if(!a||a.destroyed||!o||o.destroyed){an(e);return}if(a.visible===!1||J(a.worldAlpha)&&a.worldAlpha<=.001){an(e);return}let s=typeof a.getBounds==`function`?a.getBounds():null;if(!(s&&J(s.x)&&J(s.y)&&J(s.width)&&J(s.height)&&s.width>0&&s.height>0)){an(e);return}let c=Math.max(1,Math.abs(Number(a.width))||Math.abs(s.width)),l=Math.max(1,Math.abs(Number(a.height))||Math.abs(s.height)),u=Number(a.anchor?.x),d=Number(a.anchor?.y),f=J(u)?q(u,0,1):.5,p=J(d)?q(d,0,1):1,m=J(t.anchorX)?t.anchorX:f,h=Zt(o,Xt(a,{x:(t.footAnchor.x-f)*c+t.footOffset.x,y:(t.footAnchor.y-p)*l+t.footOffset.y})),g=[];for(let e=0;e<n.length;e++){let r=n[e];if(r.intensity<=.001||r.radius<=.001)continue;let i=Zt(o,{x:r.globalX,y:r.globalY}),a=h.x-i.x,s=h.y-i.y,c=Math.hypot(a,s),l=q(1-c/r.radius,0,1),u=q(Vt/Math.max(12,r.z),.35,2.4),d=q(l*l*r.intensity*r.shadowWeight*u,0,2.2);if(d<=.001)continue;let f=c>1e-4?c:1,p=a/f,m=s/f,_=q(c*t.height/Math.max(14,r.z),t.minLength,t.maxLength);g.push({dirX:J(p)?p:0,dirY:J(m)?m:1,influence:d,length:J(_)?_:t.minLength})}let _=rn(g,r);if(!_){an(e);return}let v=a.texture;if(!v){an(e);return}let y=.34,b=e.dirX+(_.dirX-e.dirX)*y,x=e.dirY+(_.dirY-e.dirY)*y,S=Math.hypot(b,x),C=S>1e-4?b/S:_.dirX,w=S>1e-4?x/S:_.dirY,T=e.length+(_.length-e.length)*.32;e.dirX=C,e.dirY=w,e.length=T;let E=q(T/l,.08,6),D=q(.62+E*.08,.5,1.2),O=q(t.hardness,0,1),k=q(_.influence,0,1.35),A=q(t.alpha*k,0,1),j=Math.max(0,t.blur*(1.15-O*.55)),M=q(t.gradientPower+(1-O)*.7,.2,8),N=Math.atan2(w,C)+Math.PI/2;e.near.texture=v,e.far.texture=v,e.contact.texture=v,e.near.tint=i,e.far.tint=i,e.contact.tint=i,e.near.anchor.set(m,1),e.far.anchor.set(m,1),e.contact.anchor.set(m,1),e.near.width=c*D,e.near.height=l*Math.max(.12,E*1.06),e.far.width=e.near.width*1.02,e.far.height=e.near.height*1.22,e.near.position.set(h.x,h.y),e.far.position.set(h.x+C*T*.34,h.y+w*T*.34),e.contact.position.set(h.x+C*Math.min(4,T*.06),h.y+w*Math.min(4,T*.06)),e.near.rotation=N,e.far.rotation=N,e.contact.rotation=N,e.near.alpha=q(A*(.74+O*.2),0,1),e.far.alpha=q(A*(.3+(1-O)*.2),0,1),e.near.visible=e.near.alpha>.001,e.far.visible=e.far.alpha>.001,e.nearBlur.strength=j*(.72+(1-k)*.45),e.farBlur.strength=j*(1.45+(1-k)*1.1),e.nearGradient.setGradient(M,.08),e.farGradient.setGradient(M+.65,.03);let P=q(t.contactAlpha*k*.85,0,1),F=Math.max(4,c*q(t.contactScale*1.8,.25,1.3)),I=Math.max(2,l*q(t.contactScale*.62,.08,.56));e.contact.width=F*(.92+E*.18),e.contact.height=I,e.contact.alpha=q(P*(.6+O*.2),0,1),e.contactBlur.strength=j*(.85+(1-O)*.25),e.contact.visible=e.contact.alpha>.001,cn(e)};function un(e={}){let n=(0,t.useProps)(e),r=()=>n.lights??n.sources;return(0,t.mount)(e=>{let t=e.props.context,i=t?.viewport??e.parent?.componentInstance;if(!i||typeof i.addChild!=`function`)return;let a=t?.tick,o=new Map,s=0,c=!0,l=null,u=()=>{let e=Jt(Y(n.shadowColor)),t=Y(n.mode)===`blend2`?`blend2`:Wt,a=nn(r(),i),s=tn(i),c=new Set;for(let n=0;n<s.length;n++){let{instance:r,caster:i}=s[n];if(!r||!r.parent||r.destroyed)continue;c.add(r);let l=o.get(r);(!l||l.parent!==r.parent)&&(l&&on(l),l=sn(r,r.parent,e),o.set(r,l)),ln(l,i,a,t,e)}for(let[e,t]of o.entries())(!c.has(e)||!e||e.destroyed)&&(on(t),o.delete(e))};return l=a?.observable?.subscribe(e=>{let t=e?.value??e,r=Number(t?.deltaTime),i=J(r)?r:16.67,a=Number(Y(n.updateHz)),o=1e3/q(J(a)?a:Gt,1,120);s+=i,(c||s>=o)&&(s=0,c=!1,u())}),u(),()=>{l?.unsubscribe?.();for(let e of o.values())on(e);o.clear()}}),(0,t.h)(t.Container)}var dn=`__footprintManaged`,fn=`default`,pn=30,mn=260,hn={footAnchor:{x:.5,y:1},leftOffset:{x:-10,y:1},rightOffset:{x:10,y:1},minStepDistance:18,minSpeed:36,stepIntervalMs:85,size:1,alpha:1,blur:0,surface:fn,angleOffset:0,jitter:8},X={lifetimeMs:1800,startAlpha:.32,endAlpha:0,tint:2959910,blendMode:`multiply`,scale:1,blurStart:.45,blurEnd:1.9,erosionStart:.54,depth:.58,rimStrength:.14},gn={[fn]:X,sand:{lifetimeMs:1650,startAlpha:.31,endAlpha:0,tint:9334086,blendMode:`multiply`,scale:1,blurStart:.35,blurEnd:1.5,erosionStart:.62,depth:.54,rimStrength:.12},snow:{lifetimeMs:2550,startAlpha:.24,endAlpha:0,tint:8228771,blendMode:`multiply`,scale:1.05,blurStart:.6,blurEnd:2.25,erosionStart:.45,depth:.72,rimStrength:.28}},Z=(e,t,n)=>Math.max(t,Math.min(n,e)),_n=(e,t,n)=>e+(t-e)*n,vn=(e,t,n)=>{let r=Z((n-e)/Math.max(1e-4,t-e),0,1);return r*r*(3-2*r)},Q=e=>typeof e==`number`&&Number.isFinite(e),yn=e=>e===`left`?`right`:`left`,bn=e=>e*Math.PI/180,$=e=>{if(e&&typeof e==`object`&&`value`in e&&Object.keys(e).length<=2)return e.value;if(typeof e==`function`)try{return e()}catch{return}return e},xn=(e,t)=>{if(typeof e==`number`&&Number.isFinite(e))return Math.max(0,Math.floor(e))&16777215;if(typeof e==`string`){let t=e.trim().replace(/^#/,``),n=t.length===3?`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:t,r=parseInt(n,16);if(Number.isFinite(r))return r&16777215}return t},Sn=(e,t)=>{let n=Z(t,0,1),r=Math.round((e>>16&255)*(1-n)),i=Math.round((e>>8&255)*(1-n)),a=Math.round((e&255)*(1-n));return r<<16|i<<8|a},Cn=(e,t)=>{let n=Z(t,0,1),r=Math.round((e>>16&255)+(255-(e>>16&255))*n),i=Math.round((e>>8&255)+(255-(e>>8&255))*n),a=Math.round((e&255)+(255-(e&255))*n);return r<<16|i<<8|a},wn=(e,t)=>{let n=$(e),r=Number(n?.x),i=Number(n?.y);return{x:Q(r)?r:t.x,y:Q(i)?i:t.y}},Tn=(e,t)=>{if(e&&typeof e.toGlobal==`function`){let n=e.toGlobal(t);if(Q(n?.x)&&Q(n?.y))return{x:n.x,y:n.y}}return t},En=(e,t)=>{if(e&&typeof e.toLocal==`function`){let n=e.toLocal(t);if(Q(n?.x)&&Q(n?.y))return{x:n.x,y:n.y}}return t},Dn=(e,t)=>{let n=Number($(e?.lifetimeMs)),r=Number($(e?.startAlpha)),i=Number($(e?.endAlpha)),a=Number($(e?.scale)),o=Number($(e?.blurStart)),s=Number($(e?.blurEnd)),c=Number($(e?.erosionStart)),l=Number($(e?.depth)),u=Number($(e?.rimStrength)),d=$(e?.tint),f=$(e?.blendMode);return{lifetimeMs:Q(n)?Math.max(120,n):t.lifetimeMs,startAlpha:Q(r)?Z(r,0,1.5):t.startAlpha,endAlpha:Q(i)?Z(i,0,1.5):t.endAlpha,tint:xn(d,t.tint),blendMode:f??t.blendMode,scale:Q(a)?Math.max(.05,a):t.scale,blurStart:Q(o)?Math.max(0,o):t.blurStart,blurEnd:Q(s)?Math.max(0,s):t.blurEnd,erosionStart:Q(c)?Z(c,.05,.95):t.erosionStart,depth:Q(l)?Z(l,0,1):t.depth,rimStrength:Q(u)?Z(u,0,1):t.rimStrength}},On=e=>{let t=$(e)??{},n={};for(let[e,r]of Object.entries(gn))n[e]=Dn(t[e],r);for(let[e,r]of Object.entries(t))n[e]||(n[e]=Dn(r,X));return n[fn]||(n[fn]=X),n},kn=(e,t)=>{if(e===!1||e==null)return null;let n=e===!0||typeof e!=`object`?{}:e;if($(n.enabled)===!1)return null;let r=Number($(n.minStepDistance)),i=Number($(n.minSpeed)),a=Number($(n.stepIntervalMs)),o=Number($(n.size)),s=Number($(n.alpha)),c=Number($(n.blur)),l=Number($(n.angleOffset)),u=Number($(n.jitter)),d=$(n.surface);return{footAnchor:wn(n.footAnchor,hn.footAnchor),leftOffset:wn(n.leftOffset,hn.leftOffset),rightOffset:wn(n.rightOffset,hn.rightOffset),minStepDistance:Q(r)?Math.max(2,r):hn.minStepDistance,minSpeed:Q(i)?Math.max(0,i):hn.minSpeed,stepIntervalMs:Q(a)?Math.max(0,a):hn.stepIntervalMs,size:Q(o)?Math.max(.1,o):hn.size,alpha:Q(s)?Z(s,0,2):hn.alpha,blur:Q(c)?Math.max(0,c):hn.blur,surface:typeof d==`string`&&d.trim().length>0?d.trim():t,angleOffset:Q(l)?l:hn.angleOffset,jitter:Q(u)?Math.max(0,u):hn.jitter}},An=(e,t)=>{if(!e||e[dn])return null;let n=typeof e.getElement==`function`?e.getElement():null,r=$(e.footprintCaster)??$(e.fullProps?.footprintCaster)??$(n?.props?.footprintCaster)??$(n?.propObservables?.footprintCaster);return r===void 0?null:kn(r,t)},jn=(e,t)=>{let n=[],r=[e];for(;r.length>0;){let e=r.pop(),i=Array.isArray(e?.children)?e.children:[];for(let e=0;e<i.length;e++){let a=i[e];if(!a||a[dn])continue;let o=An(a,t);o&&a.parent&&n.push({instance:a,caster:o}),Array.isArray(a.children)&&a.children.length>0&&r.push(a)}}return n},Mn=e=>{let t=e?.app;if(typeof t==`function`)try{let e=t();if(e?.renderer&&typeof e.renderer.generateTexture==`function`)return e.renderer}catch{}let n=globalThis.__PIXI_RENDERER__;return n&&typeof n.generateTexture==`function`?n:null},Nn=e=>{let t=new n.Graphics;t.ellipse(0,10,8.4,6.1).fill(16777215),t.ellipse(0,-1.4,6.8,9.4).fill(16777215),t.circle(-4.7,-12.8,2).fill(16777215),t.circle(-1.5,-14.6,1.9).fill(16777215),t.circle(1.5,-15.3,1.75).fill(16777215),t.circle(4.5,-14.1,1.45).fill(16777215);let r=e.generateTexture(t);return t.destroy(),r},Pn=(e,t,n)=>{let r=typeof e.getBounds==`function`?e.getBounds():null,i=Math.max(1,Math.abs(Number(e.width))||Math.abs(Number(r?.width))||1),a=Math.max(1,Math.abs(Number(e.height))||Math.abs(Number(r?.height))||1),o=Number(e.anchor?.x),s=Number(e.anchor?.y),c=Q(o)?Z(o,0,1):.5,l=Q(s)?Z(s,0,1):1;return En(t,Tn(e,{x:(n.footAnchor.x-c)*i,y:(n.footAnchor.y-l)*a}))},Fn=(e,t,n)=>{let r=Q(t?.zIndex)?t.zIndex:0;if(e.rimSprite.zIndex=r-.2,e.baseSprite.zIndex=r-.18,e.depthSprite.zIndex=r-.16,n.sortableChildren||!Array.isArray(n.children)||!n.children.includes(t))return;let i=[e.rimSprite,e.baseSprite,e.depthSprite];for(let e=0;e<i.length;e++){let r=i[e];if(!n.children.includes(r))continue;let a=n.getChildIndex(t),o=Math.max(0,a-1);n.getChildIndex(r)!==o&&n.setChildIndex(r,o)}};function In(e={}){let r=(0,t.useProps)(e);return(0,t.mount)(e=>{let t=e.props.context,i=t?.viewport??e.parent?.componentInstance;if(!i||typeof i.addChild!=`function`)return;let a=t?.tick,o=new Map,s=[],c=[],l=0,u=0,d=!0,f=null,p=null,m=()=>{if(p&&!p.destroyed)return p;let e=Mn(t);return e?(p=Nn(e),p):null},h=e=>{let t=[e.baseSprite,e.depthSprite,e.rimSprite];for(let e=0;e<t.length;e++){let n=t[e];n.visible=!1,n.alpha=0,n.parent&&n.parent.removeChild(n)}c.push(e)},g=e=>{let t=[e.baseSprite,e.depthSprite,e.rimSprite];for(let e=0;e<t.length;e++){let n=t[e];n.parent&&n.parent.removeChild(n),n.destroy()}},_=e=>{let t=c.pop();if(t)t.baseSprite.texture=e,t.depthSprite.texture=e,t.rimSprite.texture=e;else{let r=new n.Sprite(e),i=new n.Sprite(e),a=new n.Sprite(e),o=new n.BlurFilter({strength:0,quality:1}),s=new n.BlurFilter({strength:0,quality:1}),c=new n.BlurFilter({strength:0,quality:1}),l=[r,i,a];for(let e=0;e<l.length;e++){let t=l[e];t.anchor.set(.5,.84),t.roundPixels=!0,t.eventMode=`none`,t.visible=!1,t[dn]=!0}r.filters=[o],i.filters=[s],a.filters=[c],i.blendMode=`multiply`,a.blendMode=`screen`,t={baseSprite:r,depthSprite:i,rimSprite:a,baseBlurFilter:o,depthBlurFilter:s,rimBlurFilter:c,bornAt:0,lifetimeMs:X.lifetimeMs,startAlpha:X.startAlpha,endAlpha:X.endAlpha,baseScaleX:1,baseScaleY:1,blurStart:X.blurStart,blurEnd:X.blurEnd,erosionStart:X.erosionStart,depth:X.depth,rimStrength:X.rimStrength}}return t},v=e=>{for(;s.length>e;){let e=s.shift();if(!e)break;h(e)}},y=e=>{for(let t=s.length-1;t>=0;t--){let n=s[t],r=n.baseSprite,i=n.depthSprite,a=n.rimSprite;if(!r||!i||!a||r.destroyed||i.destroyed||a.destroyed){s.splice(t,1);continue}let o=Z((e-n.bornAt)/Math.max(1,n.lifetimeMs),0,1),c=1-vn(0,1,o),l=o<=n.erosionStart?1:1-vn(n.erosionStart,1,o),u=Z(_n(n.startAlpha,n.endAlpha,o)*c*l,0,1.5);if(o>=1||u<=.001){s.splice(t,1),h(n);continue}let d=1+o*.08,f=1+o*.05,p=1+o*.12,m=.78-n.depth*.1,g=1.05+n.depth*.12;r.scale.set(n.baseScaleX*d,n.baseScaleY*d),i.scale.set(n.baseScaleX*m*f,n.baseScaleY*m*f),a.scale.set(n.baseScaleX*g*p,n.baseScaleY*g*p),r.alpha=u,i.alpha=Z(u*(.58+n.depth*.34),0,1.2),a.alpha=Z(u*n.rimStrength,0,.65),n.baseBlurFilter.strength=_n(n.blurStart,n.blurEnd,o),n.depthBlurFilter.strength=_n(n.blurStart*(.45+(1-n.depth)*.25),n.blurEnd*(.72+(1-n.depth)*.22),o),n.rimBlurFilter.strength=_n(n.blurStart*.8,n.blurEnd*(1.28+n.depth*.24),o),r.visible=!0,i.visible=!0,a.visible=a.alpha>.001}},b=(e,t,n,r,i,a)=>{let o=m(),c=e.parent;if(!o||!c||c.destroyed)return;let l=Pn(e,c,t),u=n.nextFoot===`left`?t.leftOffset:t.rightOffset,d=n.heading,f=-Math.sin(d),p=Math.cos(d),h=Math.cos(d),g=Math.sin(d),y=l.x+f*u.x+h*u.y,b=l.y+p*u.x+g*u.y,x=_(o),S=[x.rimSprite,x.baseSprite,x.depthSprite];for(let e=0;e<S.length;e++){let t=S[e];t.parent&&t.parent!==c&&t.parent.removeChild(t),t.parent||c.addChild(t)}let C=bn(t.jitter),w=(Math.random()*2-1)*C,T=bn(t.angleOffset),E=d-Math.PI/2+T+w,D=r.scale*t.size,O=(n.nextFoot===`left`?1:-1)*Math.max(.01,D),k=Math.max(.01,D),A=Z(r.startAlpha*t.alpha,0,1.5),j=Sn(r.tint,.38+r.depth*.26),M=Cn(r.tint,.22+r.depth*.38);x.baseSprite.position.set(y,b),x.depthSprite.position.set(y,b),x.rimSprite.position.set(y,b),x.baseSprite.rotation=E,x.depthSprite.rotation=E,x.rimSprite.rotation=E,x.baseSprite.scale.set(O,k),x.depthSprite.scale.set(O*.82,k*.82),x.rimSprite.scale.set(O*1.08,k*1.08),x.baseSprite.tint=r.tint,x.depthSprite.tint=j,x.rimSprite.tint=M,x.baseSprite.blendMode=r.blendMode,x.baseSprite.alpha=A,x.depthSprite.alpha=Z(A*(.58+r.depth*.34),0,1.2),x.rimSprite.alpha=Z(A*r.rimStrength,0,.65),x.baseSprite.visible=!0,x.depthSprite.visible=!0,x.rimSprite.visible=x.rimSprite.alpha>.001,Fn(x,e,c),x.bornAt=i,x.lifetimeMs=r.lifetimeMs,x.startAlpha=A,x.endAlpha=Z(r.endAlpha*t.alpha,0,1.5),x.baseScaleX=O,x.baseScaleY=k,x.blurStart=Math.max(0,r.blurStart+t.blur),x.blurEnd=Math.max(x.blurStart,r.blurEnd+t.blur),x.depth=r.depth,x.rimStrength=r.rimStrength,x.erosionStart=Z(r.erosionStart+(Math.random()*2-1)*.11,.05,.95),x.baseBlurFilter.strength=x.blurStart,x.depthBlurFilter.strength=x.blurStart*(.45+(1-r.depth)*.25),x.rimBlurFilter.strength=x.blurStart*.8,s.push(x),v(a),n.nextFoot=yn(n.nextFoot),n.lastStepMs=i,n.distanceSinceStep=Math.max(0,n.distanceSinceStep-t.minStepDistance)},x=e=>{let t=$(r.defaultSurface),n=typeof t==`string`&&t.trim().length>0?t.trim():fn,a=On(r.profiles),s=Number($(r.maxFootprints)),c=Z(Q(s)?s:mn,10,1200),l=jn(i,n),u=new Set;for(let t=0;t<l.length;t++){let{instance:r,caster:i}=l[t];if(!r||r.destroyed||!r.parent)continue;u.add(r);let s=o.get(r);s||(s={lastPoint:null,lastUpdateMs:e,distanceSinceStep:0,lastStepMs:-1/0,nextFoot:`left`,heading:Number(r.rotation)||0},o.set(r,s));let d=r.parent,f=Pn(r,d,i);if(!s.lastPoint){s.lastPoint=f,s.lastUpdateMs=e;continue}let p=Math.max(1,e-s.lastUpdateMs),m=f.x-s.lastPoint.x,h=f.y-s.lastPoint.y,g=Math.hypot(m,h);g>1e-4&&(s.heading=Math.atan2(h,m)),s.distanceSinceStep+=g;let _=g*1e3/p,v=a[i.surface]??a[n]??X;_>=i.minSpeed&&s.distanceSinceStep>=i.minStepDistance&&e-s.lastStepMs>=i.stepIntervalMs&&b(r,i,s,v,e,c),s.lastPoint=f,s.lastUpdateMs=e}for(let[e]of o.entries())(!u.has(e)||e?.destroyed)&&o.delete(e);y(e)};return f=a?.observable?.subscribe(e=>{let t=e?.value??e,n=Number(t?.deltaTime),i=Q(n)?n:16.67;u+=i,l+=i;let a=Number($(r.updateHz)),o=1e3/Z(Q(a)?a:pn,1,120);(d||l>=o)&&(l=0,d=!1,x(u))}),x(0),()=>{f?.unsubscribe?.();for(let e=0;e<s.length;e++)g(s[e]);for(let e=0;e<c.length;e++)g(c[e]);s.length=0,c.length=0,o.clear(),p&&!p.destroyed&&p.destroy(!0),p=null}}),(0,t.h)(t.Container)}return e.Bar=a,e.CLOUD_PRESETS=wt,e.FOG_PRESETS=Ct,e.FX_PRESETS=o,e.FogOfWar=Rt,e.Footprints=In,e.Fx=T,e.FxRuntime=S,e.Loading=ie,e.NightAmbiant=re,e.Particle=E,e.RAIN_PRESETS=xt,e.SNOW_PRESETS=St,e.SpriteShadows=un,e.TiledMap=gt,e.WEATHER_PRESETS=Tt,e.Weather=Dt,e.WeatherEffect=Et,e.createFogOfWarController=Ft,e.createNightFilter=I,e})({},CanvasEngine,PIXI);
673
+ //# sourceMappingURL=index.global.js.map