bard-legends-framework 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -64,4 +64,4 @@
64
64
  highestAlpha = centerColor.a;`,e+=`
65
65
 
66
66
  gl_FragColor = vec4(color, 1.0) * highestAlpha;
67
- }`,e}constructor(t,e){if(super(o.ƀev(),o.ƀed(t*D)),this.ƀdf=t,this.resolution=D,this.ƀdf=t*D,this.ƀdf<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀdf>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀdf)||(this.ƀdf=Math.floor(this.ƀdf));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀdf*this.ƀdf,this.padding=this.ƀdf;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*D),1/(e.height*D)]),t.applyFilter(this,e,i,r);}};var Te=class extends N__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=D;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀdg=new Ee(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Ot(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=N__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀdg.apply(t,e,s,N__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Jt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀey=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbh(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀef(t.texture,s,r.expand,r.color,i),a=new N__namespace.Sprite(n);return this.ƀjx(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀef(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀey.has(n))return o.ƀey.get(n);{let a=this.ƀeg(t,e,i,r);return o.ƀey.set(n,a),a}}else return this.ƀeg(t,e,i,r)}static ƀeg(t,e,i,r){let s=new N__namespace.Sprite(t);this.ƀdi(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=g.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀjx(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdi(t,e){if(t.isSprite){let s=new N__namespace.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbh(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};R.onHardReset.subscribe(()=>{Jt.ƀey.clear();}).attachToRoot();var k=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=g.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.ƀir,i=e.parent;i&&i.removeChild(e);let r=g.instance.renderer.generateTexture(e,{resolution:2,scaleMode:N__namespace.SCALE_MODES.LINEAR,multisample:N__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀlk=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀkq=t,this.pixiSprite=new N__namespace.Sprite(M.getAsset(t.id)),this.ƀir.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgu?.destroy(),this.ƀak?.destroy(),this.ƀkq.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀkq.id),this.ƀis&&M.destroyAsset(this.ƀis.texture.id)),this.ƀis&&!this.ƀis.destroyed&&this.ƀis.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀlk}set textureScale(t){this.ƀlk=t,this.pixiSprite.scale.set(t);}get size(){return new helpersLib.Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀkq.boundingShapes&&!this.ƀir.hitArea&&(this.ƀir.hitArea=new ls(this.ƀkq.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀkq.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===N__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=N__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=N__namespace.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new N__namespace.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀis)return this.ƀis.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀis)this.ƀis.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀkq.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀis&&(this.ƀis.destroy(),this.ƀis=void 0),t&&(this.ƀis=Jt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀkq.destroyAssetOnDestroy),this.ƀis.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀis.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.ƀir.addChild(this.ƀis)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbw().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgu){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgu=this.ƀbw(),this.ƀgu.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgu.pixiSprite.renderable=false,this.ƀgu.displayParent(this);}return this.ƀgu}ƀbw(){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀkq.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=g.instance.renderer.extract.canvas(this.ƀir);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}},ls=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀkg=t.map(r=>new N__namespace.Polygon(r.map(s=>new N__namespace.Point(s.x,s.y))));}contains(t,e){return this.ƀkg.some(i=>i.contains(t,e))}};var Re=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=helpersLib.Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,y=Math.floor(c/p),w=c-p*y;y>=1&&w<i.dashLength&&(w+=p,y--);let A=s.normalize(w/2),Tt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(A)}),l=l.add(A),y>0){let pe=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(y).forEach(()=>{l=l.add(Tt),a.push({from:l,to:l.add(pe)}),l=l.add(pe);});}return l=l.add(Tt),a.push({from:l,to:l.add(A)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcx=new Map;}static createArrow(t,e){let i=new N__namespace.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new N__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:helpersLib.ColorHelper.white,...i},s=new N__namespace.Graphics;return s.lineStyle(r.width,r.color),Re.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new N__namespace.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(helpersLib.ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new N__namespace.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=helpersLib.ColorHelper.white){let i=new N__namespace.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new N__namespace.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new N__namespace.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new N__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new N__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new N__namespace.Graphics,s=new helpersLib.Radian(helpersLib.PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.ƀir.addChild(t),this.pixiGraphics=t,this.ƀan=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀan,cache:false,...t},i=this.ƀes(e.cacheName,e.cache),r={id:i.textureID,scale:1,size:i.bounds,anchor:{x:0,y:0},destroyAssetOnDestroy:!e.cache},s=new k(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀes(t,e){if(e){let i=o.ƀcx.get(t);return i||(i=this.ƀci(),o.ƀcx.set(t,i)),i}else return this.ƀci()}ƀci(){let t=g.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {textureID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var si=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},xt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcx=new Map;}constructor(t,e,i,r=exports.ScrollDirection.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===exports.ScrollDirection.Horizontal?this.ƀcc(e,i,s):this.ƀcj(e,i,s),this.ƀgu=k.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgu);}ƀcj(t,e,i){e>0&&this.ƀbz(new helpersLib.Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x,t.y-e*2),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀcc(t,e,i){e>0&&this.ƀbz(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(0,t.y),{round:false}).setRotation(helpersLib.Radian.get270).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x-e*2,t.y),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbz(t){let i={id:this.ƀca(t.y),scale:1,size:t,anchor:{x:0,y:0}};return new k(i,{textureSize:t,ignoreAnchor:true})}ƀca(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcx.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new si;helpersLib.ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=N__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcx.set(e,i);}else throw new Error("Canvas context is null")}return i}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var Ie=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}onStateChange(t){return this.ƀhs.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀhu.subscribe(e=>t(e.value,e.index)).attach(this),this}get state(){return {value:this.ƀky.state.value,item:this.ƀfv,nextItem:this.ƀhj,queuedItem:this.ƀky.state.queuedItem,animationState:this.ƀo}}constructor(t){super(),this.ƀo="idle",this.ƀhs=new actionsLib.Action,this.ƀhu=new actionsLib.Action,this.ƀhx={duration:500,animation:x.easeInOutCubic,...t},this.ƀky=new Dt({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((e,i)=>this.ƀfb(e,i)).onValueChange(e=>this.ƀfg(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfv===void 0?(this.ƀfv=t,this.ƀhs.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀky.setItem(t,e)):this.ƀfv!==t?this.ƀhj!==t?this.ƀo==="idle"?(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀhj=t,this.ƀhs.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀhj}),this.ƀky.setItem(t,e)):this.ƀky.setItem(t,e):this.ƀo==="reverting"&&this.ƀhj===t&&(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀky.setItem(t,e)):(this.ƀo==="transitionForward"||this.ƀo==="transitionBackward")&&(this.ƀo="reverting",this.ƀky.setItem(t,e));}ƀfb(t,e){switch(this.ƀfv!==void 0&&this.ƀfv!==t&&this.ƀfv!==e&&this.ƀhs.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhj!==t&&this.ƀhj!==e&&this.ƀhs.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀhj}),e!==void 0&&e!==this.ƀfv&&e!==this.ƀhj&&this.ƀhs.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀo){case "idle":break;case "transitionForward":case "transitionBackward":e===void 0?(this.ƀo="idle",this.ƀfv=this.ƀhj,this.ƀhj=void 0):this.ƀfv!==t&&this.ƀfc(t,e);break;case "reverting":e===void 0?(this.ƀo="idle",this.ƀhj=void 0):this.ƀfv!==e&&this.ƀfc(t,e);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀfc(t,e){this.ƀfv=t,this.ƀhj=e,this.ƀhu.trigger({value:0,index:this.ƀfv}),this.ƀo=this.ƀfv<this.ƀhj?"transitionForward":"transitionBackward";}ƀfg(t){let e=1;(this.ƀo==="transitionBackward"||this.ƀo==="reverting"&&this.ƀfv!==void 0&&this.ƀhj!==void 0&&this.ƀfv>this.ƀhj)&&(e=-1),(this.ƀo==="idle"||t!==0)&&this.ƀhu.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhu.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀhj});}};exports.ScrollDirection=void 0;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(exports.ScrollDirection||(exports.ScrollDirection={}));var oi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀby=t,this.ƀcs="x",this.ƀbo=new Map,this.ƀhx={duration:300,animation:x.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀhx.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀhx.size.x+this.ƀhx.margin*2,this.ƀhx.size.y):new helpersLib.Vector(this.ƀhx.size.x,this.ƀhx.size.y+this.ƀhx.margin*2),r=new u().setPosition(this.ƀhx.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀhx.margin,0):new helpersLib.Vector(0,-this.ƀhx.margin),{round:false}).displayParent(this).attach(this);this.ƀcd(i,this.ƀhx.margin,this.ƀhx.direction,r),this.ƀcs=this.ƀhx.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀky=new Ie({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbo.set(n,a),this.ƀby({index:n,container:a});}else {let a=this.ƀbo.get(n);a&&(a.destroy(),this.ƀbo.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbo.get(n);if(a){let l={x:0,y:0};l[this.ƀcs]=i[this.ƀcs]*s+this.ƀhx.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀky.setIndex(t,e),this}ƀcd(t,e,i,r){new xt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},Ji=class extends oi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var bt=class{static{h(this,"VectorSet");}constructor(){this.ƀlx=new Map;}add(t){let e=this.ƀlx.get(t.x);e||(e=new Set,this.ƀlx.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀlx.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀlx.get(t.x);return e?e.delete(t.y):false}};var ni=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var G=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new helpersLib.Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new helpersLib.Vector(.5,.5)).multiplyNumber(e)}};var Xt=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new helpersLib.Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=G.areaToGridArea(e,i);if(this.ƀau(t,s))return helpersLib.Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=helpersLib.Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=helpersLib.Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new helpersLib.Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new bt,s=new helpersLib.Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new helpersLib.Rectangle(n,n.add(i));if(this.ƀau(t,a))return helpersLib.Vector.fromTo(e,n);t.getNeighborPositions(n,helpersLib.GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀau(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new helpersLib.Vector(r,i)))return false;return true}};var Yi=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return helpersLib.Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},Rs=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀfa=t,this.ƀkv=e,this.ƀhw=new helpersLib.BinaryHeap("min"),this.ƀba=[],this.ƀhl=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new Yi(this.ƀkv,0,Number.MAX_SAFE_INTEGER);this.ƀhw.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀhw.size>0}getNeighbors(t,e){return this.ƀfa.getNeighborPositions(t.position,e).filter(i=>this.ƀfa.get(i)).map(i=>this.ƀhl.get(i)||this.ƀce(i))}popLowestPathCostNode(){let t=this.ƀhw.pop();return this.ƀhw.delete(t),t.closed=true,this.ƀba.push(t),t}changeNodeCost(t,e,i,r){this.ƀhw.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀhw.add(t.pathLength,t);}getBestClosedNode(){return this.ƀba.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀce(t){let e=new Yi(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀhl.set(t,e),this.ƀhw.add(e.pathLength,e),e}},Kt=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new Rs(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var Zt=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀle=t,this.ƀy=e,this.ƀfj=this.ƀei(this.ƀy.size),this.ƀmg=new helpersLib.Grid({size:this.ƀy.size,defaultValue:this.ƀfj}),this.ƀct=new helpersLib.Grid({size:this.ƀy.size,defaultValue:void 0});let i=new bt,r=new helpersLib.Queue;for(this.ƀdv(this.ƀy.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀmg.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀmg.getOrFail(n);this.ƀen(n,this.ƀy).forEach(l=>{if(!i.has(l.position)){let c=this.ƀmg.getOrFail(l.position),p=a+l.distance;this.ƀy.getOrFail(l.position)&&p<c&&(this.ƀmg.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀle)){if(t=this.ƀmg.movePositionInsideGrid(t),this.ƀct.has(t))return this.ƀct.get(t);{let e=this.ƀen(t,this.ƀy),i;return this.ƀmg.getOrFail(t)>=this.ƀfj?e.some(s=>this.ƀy.get(s.position))&&(e.some(n=>!this.ƀy.get(n.position))?i=this.ƀec(e):i=this.ƀdx(t,e)):i=this.ƀdx(t,e),this.ƀct.set(t,i),i}}}ƀec(t){let e=t.filter(i=>this.ƀy.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdx(t,e){let i=e.filter(r=>this.ƀmg.getOrFail(r.position)<this.ƀfj).reduce((r,s)=>{let n=this.ƀmg.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀfj}).bestDirections;return this.ƀet(i,t)}ƀet(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀgb(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀgb(t,e){let i=t.add(this.ƀly(e));return this.ƀy.isPointWithinBounds(i)&&this.ƀy.getOrFail(i)}ƀen(t,e){return this.ƀmg.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdv(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new helpersLib.Vector(r,i));return e}ƀly(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀei(t){return (t.x+t.y)*20}};var P=class o{static{h(this,"AudioAssets");}static{this.ƀam=new Map;}static{this.context=new AudioContext;}static async load(t){await Promise.all(t.map(e=>fetch(e.url).then(i=>i.arrayBuffer()).then(i=>this.context.decodeAudioData(i)).then(i=>this.ƀam.set(e.id,i))));}static createSource(t){let e=o.ƀdw(t),i=o.context.createBufferSource();return i.buffer=e,i}static ƀdw(t){let e=this.ƀam.get(t);if(!e)throw new Error(`Audio: Sound with id ${t} was not loaded.`);return e}};R.onHardReset.subscribe(()=>{P.context=new AudioContext,P.ƀam.clear();}).attachToRoot();var Y=800,J=class o{static{h(this,"Audio");}static ƀka(){return this.ƀfy=new o,this.ƀfy}constructor(){this.ƀgx=P.context.createGain(),this.ƀgw=P.context.createGain(),this.ƀhi=P.context.createGain(),this.ƀkj=P.context.createGain(),this.ƀgx.connect(P.context.destination),this.ƀgw.connect(this.ƀgx),this.ƀhi.connect(this.ƀgw),this.ƀkj.connect(this.ƀgw),this.ƀgy=new I(this.ƀgx.gain,"value",{duration:500*2,animation:x.easeIn,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀgy.set({value:0});}setVolumes(t){this.ƀgw.gain.value=t.master,this.ƀhi.gain.value=t.music,this.ƀkj.gain.value=t.sound;}appear(t,e="ease"){switch(e){case "ease":return this.ƀgy.set({value:t?0:1}),this.ƀgy.animate({value:t?1:0}).chainToRoot();case "instant":return this.ƀgy.set({value:t?1:0}),actionsLib.SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}};R.onHardReset.subscribe(()=>{J.ƀka();}).attachToRoot();var Ms=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s};exports.CameraGateway=class st extends q(){static{h(this,"CameraGateway");}};exports.CameraGateway=Ms([d()],exports.CameraGateway);var Bs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Pt=class extends q(){static{h(this,"CameraViewGateway");}};Pt=Bs([d()],Pt);var Ki;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Ki||(Ki={}));exports.FocusingAnimation=void 0;(function(o){o[o.Instant=1]="Instant",o[o.EaseInOut=2]="EaseInOut",o[o.EaseOut=3]="EaseOut";})(exports.FocusingAnimation||(exports.FocusingAnimation={}));var hi=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀit=new N__namespace.Graphics,this.ƀit.beginFill(0,1e-9),this.ƀit.drawRect(0,0,t.x,t.y),this.ƀit.endFill(),this.ƀir.addChild(this.ƀit);}destroy(){this.destroyed||(super.destroy(),this.ƀit.destroy());}};var Bt=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:helpersLib.ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:helpersLib.Radian.get60,distance:10,color:helpersLib.ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:helpersLib.ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return helpersLib.JsonHelper.removeUndefinedProperties({fontFamily:e.fontFamily,fill:helpersLib.ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r})}};var Ce=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=scriptEngineLib.RichTextSeparator.process(t,i),s=this.ƀfu(r,e),n=this.ƀs(s);return this.ƀko(n)}static ƀfu(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Bt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀea(a.tags,e,i),p=s(l,c),y=N__namespace.TextMetrics.measureText(" ",new N__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:y.width}})}static ƀea(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbf(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbf(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀko(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀkp(s.text).map(a=>{let l=new N__namespace.TextStyle(s.pixiStyle),c=N__namespace.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀkp(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcm.length===0}get remainingWidth(){return this.ƀmh-this.ƀcp}constructor(t,e){this.ƀmh=t,this.ƀgm=[],this.ƀcm=[],this.ƀcp=0,this.ƀgl=new helpersLib.Vector(0,0),this.ƀcn=0;let i={rectangleCutOption:void 0,horizontalAlignment:"left",verticalAlignment:"bottom",...e};if(this.ƀfm=i.horizontalAlignment,this.ƀlz=i.verticalAlignment,i.rectangleCutOption){if(i.rectangleCutOption.position.x<0||i.rectangleCutOption.position.x>=this.ƀmh||i.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcq={direction:i.rectangleCutOption.direction,rectangle:this.ƀbs(i.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcn,t.y),i=this.ƀej(this.ƀgl.y,this.ƀgl.y+e);return this.ƀcp+t.x<=i}insertWord(t){let e=Math.max(this.ƀcn,t.style.height);if(this.ƀcm.length===0){let i=this.ƀek(this.ƀgl.y,this.ƀgl.y+e);this.ƀgl=new helpersLib.Vector(i,this.ƀgl.y),this.ƀcp=this.ƀgl.x;}this.ƀcm.push({chunk:t,position:new helpersLib.Vector(this.ƀcp,this.ƀgl.y)}),this.ƀcn=e,this.ƀcp+=t.style.width;}newLine(){let t=this.ƀgl.y+this.ƀcn,e=this.ƀek(t,t);this.ƀdn(),this.ƀgl=new helpersLib.Vector(e,t),this.ƀcp=this.ƀgl.x,this.ƀcn=0;}print(){return this.ƀdn(),this.ƀgm}ƀdn(){this.ƀcm.length>0&&(this.ƀgm.push(this.ƀg(this.ƀcm)),this.ƀcm=[]);}ƀg(t){return t=this.ƀmb(t),t=this.ƀfo(t),t}ƀfo(t){if(this.ƀfm==="left")return t;let e=this.ƀgl.y+this.ƀcn,i=this.ƀek(this.ƀgl.y,e),s=this.ƀej(this.ƀgl.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀfm==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new helpersLib.Vector(l.position.x+a,l.position.y)},l))}ƀmb(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀlz){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀlz;throw new Error(`Unexpected case! "${this.ƀlz}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀek(t,e){return this.ƀcq&&(this.ƀcq.direction==="topLeft"||this.ƀcq.direction==="bottomLeft")&&(this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀcq.rectangle.bottomRight.x:0}ƀej(t,e){return this.ƀcq&&(this.ƀcq.direction==="topRight"||this.ƀcq.direction==="bottomRight")&&(this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(this.ƀmh,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(this.ƀmh,e),{includeEdges:false}))?this.ƀcq.rectangle.topLeft.x:this.ƀmh}ƀbs(t){let e,i;switch(t.direction){case "topRight":e=new helpersLib.Vector(t.position.x,-1/0),i=new helpersLib.Vector(1/0,t.position.y);break;case "topLeft":e=new helpersLib.Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new helpersLib.Vector(1/0,1/0);break;case "bottomLeft":e=new helpersLib.Vector(-1/0,t.position.y),i=new helpersLib.Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new helpersLib.Rectangle(e,i)}};var De=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new helpersLib.Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new helpersLib.Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀmi(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀmi(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀmi(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀhc(t),t=this.ƀlp(t),this.ƀaw(t)}static ƀhc(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀlp(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀaw(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ce.process(t,e),r=helpersLib.JsonHelper.removeUndefinedProperties({rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=new Oe(e.default.wordWrapWidth??1/0,r),n=De.wrapText(i,s);return Me.process(n)}};var js=1,Qi=1/js,Qt=class extends u{static{h(this,"Text");}get ƀli(){if(!this.ƀlj){let t=new N__namespace.TextStyle(this.ƀiv);this.ƀlj=N__namespace.TextMetrics.measureText(this.ƀlh,t);}return this.ƀlj}get ascent(){return this.ƀli.fontProperties.ascent}constructor(t,e){super(),this.ƀiv=Bt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀiu.destroyed&&this.ƀiu.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀiu.anchor.x,this.ƀiu.anchor.y)}set anchor(t){this.ƀi=t,this.ƀiu.anchor.set(t.x,t.y);}setText(t){return this.ƀlh!==t&&(this.ƀlh=t,this.ƀjf()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀiv.fill!==e&&(this.ƀiv.fill=e,this.ƀjf()),this}ƀjf(){this.ƀiu?.destroy(),this.ƀlc?.destroy(),this.ƀlc=void 0,this.ƀlj=void 0;let t=new N__namespace.TextStyle(this.ƀiv);this.ƀiu=new N__namespace.Text(this.ƀlh,t),this.ƀji(),this.ƀi&&this.ƀiu.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀiu.scale.set(Qi,Qi),this.ƀir.addChild(this.ƀiu),this.ƀiv.lineThrough&&(this.ƀlc=this.ƀe(this.ƀiu,this.ƀiv.fill),this.ƀir.addChild(this.ƀlc));}ƀji(){let t=N__namespace.TextMetrics.measureText(this.ƀlh,new N__namespace.TextStyle({...this.ƀiv,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀiu.calculateBounds=function(){this.updateText(true),this._bounds.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this._bounds.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=N__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new N__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=N__namespace.TextMetrics.measureText(l,t.style),y=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,w=0;t.style.align==="center"?w=0+(t.width-p.width)*.5:t.style.align==="right"&&(w=0+t.width-p.width),w=Math.floor(w),n.moveTo(Math.floor(w),y),n.lineTo(Math.floor(w+p.width),y),a+=p.lineHeight;}),n.endFill(),n}};var li=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new Qt(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var Us=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},F=class extends gt{static{h(this,"CameraEntity");}constructor(){super(...arguments),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.offset=new actionsLib.Variable(helpersLib.Vector.zero),this.targetPosition=new actionsLib.Variable(void 0),this.focusingNewTargetInfo=new actionsLib.Variable(void 0);}};F=Us([yt()],F);var Ge=class{static{h(this,"PositionConversionHelper");}static includeScaleInScreenPosition(t,e,i){if(e!==1){let r=helpersLib.Vector.fromTo(i,t).multiplyNumber(1/e);return i.add(r)}else return t}};var $s=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Et=class extends mt{static{h(this,"CameraView");}constructor(t){super(),this.ƀdd=t,this.ƀkr=(()=>{let e=new u().attach(this);return e.ƀir=g.instance.ƀiq.stage,e})(),this.ƀjm=new u().setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀae=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀac=new u().displayParent(this.ƀjm).attach(this),this.ƀar=new u().displayParent(this.ƀjm).attach(this),this.ƀdq=new u().setSortableChildren(true).displayParent(this.ƀjm).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdp=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgs=new u().setSortableChildren(true).setZIndex(10).displayParent(this.ƀaq).attach(this),this.ƀab=new u().setZIndex(0).displayParent(this.ƀaq).attach(this),this.ƀh=new I(this.ƀjm,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaf=new I(this.ƀae,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),g.instance.screenSize.subscribe(e=>{this.ƀae.aspectRatio=e.x/e.y,this.ƀae.scale=Math.max(e.x,e.y),this.ƀae.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.zero});}).attach(this),this.ƀdd.position.subscribe(e=>{this.ƀaq.position=this.ƀbt(e);}).attach(this),this.ƀdd.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:0});}screenPositonToStagePosition(t){let e=Ge.includeScaleInScreenPosition(t,this.ƀkr.scale,g.instance.screenSizeCenter.value);return new helpersLib.Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgs.id,foreground:this.ƀdp.id,foregroundScreen:this.ƀdq.id}}appear(t,e,i){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),actionsLib.SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀh.animate({alpha:t?1:0})).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),actionsLib.SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀaf.animate({alpha:t?0:1})).chain(this);case "instant":return this.ƀh.set({alpha:t?1:0}),this.ƀaf.set({alpha:t?0:1}),actionsLib.SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}ƀbt(t){return helpersLib.Vector.fromTo(t,g.instance.screenSizeCenter.value)}};Et=$s([Qe({entity:F}),zs("design:paramtypes",[F])],Et);var Js=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ys=1500,_e=class{static{h(this,"CameraService");}createCamera(){return new F().attachToRoot()}getCameraPosition(){let t=F.getInstanceOrFail();return helpersLib.Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=F.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=F.getInstanceOrFail();e.focusingNewTargetInfo.value={time:g.time,duration:t?.duration??Ys,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??exports.FocusingAnimation.Instant};}update(t,e){let i=F.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀgf(i,r,t):i.position.value=r);}ƀgf(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===exports.FocusingAnimation.Instant)this.ƀbg(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbg(t,e);else {let n;r.focusingAnimation===exports.FocusingAnimation.EaseInOut?n=V.easeInOut(s):r.focusingAnimation===exports.FocusingAnimation.EaseOut?n=V.easeOut(s):n=1;let a=r.position.lerp(e,n);r.roundPosition&&(Math.abs(a.x-r.position.x)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(Math.round(a.x),a.y)),Math.abs(a.y-r.position.y)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(a.x,Math.round(a.y)))),t.position.value=a;}}}ƀbg(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};_e=Js([d()],_e);var Xs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ks=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},di=class{static{h(this,"CameraController");}constructor(t){this.ƀas=t;}createCamera(){return this.ƀas.createCamera().id}update(t,e){this.ƀas.update(t,e);}setPosition(t){this.ƀas.setPosition(t);}setTransition(t){this.ƀas.setTransition(t);}getCameraPosition(){return this.ƀas.getCameraPosition()}};di=Xs([Q(exports.CameraGateway),Ks("design:paramtypes",[_e])],di);var Zs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ui=class{static{h(this,"CameraViewController");}getLayers(){let t=F.getInstanceOrFail().id;return Et.getInstanceOrFail(t).getLayers()}appear(t,e,i){let r=F.getInstanceOrFail().id;return Et.getInstanceOrFail(r).appear(t,e,i)}screenPositonToStagePosition(t){let e=F.getInstanceOrFail().id;return Et.getInstanceOrFail(e).screenPositonToStagePosition(t)}};ui=Zs([Q(Pt)],ui);var ee=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=S.get(exports.CameraGateway),this.ƀat=S.get(Pt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha",i=0){return this.ƀat.appear(t,e,i)}screenPositonToStagePosition(t){return this.ƀat.screenPositonToStagePosition(t)}};var g=class o{static{h(this,"Game");}static get instance(){return this.ƀfy}static{this.pause=actionsLib.Reducer.createOr();}static{this.freeze=actionsLib.Reducer.createOr();}static get camera(){return this.ƀao}static get audio(){return this.ƀx}static appear(t,e){let i=e?.audio??"ease",r=e?.camera??"alpha";return actionsLib.ActionLib.all([this.audio.appear(t,i),this.camera.appear(t,r,i!=="instant"?0:500)]).mapToVoid().chainToRoot()}static get time(){return m.ƀll}static get setupOptions(){return this.ƀkd}constructor(t){if(this.ƀjp=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSize=this.ƀjp.notifier,this.ƀjq=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSizeCenter=this.ƀjq.notifier,this.devMode=false,o.ƀfy)throw new Error("There can be only one Game instance!");this.ƀbk={screenResolution:void 0,maxScreenResolution:void 0,devMode:false,backgroundColor:helpersLib.ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbk.devMode||false;let e=helpersLib.JsonHelper.removeUndefinedProperties({backgroundColor:this.ƀbk.backgroundColor,autoStart:false,antialias:this.ƀbk.antialias,resolution:this.ƀbk.resolution,width:this.ƀbk.screenResolution?.width,height:this.ƀbk.screenResolution?.height});this.ƀiq=new N__namespace.Application(e);let i=o.pause.effect(false).attachToRoot();o.freeze.subscribe(r=>{i.update(r),r?P.context.suspend():P.context.resume();}).attachToRoot();}async setup(t){o.ƀkd=t;let e=document.body.appendChild(this.ƀiq.view);this.ƀjz(e),await Promise.all([M.loadGameAssets(t.spriteAssetDefinitions),M.loadGameAssets(t.fontAssetDefinitions),P.load(t.soundAssetDefinitions)]),o.ƀfy=this,this.renderer=this.ƀiq.renderer,globalThis.ƀa=this.ƀiq,this.ƀfe(),o.ƀao=new ee,o.ƀx=J.ƀka(),this.ƀiq.start(),this.ƀiq.ticker.add(()=>{o.freeze.value||m.triggerUpdateTick(this.ƀiq.ticker.deltaMS);});}setResolution(t){if(this.ƀiq.renderer.resolution!==t){this.ƀiq.renderer.resolution=t;let e=this.ƀer();this.ƀiq.renderer.resize(e.x,e.y);}}ƀfe(){this.ƀdb(),this.ƀjy(),window.addEventListener("resize",t=>{this.ƀdb(),this.ƀjy();});}ƀdb(){let t=this.ƀer();(t.x!==this.ƀiq.screen.width||t.y!==this.ƀiq.screen.height)&&this.ƀiq.renderer.resize(t.x,t.y);}ƀjy(){let t=new helpersLib.Vector(this.ƀiq.screen.width,this.ƀiq.screen.height);this.ƀjp.value=t,this.ƀjq.value=t.multiplyNumber(.5).round();}ƀer(){let t=this.ƀbk.screenResolution?.width??window.innerWidth,e=this.ƀbk.screenResolution?.height??window.innerHeight;return this.ƀbk.maxScreenResolution&&(t=Math.min(t,this.ƀbk.maxScreenResolution.width),e=Math.min(e,this.ƀbk.maxScreenResolution.height)),new helpersLib.Vector(t,e)}ƀjz(t){this.ƀbk.maxScreenResolution&&(t.style.maxWidth=`${this.ƀbk.maxScreenResolution?.width}px`,t.style.maxHeight=`${this.ƀbk.maxScreenResolution?.height}px`),t.style.width="100%",t.style.height="100%";}};var ie=class o extends actionsLib.IDAttachable{static{h(this,"Sound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`Sound: Could not find sound definition with name ${t}.`);return new o(i,e)}get volume(){return this.ƀdr.gain.value}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀdr.gain.value=t,this}constructor(t,e){super(),this.ƀkk=t,this.ƀdr=P.context.createGain(),this.ƀdr.connect(J.ƀfy.ƀkj),this.ƀfi=this.ƀdr,e?.volume!==void 0&&(this.volume=e.volume),this.ƀiw(e?.time??0);}destroy(){this.destroyed||(super.destroy(),this.ƀla(),this.ƀdr?.disconnect());}ƀlv(){this.ƀfi.disconnect(),this.ƀfi.connect(J.ƀfy.ƀhi);}ƀiw(t){this.ƀla();let e=this.ƀkk.loop;if(this.ƀkt=helpersLib.NumberHelper.clamp(t,0,e?e.to:this.ƀkk.duration),e){let i=e.from,r=e.to;this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:this.ƀkt<i?i:r,loop:false,onComplete:h(()=>{this.ƀkn.disconnect(),this.ƀix({soundID:this.ƀkk.id,start:i,end:r,loop:true});},"onComplete")});}else this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:void 0,loop:false,onComplete:h(()=>this.destroy(),"onComplete")});}ƀla(){this.ƀkn&&(this.ƀkn.onended=null,this.ƀkn.stop(),this.ƀkn.disconnect());}ƀix(t){this.ƀkn=P.createSource(t.soundID),this.ƀkn.connect(this.ƀdr),t.onComplete&&(this.ƀkn.onended=t.onComplete),t.loop?(this.ƀkn.loop=true,this.ƀkn.loopStart=t.start,this.ƀkn.loopEnd=t.end??this.ƀkn.buffer.duration,this.ƀkn.start(0,t.start)):this.ƀkn.start(0,t.start,t.end?t.end-t.start:void 0);}};var so=800,re=-128,nt=class o extends ie{static{h(this,"AdvancedSound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}constructor(t,e){super(t,e),this.ƀll=new actionsLib.Variable(0),this.time=this.ƀll.notifier,this.ƀkw=P.context.currentTime-this.ƀkt,this.ƀll.value=this.ƀkt,m.beforeSceneUpdateAction.subscribe(()=>{this.ƀll.value=P.context.currentTime-this.ƀkw;}).attach(this),this.ƀfi.disconnect(),this.ƀkb(e?.fade?helpersLib.NumberHelper.clamp(e.fade,0,1):0),this.ƀkc(e?.muffle?helpersLib.NumberHelper.clamp(e.muffle,0,1):0),this.ƀfi.connect(J.ƀfy.ƀkj);}ƀkb(t=0){this.ƀdk=P.context.createGain(),this.ƀdk.gain.value=1-t,this.ƀdj=new I(this.ƀdk.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀfi.connect(this.ƀdk),this.ƀfi=this.ƀdk;}ƀkc(t=0){this.ƀhg=P.context.createBiquadFilter(),this.ƀhg.type="highshelf",this.ƀhg.frequency.value=so,this.ƀhg.gain.value=t*re,this.ƀhh=new I(this.ƀhg.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀfi.connect(this.ƀhg),this.ƀfi=this.ƀhg;}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.fade(1,Y).notIdle().chain(this).tap(()=>this.destroy()).chainToRoot())}notifyOnTime(t){return this.time.value>t?actionsLib.SingleEvent.createDestroyed():actionsLib.SingleEvent.create(e=>{let i=this.time.filter(r=>r>=t).tap(()=>e()).attach(this);return ()=>i.destroy()})}setFade(t){t=helpersLib.NumberHelper.clamp(t,0,1),this.ƀdj.set({value:1-t});}fade(t,e=500){t=helpersLib.NumberHelper.clamp(t,0,1);let i=t>1-this.ƀdk.gain.value;return e===0?(this.ƀdj.set({value:1-t}),actionsLib.SingleEvent.instant()):this.ƀdj.animate({value:1-t},{duration:e,animation:i?x.easeOut:x.easeIn}).chain(this)}setMuffle(t){t=helpersLib.NumberHelper.clamp(t,0,1),this.ƀhh.set({value:t*re});}muffle(t,e=500){t=helpersLib.NumberHelper.clamp(t,0,1);let i=t>this.ƀhg.gain.value/re;return e===0?(this.ƀhh.set({value:t*re}),actionsLib.SingleEvent.instant()):this.ƀhh.animate({value:t*re},{duration:e,animation:i?x.easeIn:x.easeOut}).chain(this)}destroy(){this.destroyed||(this.ƀdk.disconnect(),this.ƀhg.disconnect()),super.destroy();}};var se=class o extends actionsLib.IDAttachable{static{h(this,"Music");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}get time(){switch(this.ƀkm.value.type){case "paused":return this.ƀkm.value.value.time;case "playing":return this.ƀkm.value.value.time.value;default:{this.ƀkm.value;throw new Error(`Unexpected case! "${this.ƀkm.value}"`)}}}get volume(){return this.ƀkm.value.value.volume}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀkm.value.value.volume=t,this}constructor(t,e){super(),this.ƀhx={stopPlayingOnPause:true,...e},this.ƀkl=t.id;let i;if(g.pause.value)i={type:"paused",value:{time:0,volume:1}};else {let r=new nt(t,this.ƀhx).attach(this);r.ƀlv(),i={type:"playing",value:r};}this.ƀkm=new actionsLib.Variable(i),this.ƀhx.stopPlayingOnPause&&(this.ƀid=g.pause.subscribe(r=>this.ƀfd(r)).attach(this));}notifyOnTime(t){return actionsLib.SingleEvent.create(e=>{let i=this.ƀkm.asyncMapDropOngoing((r,s)=>{switch(r.type){case "paused":s.drop();break;case "playing":return r.value.notifyOnTime(t);default:{throw new Error(`Unexpected case! "${r}"`)}}}).toSingleEvent().tap(()=>e()).attach(this);return ()=>i.destroy()})}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),actionsLib.SingleEvent.instant().asyncTap(()=>actionsLib.ActionLib.all([this.ƀkm.value.type==="playing"?this.ƀkm.value.value.close():actionsLib.SingleEvent.instant(),this.ƀdl?.onDestroy()??actionsLib.SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀfd(t){if(t){if(this.ƀkm.value.type==="playing"){let e=this.ƀkm.value.value;this.ƀkm.value={type:"paused",value:{time:e.time.value,volume:e.volume}},this.ƀdl=e,actionsLib.ActionLib.all([e.fade(1,Y),e.muffle(1,Y)]).tap(()=>{this.ƀdl=void 0,e.destroy();}).attach(this);}}else if(this.ƀkm.value.type==="paused"){let{volume:e,time:i}=this.ƀkm.value.value,r=nt.createByName(this.ƀkl,{volume:e,time:i,fade:1,muffle:1}).attach(this);r.ƀlv(),actionsLib.ActionLib.all([r.fade(0,Y),r.muffle(0,Y)]).attach(this),this.ƀkm.value={type:"playing",value:r};}}};var mi=class extends actionsLib.IDAttachable{static{h(this,"MusicPlayer");}get time(){return this.ƀiy?this.ƀiy.time:0}get volume(){return this.ƀmf}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀmf=t,this.ƀiy&&(this.ƀiy.volume=t),this.ƀic&&(this.ƀic.volume=t),this}constructor(t){super(),this.ƀmf=1,this.ƀhx={stopPlayingOnPause:true,playWhenPaused:void 0,volume:1,...t},this.ƀmf=this.ƀhx.volume,this.ƀhx.playWhenPaused&&this.ƀke(this.ƀhx.playWhenPaused);}play(t){if(this.ƀbb)throw new Error("Play is called while music player is destroyed.");return this.ƀco=t,actionsLib.SingleEvent.instant().asyncTap(()=>{let e=this.ƀiy;if(e)return this.ƀiy=void 0,e.close()}).map(()=>{if(this.ƀco===t)return this.ƀiy=se.createByName(t,{stopPlayingOnPause:this.ƀhx.stopPlayingOnPause,volume:this.ƀmf}).attach(this),this.ƀiy}).chain(this)}stop(){return actionsLib.SingleEvent.instant().asyncTap(()=>{let t=this.ƀiy;if(t)return t.close().tap(()=>{t===this.ƀiy&&(this.ƀiy=void 0);})}).chain(this)}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),actionsLib.SingleEvent.instant().asyncTap(()=>actionsLib.ActionLib.all([this.ƀiy?.close()??actionsLib.SingleEvent.instant(),this.ƀic?.close()??actionsLib.SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀke(t){this.ƀid=g.pause.toSequence().asyncMapDropOngoing(e=>e&&m.wait(Y).map(()=>e)).tap(e=>{if(e)this.ƀic=nt.createByName(t,{fade:1,volume:this.ƀmf}).attach(this),this.ƀic.fade(0);else if(this.ƀic){let i=this.ƀic;this.ƀic.fade(1).tap(()=>i.destroy()).attach(this),this.ƀic=void 0;}}).attach(this);}};var yi=class extends u{static{h(this,"UpdatableContainer");}},gi=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀby=t,this.ƀcu=new Map,this.ƀhx={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcu.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhx.trackBy(r,s),a;this.ƀcu.has(n)?(a=this.ƀcu.get(n),e.delete(n),a.update(r)):(a=this.ƀby(r).displayParent(this).attach(this),this.ƀcu.set(n,a)),this.ƀhx.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhx.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhx.positioning.spacing);}),e.forEach(r=>{this.ƀcu.get(r).destroy(),this.ƀcu.delete(r);});}};var ne=class o extends u{static{h(this,"MenuUI");}static{this.ƀga=actionsLib.Reducer.createExistenceChecker();}static{this.isAnyMenuTransitioning=this.ƀga.notifier;}constructor(t,e){super(),this.ƀhp=new actionsLib.SingleAction,this.onCreate=this.ƀhp.notifier,this.ƀhr=new actionsLib.SingleAction,this.onOpen=this.ƀhr.notifier,this.ƀhm=new actionsLib.SingleAction,this.onClose=this.ƀhm.notifier,this.ƀbb=false;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,backgroundDarkeningRatio:.3,...e};this.setAlpha(0),this.ƀp=new I(this,"alpha",{animation:x.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState});let r=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.backgroundDarkeningRatio).setInteractive(true).displayParent(this).attach(this);this.ƀha=k.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),g.instance.screenSize.subscribe(n=>{r.aspectRatio=n.x/n.y,r.scale=Math.max(n.x,n.y),r.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(n.multiplyNumber(.5));}).attach(this),this.ƀhp.resolve();let s=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:1}).chain(this).tap(()=>{this.ƀhr.resolve(),s.destroy(),i.closeOnBackgroundClick&&r.on(exports.ContainerEventType.Click).take(1).tap(()=>this.close()).attach(this);}).attachToRoot();}getBoundingMask(){return this.ƀha.getBoundingMask()}close(){if(!this.ƀbb){this.ƀbb=true;let t=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:0}).chain(this).map(()=>{this.ƀhm.resolve(),t.destroy(),this.destroy();}).chainToRoot();}return this.onClose.toSingleEvent()}};var xi=class extends gt{static{h(this,"MenuEntity");}static subscribeIsOpen(){return actionsLib.ActionLib.merge(this.continuesSubscription().map(t=>t.type==="open"),actionsLib.SingleEvent.instant(this.getInstance()!==void 0))}constructor(t){super(),this.ƀhx=t,queueMicrotask(()=>{if(!this.ƀhb)throw new Error("MenuEntity: MenuEntity has to have a MenuView.")});}ƀjh(t){this.ƀhb=t,this.ƀhb.onClose.subscribe(()=>this.destroy()).attach(this);}onCreate(){return this.ƀhb.onCreate.toSingleEvent()}onOpen(){return this.ƀhb.onOpen.toSingleEvent()}onClose(){return this.ƀhb.onClose.toSingleEvent()}close(){return this.ƀhb.close()}};var vi=class extends mt{static{h(this,"MenuView");}constructor(t,e,i){super();let r=helpersLib.JsonHelper.removeUndefinedProperties({appearAnimationDuration:i.appearAnimationDuration,backgroundDarkeningRatio:i.backgroundDarkeningRatio,closeOnBackgroundClick:t.ƀhx.closeOnBackgroundClick}),s=new ne(e,r).displayParent(g.camera.layers.foregroundScreen).attach(this);t.ƀjh(s);let n=new actionsLib.SingleAction;s.onCreate.subscribe(()=>n.resolve(s)).attach(this),this.onCreate=n.notifier,this.onOpen=s.onOpen.notifier,this.onClose=s.onClose.notifier;}};var go=.65,wo=.01,He=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀjr}get contentSize(){return this.ƀbm.size.ceil()}constructor(t,e,i,r){this.ƀbm=t,this.ƀv=e,this.ƀia=i,this.ƀki=r,this.ƀfx=false,this.ƀjr=e-i*2,this.ƀbm.y=i,this.ƀld=i;}onWheel(t){this.setTarget(this.ƀld-t*go);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀld=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀia-this.contentSize.y,this.ƀia);}jumpToTarget(){this.ƀbm.y=this.ƀld;}update(t){let e=this.contentSize;if(e.y<=this.ƀjr){switch(this.ƀki){case "start":this.ƀld=this.ƀia;break;case "center":this.ƀld=(this.ƀv-e.y)*.5;break;case "end":this.ƀld=this.ƀv-e.y-this.ƀia;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}this.ƀfx||(this.ƀbm.y=this.ƀld);}this.ƀfx=true;let i=this.ƀld-this.ƀbm.y;this.ƀbm.y=this.ƀbm.y+i*wo*t;}};var vo=15,bi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbn}get contentSize(){return this.ƀjs.contentSize}constructor(t,e={}){super();let i={padding:vo,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new xt(r,t,i.padding).attach(this);let s=new N__namespace.Graphics;s.beginFill(0,1e-9),s.drawRect(0,0,t.x,t.y),s.endFill(),r.ƀir.addChild(s);let n=new u().displayParent(r).attach(this);this.ƀjs=new He(n,t.y,i.padding,i.smallContentAlign),this.ƀbn=new helpersLib.Vector(t.x,this.ƀjs.scrollHeight),s.eventMode="dynamic",s.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),n.setInteractive(true),n.ƀir.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),m.afterSceneUpdateAction.subscribe(a=>this.ƀjs.update(a.delta)).attach(this),this.addChildTo=n;}scrollToTop(t){this.ƀjs.scrollToTop(),t?.instant&&this.ƀjs.jumpToTarget();}scrollToBottom(t){this.ƀjs.scrollToBottom(),t?.instant&&this.ƀjs.jumpToTarget();}};var bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class Si{static{h(this,"KeyboardService");}constructor(){this.ƀgh=new actionsLib.Action,this.keyPressed=this.ƀgh.notifier,this.ƀgi=new actionsLib.Action,this.keyReleased=this.ƀgi.notifier,this.ƀgo=new Set,this.ƀgn=new Set,window.addEventListener("keydown",t=>{this.ƀgo.add(t.code),this.ƀgn.add(t.code),!t.repeat&&this.ƀgh.trigger({key:t.key,code:t.code});}),window.addEventListener("keyup",t=>{this.ƀgo.delete(t.code),this.ƀgi.trigger({key:t.key,code:t.code});}),window.addEventListener("blur",()=>{this.ƀgo.clear();}),m.afterSceneUpdateAction.subscribe(()=>this.ƀgn.clear()).attachToRoot();}isKeyDown(t,e){return (e?.onlyPressedThisFrame?this.ƀgn:this.ƀgo).has(t)}};exports.KeyboardService=bo([d(),So("design:paramtypes",[])],exports.KeyboardService);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Eo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class he{static{h(this,"MouseService");}constructor(){this.ƀfw=new actionsLib.Variable(false),this.initialMouseMovementHappened=this.ƀfw.notifier,this.ƀks=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀks.notifier,this.ƀjo=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀjo.notifier,this.ƀgr=new actionsLib.Variable(false),this.mainButtonState=this.ƀgr.notifier,this.ƀjt=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀjt.notifier,this.ƀku(),window.addEventListener("pointerdown",t=>{t.button===0?this.ƀgr.value=true:t.button===2&&(this.ƀjt.value=true);},{capture:true}),window.addEventListener("pointerup",t=>{t.button===0?this.ƀgr.value=false:t.button===2&&(this.ƀjt.value=false);},{capture:true}),window.addEventListener("blur",()=>{this.ƀgr.value=false,this.ƀjt.value=false;},{capture:true});}ƀku(){let t=helpersLib.Vector.zero;window.addEventListener("pointermove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfw.value=true;},{capture:true}),m.beforeSceneUpdateAction.subscribe(()=>{this.ƀjo.value=this.ƀaz(t);}).attachToRoot(),m.afterSceneUpdateAction.subscribe(()=>{let e=g.camera.screenPositonToStagePosition(this.ƀjo.value);e.isEqual(this.ƀks.value)?g.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:t.x,clientY:t.y,pointerType:"mouse"})):this.ƀks.value=e;}).attachToRoot();}ƀaz(t){let i=g.instance.renderer.view.getBoundingClientRect(),r=i.width,s=i.height;if(r<=0||s<=0)return helpersLib.Vector.zero;let n=g.instance.renderer,a=(t.x-i.left)/r*n.screen.width,l=(t.y-i.top)/s*n.screen.height;return a=helpersLib.NumberHelper.clamp(a,0,n.screen.width),l=helpersLib.NumberHelper.clamp(l,0,n.screen.height),new helpersLib.Vector(a,l)}};exports.MouseService=Po([d(),Eo("design:paramtypes",[])],exports.MouseService);var To=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ro=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class Pi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdo}get lastFocusedPosition(){return this.ƀgk}constructor(t){this.ƀhe=t,this.ƀht=new actionsLib.Action,this.onTargetFocus=this.ƀht.notifier,this.ƀln=0,this.ƀlo=false,this.ƀdo=false,this.ƀgk=void 0,m.beforeSceneUpdateAction.subscribe(e=>this.ƀlr(e.delta)).attachToRoot();}ƀlr(t){if(this.ƀhf){let e=this.ƀeq(this.ƀhe.stagePosition.value,this.ƀhf);this.ƀif===void 0?this.ƀif=e:this.ƀav(e,t);}this.ƀhf=this.ƀhe.stagePosition.value;}ƀav(t,e){this.ƀif-t>10?(this.ƀln=Math.max(250,this.ƀln),this.ƀlo=true):this.ƀln>1e3&&(this.ƀlo=true);let i=this.ƀln>=300&&this.ƀlo;this.ƀgg(i,t,e);}ƀgg(t,e,i){(t||e>this.ƀif)&&(this.ƀif=e),t?(this.ƀlo=false,this.ƀln=0,this.ƀdo=true,this.ƀgk=this.ƀhe.stagePosition.value,this.ƀht.trigger(this.ƀgk)):(this.ƀln+=i,this.ƀdo=false);}ƀeq(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=To([d(),Ro("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var Ei=10.8,Ti=10.01;exports.PhysicsShapeType=void 0;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(exports.PhysicsShapeType||(exports.PhysicsShapeType={}));var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return helpersLib.Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new helpersLib.Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new U__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},at=class extends q(){static{h(this,"PhysicsInternalGateway");}};at=Mo([d()],at);var b=class o extends W{static{h(this,"PhysicsEntity");}static{this.ƀhz=new Map;}static{this.ƀij=new Map;}static getFromP2BodyID(t){return o.ƀhz.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhz.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀij.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀij.values())}get area(){return this.ƀu}get mass(){return this.ƀgv}get collisions(){return this.ƀbc}constructor(t,e,i){super(),this.ƀhn=new actionsLib.Action,this.onCollision=this.ƀhn.notifier,this.type="dynamic",this.ƀu=0,this.ƀgv=0,this.ƀbc=[],this.physicsWorldID=t,this.ƀil=S.get(at);let r=this.ƀil.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀil.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀik=this.ƀil.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀim=this.ƀil.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀil.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgv=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀil.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhz.set(this.p2Body.id,this),o.ƀij.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀil.removeBody(this.physicsWorldID,this.p2Body),o.ƀhz.delete(this.p2Body.id),o.ƀij.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀik,this.ƀim,t.ƀik,t.ƀim)}ƀjv(t){this.ƀbc=t,t.length>0&&this.ƀhn.trigger(t);}};var le=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new helpersLib.Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:helpersLib.Vector.zero,rotationalSpeed:0}}};var Ri=class extends W{static{h(this,"MovableEntity");}constructor(){super(),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),m.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀkz(t,e);}).attach(this);}ƀkz(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new helpersLib.Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ii=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),this.ƀfp=false,this.ƀfq=false,this.ƀfs=false,this.ƀfr=false,this.ƀig(),this.ƀgp(),S.get(at).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀkz(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀkz(t,e){this.ƀfp=true,this.ƀfq=true,this.ƀfs=true,this.ƀfr=true,this.ƀig();}ƀig(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new helpersLib.Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀgp(){this.position.subscribe(t=>{this.ƀfp?this.ƀfp=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfq?this.ƀfq=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfs?this.ƀfs=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfr?this.ƀfr=false:this.p2Body.angularVelocity=t;}).attach(this);}};var ht="border";var Fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s};exports.PhysicsGateway=class ce extends q(){static{h(this,"PhysicsGateway");}};exports.PhysicsGateway=Fo([d()],exports.PhysicsGateway);var Vo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},No=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends W{static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new actionsLib.Variable(false),this.lastP2Time=new actionsLib.Variable(0),this.onPhysicsStep=new actionsLib.Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=Vo([yt(),No("design:paramtypes",[helpersLib.Vector,Boolean,U__default.default.World,Map,Map,Map,Map])],v);var Uo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},X=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};X=Uo([d()],X);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},We=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀii=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀii.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};We=Wo([d(),$o("design:paramtypes",[X])],We);var zo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},lt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀii=t,this.ƀz=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀz.getCollidableGrids(t,i).forEach(s=>{let n=G.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=50){return e.aabbNeedsUpdate=true,e.updateAABB(),Xt.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀz.get(t,e,i);return r||(r=this.ƀcb(t,e,i),this.ƀz.set(t,e,i,r)),r}ƀcb(t,e,i){let r=new helpersLib.Grid({size:new helpersLib.Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀii.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀeh(s,e);r.setArea(a,false);}}),r}ƀeh(t,e){let i=f.aabbToBoundingBox(t.aabb);return G.areaToGridArea(i,e)}};lt=zo([d(),ko("design:paramtypes",[X,We])],lt);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Nt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀih=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=50);let n=v.getInstanceByIDOrFail(t),a,l;helpersLib.Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=G.positionToGridPosition(e,s.gridCellSize),p=G.positionToGridPosition(a,s.gridCellSize),y=this.ƀih.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let A=f.aabbToBoundingBox(l.aabb),Tt=G.areaToGridArea(A,s.gridCellSize);y.setArea(Tt,true);}let w=Kt.findPath(y,c,p,s.neighborType);return w.path=w.path.map(A=>G.gridPositionToPosition(A,s.gridCellSize)),w}findPathDirection(t,e,i,r,s=50){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let w=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(w.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=G.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let w=this.ƀih.getAvilabilityGrid(n,s,r);p=new Zt(l,w),n.vectorFieldCache.set(c,p);}let y=G.positionToGridPosition(e,s);return p.getDirectionToTarget(y)}};Nt=Xo([d(),Ko("design:paramtypes",[lt])],Nt);var Qo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},tn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Z=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀaa=t,this.ƀib=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀaa.getAvilabilityGrid(a,n,r).map((c,p)=>({position:G.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀib.findPathDirection(t,c.position,i,r),y;p===void 0?y=T.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):y=T.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new I(y,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>y.destroy()).attach(y);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,helpersLib.ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new I(a,"alpha",{duration:n,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,helpersLib.ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let y=p.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(p.line.from,p.line.to,y).toSprite().displayParent(l).attach(t);}),new I(l,"alpha",{duration:a,animation:x.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new helpersLib.Radian(t.angle),n=i?.color??helpersLib.ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcw(c,n).displayParent(a).attachToRoot();}),new I(a,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcw(t,e){switch(t.type){case U__default.default.Shape.PARTICLE:throw new Error("Not implemented");case U__default.default.Shape.LINE:throw new Error("Not implemented");case U__default.default.Shape.PLANE:throw new Error("Not implemented");case U__default.default.Shape.CIRCLE:throw new Error("Not implemented");case U__default.default.Shape.CAPSULE:throw new Error("Not implemented");case U__default.default.Shape.BOX:throw new Error("Not implemented");case U__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case U__default.default.Shape.CONVEX:return this.ƀcv(t,e);default:throw new Error("Not implemented")}}ƀcv(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Z=Qo([d(),tn("design:paramtypes",[lt,Nt])],Z);var sn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},on=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},$e=class{static{h(this,"HitTestService");}constructor(t){this.ƀlg=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdt(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new U__default.default.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?helpersLib.ColorHelper.red:helpersLib.ColorHelper.green;this.ƀlg.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdt(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};$e=sn([d(),on("design:paramtypes",[Z])],$e);var an=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ze=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀjg(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀbc=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀjg(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀff(r.p2Body),r.entity.ƀjv(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀff(t){let e=f.arrayToVector(t.velocity);e.length>Ei&&(e=e.normalize(Ei),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-Ti),Ti);}ƀjg(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdz(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdz(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeo(i);return {collisionDetailsA:this.ƀdy(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdy(s,i.bodyB.mass,a,c,e.area)}}ƀdy(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeo(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};ze=an([d()],ze);var hn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ln=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ke=class extends le{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};ke=hn([yt(),ln("design:paramtypes",[Number,Object])],ke);var cn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=1e4,Je=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbv(t,new helpersLib.Vector(e.x/2,-j/2),new helpersLib.Vector(e.x+j*2,j),i),this.ƀbv(t,new helpersLib.Vector(e.x/2,e.y+j/2),new helpersLib.Vector(e.x+j*2,j),i),this.ƀbv(t,new helpersLib.Vector(-j/2,e.y/2),new helpersLib.Vector(j,e.y+j*2),i),this.ƀbv(t,new helpersLib.Vector(e.x+j/2,e.y/2),new helpersLib.Vector(j,e.y+j*2),i);}ƀbv(t,e,i,r){return new ke(t,{shapeDefinition:{materialName:ht,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};Je=cn([d()],Je);var dn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},fr=new U__default.default.Material,un={id:ht,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Lt=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new U__default.default.Material),n.set(a.id,a);}),s.has(ht))throw new Error(`Material with name ${ht} cannot be defined, pick another name for the material.`);return s.set(ht,fr),n.set(ht,un),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀem(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀel(e,i.materialDefinitions)}ƀem(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀel(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀee(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀem(n.materialA,s),l=this.ƀem(n.materialB,s);t.addContactMaterial(new U__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀee(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀem(s.id,r);t.addContactMaterial(new U__default.default.ContactMaterial(n,fr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Lt=dn([d()],Lt);var fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ht=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgz=t,this.ƀaj=e,this.ƀaa=i,this.ƀbd=r,this.ƀii=s;}createPhysicsWorld(t){let e=new U__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgz.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀii.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&m.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀbd.registerPhysicsWorld(a),t.modifyUpdateCycle?m.registerUpdateModifier((l,c)=>this.ƀkz(a,l,c)):m.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀkz(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀaa.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀkz(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀbd.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ht=fn([d(),mn("design:paramtypes",[Lt,Je,lt,ze,X])],Ht);var gn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ut=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new U__default.default.RaycastResult,s=new U__default.default.Ray({mode:U__default.default.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbq(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new U__default.default.Ray({mode:U__default.default.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbq(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbq(n,e));},"callback")});return t.p2World.raycast(new U__default.default.RaycastResult,s),Array.from(r.values())}ƀbq(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Ut=gn([d()],Ut);var wn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},dt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};dt=wn([d()],dt);var xn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Wt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbr(r,t.length))}ƀbr(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:helpersLib.Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Wt=xn([d()],Wt);var bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Tn=15,Xe=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcg(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀjb.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀlg.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(y=>{let{p2Body:w,...A}=y;return A})}ƀcg(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(helpersLib.Radian.get90).vector,p=c.normalize(i.x);a.push(new helpersLib.Line(t,t.add(p))),a.push(new helpersLib.Line(t,t.add(p.multiplyNumber(-1))));let y=l.normalize(i.y);a.push(new helpersLib.Line(t,t.add(y))),a.push(new helpersLib.Line(t,t.add(y.multiplyNumber(-1))));let w=Math.round(i.y/Tn),A=i.y/(w*2+1)*2,Tt=l.normalize(A),pe=i.x,yr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(w).forEach(ft=>{let Rt=A*(ft+1),Oi=Tt.multiplyNumber(ft+1),de=c.normalize(this.ƀex(pe,yr,Rt)),ue=t.add(Oi);a.push(new helpersLib.Line(ue,ue.add(de))),a.push(new helpersLib.Line(ue,ue.add(de.multiplyNumber(-1))));let fe=t.add(Oi.multiplyNumber(-1));a.push(new helpersLib.Line(fe,fe.add(de))),a.push(new helpersLib.Line(fe,fe.add(de.multiplyNumber(-1))));}),a.map(ft=>{if(s){let Rt=this.ƀjc.castClosest(n,ft,r);return {line:ft,hits:Rt?[Rt]:[]}}else {let Rt=this.ƀjc.castAllFirstContacts(n,ft,r);return {line:ft,hits:Rt}}})}ƀex(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀft.applyImpulse(r.body,r.hitPosition(),s,n);});});}};Xe=bn([d(),Sn("design:paramtypes",[Ut,Z,Wt,dt])],Xe);var Rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},In=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ke=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeu(i),c=this.ƀcg(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀjb.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀlg.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcg(t,e,i,r,s,n){let a=new helpersLib.Radian(helpersLib.PI_360/r),l=new helpersLib.Vector(0,-e),c=a.vector;return helpersLib.ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new helpersLib.Line(t,p)}).map(p=>{if(s){let y=this.ƀjc.castClosest(n,p,i);return {line:p,hits:y?[y]:[]}}else {let y=this.ƀjc.castAllFirstContacts(n,p,i);return {line:p,hits:y}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀft.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=helpersLib.Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀft.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeu(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};Ke=Rn([d(),In("design:paramtypes",[Ut,Z,Wt,dt])],Ke);var Mn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$t=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};$t=Mn([d()],$t);var Bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Gn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ai=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀip=t,this.ƀib=e,this.ƀlg=i,this.ƀdh=r,this.ƀda=s,this.ƀfk=n,this.ƀio=a,this.ƀft=l;}createPhysicsWorld(t){return this.ƀip.createPhysicsWorld(t)}getMapSize(t){return this.ƀio.getMapSize(t)}setPaused(t,e){this.ƀip.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀfk.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀib.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀib.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀft.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdh.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀda.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=50){this.ƀlg.printPathfindingTestGrid(t,e,i,r,s,n);}};Ai=Bn([Q(exports.PhysicsGateway),Gn("design:paramtypes",[Ht,Nt,Z,Ke,Xe,$e,$t,dt])],Ai);var _n=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ze=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case exports.PhysicsShapeType.Point:return this.ƀbx(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbx(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcf(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀch(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbx(t,e,i,r,s,n){let a=new U__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcf(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(w=>new U__default.default.Convex({vertices:w.map(A=>[A.x,A.y]),collisionGroup:a,collisionMask:l})).map(w=>(w.material=i,w)),p=c.reduce((w,A)=>w+A.area,0),y=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(w=>y.addShape(w)),y.setDensity(r.density),y}ƀch(t,e,i,r,s,n){let a=new U__default.default.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};Ze=_n([d()],Ze);var Fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ci=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀip=t,this.ƀin=e,this.ƀkf=i,this.ƀio=r,this.ƀii=s;}createBody(t,e,i,r,s){return this.ƀkf.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀin.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀin.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀii.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀii.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀip.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀip.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀio.subscribeToPhysicsStep(t,e)}};Ci=Fn([Q(at),Vn("design:paramtypes",[Ht,Lt,Ze,$t,X])],Ci);exports.AdvancedSound=nt;exports.AnimationFlicker=Bi;exports.AnimationInterpolationFunctions=V;exports.Animations=x;exports.Animator=I;exports.BORDER_MATERIAL_NAME=ht;exports.BardLegendsHardReset=R;exports.Camera=ee;exports.ClosestAvailableSpaceHelper=Xt;exports.Container=u;exports.ControllerDecorator=Q;exports.DEFAULT_SHADER_RESOLUTION=D;exports.DeltaTime=ni;exports.DisplayObjectArray=gi;exports.Entity=W;exports.EntityDecorator=yt;exports.FadeInContent=Hi;exports.Game=g;exports.Gateway=q;exports.Graphics=T;exports.ImmovablePhysicsEntity=le;exports.MenuEntity=xi;exports.MenuUI=ne;exports.MenuView=vi;exports.MovableEntity=Ri;exports.MovablePhysicsEntity=Ii;exports.Music=se;exports.MusicPlayer=mi;exports.PathFinder=Kt;exports.PhysicsEntity=b;exports.Placeholder=hi;exports.ROTATIONAL_SPEED_LIMIT=Ti;exports.RichText=li;exports.SOUND_TRANSITION_DURATION=Y;exports.SPEED_LIMIT=Ei;exports.Scene=me;exports.SceneDecorator=Cr;exports.ScrollAreaUI=bi;exports.ScrollMaskUI=xt;exports.Service=S;exports.ServiceDecorator=d;exports.SingletonEntity=gt;exports.SlideInContent=Ji;exports.SlideInContentByIndex=oi;exports.SlideStateAnimation=Ie;exports.Sound=ie;exports.Sprite=k;exports.StateAnimation=Dt;exports.Text=Qt;exports.ThroughEmptyStateAnimation=be;exports.UpdatableContainer=yi;exports.UpdateCycle=m;exports.VectorFieldPathFinder=Zt;exports.VectorSet=bt;exports.View=mt;exports.ViewDecorator=Qe;
67
+ }`,e}constructor(t,e){if(super(o.ƀev(),o.ƀed(t*D)),this.ƀdf=t,this.resolution=D,this.ƀdf=t*D,this.ƀdf<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀdf>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀdf)||(this.ƀdf=Math.floor(this.ƀdf));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀdf*this.ƀdf,this.padding=this.ƀdf;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*D),1/(e.height*D)]),t.applyFilter(this,e,i,r);}};var Te=class extends N__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=D;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀdg=new Ee(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Ot(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=N__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀdg.apply(t,e,s,N__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Jt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀey=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbh(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀef(t.texture,s,r.expand,r.color,i),a=new N__namespace.Sprite(n);return this.ƀjx(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀef(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀey.has(n))return o.ƀey.get(n);{let a=this.ƀeg(t,e,i,r);return o.ƀey.set(n,a),a}}else return this.ƀeg(t,e,i,r)}static ƀeg(t,e,i,r){let s=new N__namespace.Sprite(t);this.ƀdi(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=g.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀjx(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdi(t,e){if(t.isSprite){let s=new N__namespace.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbh(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};R.onHardReset.subscribe(()=>{Jt.ƀey.clear();}).attachToRoot();var k=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=g.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.ƀir,i=e.parent;i&&i.removeChild(e);let r=g.instance.renderer.generateTexture(e,{resolution:2,scaleMode:N__namespace.SCALE_MODES.LINEAR,multisample:N__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀlk=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀkq=t,this.pixiSprite=new N__namespace.Sprite(M.getAsset(t.id)),this.ƀir.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgu?.destroy(),this.ƀak?.destroy(),this.ƀkq.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀkq.id),this.ƀis&&M.destroyAsset(this.ƀis.texture.id)),this.ƀis&&!this.ƀis.destroyed&&this.ƀis.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀlk}set textureScale(t){this.ƀlk=t,this.pixiSprite.scale.set(t);}get size(){return new helpersLib.Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀkq.boundingShapes&&!this.ƀir.hitArea&&(this.ƀir.hitArea=new ls(this.ƀkq.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀkq.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===N__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=N__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=N__namespace.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new N__namespace.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀis)return this.ƀis.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀis)this.ƀis.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀkq.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀis&&(this.ƀis.destroy(),this.ƀis=void 0),t&&(this.ƀis=Jt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀkq.destroyAssetOnDestroy),this.ƀis.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀis.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.ƀir.addChild(this.ƀis)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbw().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgu){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgu=this.ƀbw(),this.ƀgu.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgu.pixiSprite.renderable=false,this.ƀgu.displayParent(this);}return this.ƀgu}ƀbw(){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀkq.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=g.instance.renderer.extract.canvas(this.ƀir);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}},ls=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀkg=t.map(r=>new N__namespace.Polygon(r.map(s=>new N__namespace.Point(s.x,s.y))));}contains(t,e){return this.ƀkg.some(i=>i.contains(t,e))}};var Re=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=helpersLib.Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,y=Math.floor(c/p),w=c-p*y;y>=1&&w<i.dashLength&&(w+=p,y--);let A=s.normalize(w/2),Tt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(A)}),l=l.add(A),y>0){let pe=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(y).forEach(()=>{l=l.add(Tt),a.push({from:l,to:l.add(pe)}),l=l.add(pe);});}return l=l.add(Tt),a.push({from:l,to:l.add(A)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcx=new Map;}static createArrow(t,e){let i=new N__namespace.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new N__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:helpersLib.ColorHelper.white,...i},s=new N__namespace.Graphics;return s.lineStyle(r.width,r.color),Re.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new N__namespace.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(helpersLib.ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new N__namespace.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=helpersLib.ColorHelper.white){let i=new N__namespace.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new N__namespace.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new N__namespace.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new N__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new N__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new N__namespace.Graphics,s=new helpersLib.Radian(helpersLib.PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.ƀir.addChild(t),this.pixiGraphics=t,this.ƀan=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀan,cache:false,...t},i=this.ƀes(e.cacheName,e.cache),r={id:i.textureID,scale:1,size:i.bounds,anchor:{x:0,y:0},destroyAssetOnDestroy:!e.cache},s=new k(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀes(t,e){if(e){let i=o.ƀcx.get(t);return i||(i=this.ƀci(),o.ƀcx.set(t,i)),i}else return this.ƀci()}ƀci(){let t=g.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {textureID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var si=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},xt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcx=new Map;}constructor(t,e,i,r=exports.ScrollDirection.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===exports.ScrollDirection.Horizontal?this.ƀcc(e,i,s):this.ƀcj(e,i,s),this.ƀgu=k.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgu);}ƀcj(t,e,i){e>0&&this.ƀbz(new helpersLib.Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x,t.y-e*2),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀcc(t,e,i){e>0&&this.ƀbz(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(0,t.y),{round:false}).setRotation(helpersLib.Radian.get270).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x-e*2,t.y),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbz(t){let i={id:this.ƀca(t.y),scale:1,size:t,anchor:{x:0,y:0}};return new k(i,{textureSize:t,ignoreAnchor:true})}ƀca(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcx.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new si;helpersLib.ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=N__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcx.set(e,i);}else throw new Error("Canvas context is null")}return i}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var Ie=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}onStateChange(t){return this.ƀhs.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀhu.subscribe(e=>t(e.value,e.index)).attach(this),this}get state(){return {value:this.ƀky.state.value,item:this.ƀfv,nextItem:this.ƀhj,queuedItem:this.ƀky.state.queuedItem,animationState:this.ƀo}}constructor(t){super(),this.ƀo="idle",this.ƀhs=new actionsLib.Action,this.ƀhu=new actionsLib.Action,this.ƀhx={duration:500,animation:x.easeInOutCubic,...t},this.ƀky=new Dt({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((e,i)=>this.ƀfb(e,i)).onValueChange(e=>this.ƀfg(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfv===void 0?(this.ƀfv=t,this.ƀhs.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀky.setItem(t,e)):this.ƀfv!==t?this.ƀhj!==t?this.ƀo==="idle"?(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀhj=t,this.ƀhs.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀhj}),this.ƀky.setItem(t,e)):this.ƀky.setItem(t,e):this.ƀo==="reverting"&&this.ƀhj===t&&(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀky.setItem(t,e)):(this.ƀo==="transitionForward"||this.ƀo==="transitionBackward")&&(this.ƀo="reverting",this.ƀky.setItem(t,e));}ƀfb(t,e){switch(this.ƀfv!==void 0&&this.ƀfv!==t&&this.ƀfv!==e&&this.ƀhs.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhj!==t&&this.ƀhj!==e&&this.ƀhs.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀhj}),e!==void 0&&e!==this.ƀfv&&e!==this.ƀhj&&this.ƀhs.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀo){case "idle":break;case "transitionForward":case "transitionBackward":e===void 0?(this.ƀo="idle",this.ƀfv=this.ƀhj,this.ƀhj=void 0):this.ƀfv!==t&&this.ƀfc(t,e);break;case "reverting":e===void 0?(this.ƀo="idle",this.ƀhj=void 0):this.ƀfv!==e&&this.ƀfc(t,e);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀfc(t,e){this.ƀfv=t,this.ƀhj=e,this.ƀhu.trigger({value:0,index:this.ƀfv}),this.ƀo=this.ƀfv<this.ƀhj?"transitionForward":"transitionBackward";}ƀfg(t){let e=1;(this.ƀo==="transitionBackward"||this.ƀo==="reverting"&&this.ƀfv!==void 0&&this.ƀhj!==void 0&&this.ƀfv>this.ƀhj)&&(e=-1),(this.ƀo==="idle"||t!==0)&&this.ƀhu.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhu.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀhj});}};exports.ScrollDirection=void 0;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(exports.ScrollDirection||(exports.ScrollDirection={}));var oi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀby=t,this.ƀcs="x",this.ƀbo=new Map,this.ƀhx={duration:300,animation:x.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀhx.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀhx.size.x+this.ƀhx.margin*2,this.ƀhx.size.y):new helpersLib.Vector(this.ƀhx.size.x,this.ƀhx.size.y+this.ƀhx.margin*2),r=new u().setPosition(this.ƀhx.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀhx.margin,0):new helpersLib.Vector(0,-this.ƀhx.margin),{round:false}).displayParent(this).attach(this);this.ƀcd(i,this.ƀhx.margin,this.ƀhx.direction,r),this.ƀcs=this.ƀhx.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀky=new Ie({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbo.set(n,a),this.ƀby({index:n,container:a});}else {let a=this.ƀbo.get(n);a&&(a.destroy(),this.ƀbo.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbo.get(n);if(a){let l={x:0,y:0};l[this.ƀcs]=i[this.ƀcs]*s+this.ƀhx.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀky.setIndex(t,e),this}ƀcd(t,e,i,r){new xt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},Ji=class extends oi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var bt=class{static{h(this,"VectorSet");}constructor(){this.ƀlx=new Map;}add(t){let e=this.ƀlx.get(t.x);e||(e=new Set,this.ƀlx.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀlx.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀlx.get(t.x);return e?e.delete(t.y):false}};var ni=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var G=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new helpersLib.Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new helpersLib.Vector(.5,.5)).multiplyNumber(e)}};var Xt=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new helpersLib.Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=G.areaToGridArea(e,i);if(this.ƀau(t,s))return helpersLib.Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=helpersLib.Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=helpersLib.Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new helpersLib.Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new bt,s=new helpersLib.Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new helpersLib.Rectangle(n,n.add(i));if(this.ƀau(t,a))return helpersLib.Vector.fromTo(e,n);t.getNeighborPositions(n,helpersLib.GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀau(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new helpersLib.Vector(r,i)))return false;return true}};var Yi=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return helpersLib.Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},Rs=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀfa=t,this.ƀkv=e,this.ƀhw=new helpersLib.BinaryHeap("min"),this.ƀba=[],this.ƀhl=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new Yi(this.ƀkv,0,Number.MAX_SAFE_INTEGER);this.ƀhw.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀhw.size>0}getNeighbors(t,e){return this.ƀfa.getNeighborPositions(t.position,e).filter(i=>this.ƀfa.get(i)).map(i=>this.ƀhl.get(i)||this.ƀce(i))}popLowestPathCostNode(){let t=this.ƀhw.pop();return this.ƀhw.delete(t),t.closed=true,this.ƀba.push(t),t}changeNodeCost(t,e,i,r){this.ƀhw.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀhw.add(t.pathLength,t);}getBestClosedNode(){return this.ƀba.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀce(t){let e=new Yi(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀhl.set(t,e),this.ƀhw.add(e.pathLength,e),e}},Kt=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new Rs(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var Zt=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀle=t,this.ƀy=e,this.ƀfj=this.ƀei(this.ƀy.size),this.ƀmg=new helpersLib.Grid({size:this.ƀy.size,defaultValue:this.ƀfj}),this.ƀct=new helpersLib.Grid({size:this.ƀy.size,defaultValue:void 0});let i=new bt,r=new helpersLib.Queue;for(this.ƀdv(this.ƀy.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀmg.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀmg.getOrFail(n);this.ƀen(n,this.ƀy).forEach(l=>{if(!i.has(l.position)){let c=this.ƀmg.getOrFail(l.position),p=a+l.distance;this.ƀy.getOrFail(l.position)&&p<c&&(this.ƀmg.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀle)){if(t=this.ƀmg.movePositionInsideGrid(t),this.ƀct.has(t))return this.ƀct.get(t);{let e=this.ƀen(t,this.ƀy),i;return this.ƀmg.getOrFail(t)>=this.ƀfj?e.some(s=>this.ƀy.get(s.position))&&(e.some(n=>!this.ƀy.get(n.position))?i=this.ƀec(e):i=this.ƀdx(t,e)):i=this.ƀdx(t,e),this.ƀct.set(t,i),i}}}ƀec(t){let e=t.filter(i=>this.ƀy.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdx(t,e){let i=e.filter(r=>this.ƀmg.getOrFail(r.position)<this.ƀfj).reduce((r,s)=>{let n=this.ƀmg.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀfj}).bestDirections;return this.ƀet(i,t)}ƀet(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀgb(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀgb(t,e){let i=t.add(this.ƀly(e));return this.ƀy.isPointWithinBounds(i)&&this.ƀy.getOrFail(i)}ƀen(t,e){return this.ƀmg.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdv(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new helpersLib.Vector(r,i));return e}ƀly(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀei(t){return (t.x+t.y)*20}};var P=class o{static{h(this,"AudioAssets");}static{this.ƀam=new Map;}static{this.context=new AudioContext;}static async load(t){await Promise.all(t.map(e=>fetch(e.url).then(i=>i.arrayBuffer()).then(i=>this.context.decodeAudioData(i)).then(i=>this.ƀam.set(e.id,i))));}static createSource(t){let e=o.ƀdw(t),i=o.context.createBufferSource();return i.buffer=e,i}static ƀdw(t){let e=this.ƀam.get(t);if(!e)throw new Error(`Audio: Sound with id ${t} was not loaded.`);return e}};R.onHardReset.subscribe(()=>{P.context=new AudioContext,P.ƀam.clear();}).attachToRoot();var Y=800,J=class o{static{h(this,"Audio");}static ƀka(){return this.ƀfy=new o,this.ƀfy}constructor(){this.ƀgx=P.context.createGain(),this.ƀgw=P.context.createGain(),this.ƀhi=P.context.createGain(),this.ƀkj=P.context.createGain(),this.ƀgx.connect(P.context.destination),this.ƀgw.connect(this.ƀgx),this.ƀhi.connect(this.ƀgw),this.ƀkj.connect(this.ƀgw),this.ƀgy=new I(this.ƀgx.gain,"value",{duration:500*2,animation:x.easeIn,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀgy.set({value:0});}setVolumes(t){this.ƀgw.gain.value=t.master,this.ƀhi.gain.value=t.music,this.ƀkj.gain.value=t.sound;}appear(t,e="ease"){switch(e){case "ease":return this.ƀgy.set({value:t?0:1}),this.ƀgy.animate({value:t?1:0}).chainToRoot();case "instant":return this.ƀgy.set({value:t?1:0}),actionsLib.SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}};R.onHardReset.subscribe(()=>{J.ƀka();}).attachToRoot();var Ms=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s};exports.CameraGateway=class st extends q(){static{h(this,"CameraGateway");}};exports.CameraGateway=Ms([d()],exports.CameraGateway);var Bs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Pt=class extends q(){static{h(this,"CameraViewGateway");}};Pt=Bs([d()],Pt);var Ki;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Ki||(Ki={}));exports.FocusingAnimation=void 0;(function(o){o[o.Instant=1]="Instant",o[o.EaseInOut=2]="EaseInOut",o[o.EaseOut=3]="EaseOut";})(exports.FocusingAnimation||(exports.FocusingAnimation={}));var hi=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀit=new N__namespace.Graphics,this.ƀit.beginFill(0,1e-9),this.ƀit.drawRect(0,0,t.x,t.y),this.ƀit.endFill(),this.ƀir.addChild(this.ƀit);}destroy(){this.destroyed||(super.destroy(),this.ƀit.destroy());}};var Bt=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:helpersLib.ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:helpersLib.Radian.get60,distance:10,color:helpersLib.ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:helpersLib.ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return helpersLib.JsonHelper.removeUndefinedProperties({fontFamily:e.fontFamily,fill:helpersLib.ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r})}};var Ce=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=scriptEngineLib.RichTextSeparator.process(t,i),s=this.ƀfu(r,e),n=this.ƀs(s);return this.ƀko(n)}static ƀfu(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Bt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀea(a.tags,e,i),p=s(l,c),y=N__namespace.TextMetrics.measureText(" ",new N__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:y.width}})}static ƀea(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbf(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbf(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀko(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀkp(s.text).map(a=>{let l=new N__namespace.TextStyle(s.pixiStyle),c=N__namespace.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀkp(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcm.length===0}get remainingWidth(){return this.ƀmh-this.ƀcp}constructor(t,e){this.ƀmh=t,this.ƀgm=[],this.ƀcm=[],this.ƀcp=0,this.ƀgl=new helpersLib.Vector(0,0),this.ƀcn=0;let i={rectangleCutOption:void 0,horizontalAlignment:"left",verticalAlignment:"bottom",...e};if(this.ƀfm=i.horizontalAlignment,this.ƀlz=i.verticalAlignment,i.rectangleCutOption){if(i.rectangleCutOption.position.x<0||i.rectangleCutOption.position.x>=this.ƀmh||i.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcq={direction:i.rectangleCutOption.direction,rectangle:this.ƀbs(i.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcn,t.y),i=this.ƀej(this.ƀgl.y,this.ƀgl.y+e);return this.ƀcp+t.x<=i}insertWord(t){let e=Math.max(this.ƀcn,t.style.height);if(this.ƀcm.length===0){let i=this.ƀek(this.ƀgl.y,this.ƀgl.y+e);this.ƀgl=new helpersLib.Vector(i,this.ƀgl.y),this.ƀcp=this.ƀgl.x;}this.ƀcm.push({chunk:t,position:new helpersLib.Vector(this.ƀcp,this.ƀgl.y)}),this.ƀcn=e,this.ƀcp+=t.style.width;}newLine(){let t=this.ƀgl.y+this.ƀcn,e=this.ƀek(t,t);this.ƀdn(),this.ƀgl=new helpersLib.Vector(e,t),this.ƀcp=this.ƀgl.x,this.ƀcn=0;}print(){return this.ƀdn(),this.ƀgm}ƀdn(){this.ƀcm.length>0&&(this.ƀgm.push(this.ƀg(this.ƀcm)),this.ƀcm=[]);}ƀg(t){return t=this.ƀmb(t),t=this.ƀfo(t),t}ƀfo(t){if(this.ƀfm==="left")return t;let e=this.ƀgl.y+this.ƀcn,i=this.ƀek(this.ƀgl.y,e),s=this.ƀej(this.ƀgl.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀfm==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new helpersLib.Vector(l.position.x+a,l.position.y)},l))}ƀmb(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀlz){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀlz;throw new Error(`Unexpected case! "${this.ƀlz}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀek(t,e){return this.ƀcq&&(this.ƀcq.direction==="topLeft"||this.ƀcq.direction==="bottomLeft")&&(this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀcq.rectangle.bottomRight.x:0}ƀej(t,e){return this.ƀcq&&(this.ƀcq.direction==="topRight"||this.ƀcq.direction==="bottomRight")&&(this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(this.ƀmh,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new helpersLib.Vector(this.ƀmh,e),{includeEdges:false}))?this.ƀcq.rectangle.topLeft.x:this.ƀmh}ƀbs(t){let e,i;switch(t.direction){case "topRight":e=new helpersLib.Vector(t.position.x,-1/0),i=new helpersLib.Vector(1/0,t.position.y);break;case "topLeft":e=new helpersLib.Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new helpersLib.Vector(1/0,1/0);break;case "bottomLeft":e=new helpersLib.Vector(-1/0,t.position.y),i=new helpersLib.Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new helpersLib.Rectangle(e,i)}};var De=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new helpersLib.Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new helpersLib.Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀmi(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀmi(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀmi(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀhc(t),t=this.ƀlp(t),this.ƀaw(t)}static ƀhc(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀlp(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀaw(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ce.process(t,e),r=helpersLib.JsonHelper.removeUndefinedProperties({rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=new Oe(e.default.wordWrapWidth??1/0,r),n=De.wrapText(i,s);return Me.process(n)}};var js=1,Qi=1/js,Qt=class extends u{static{h(this,"Text");}get ƀli(){if(!this.ƀlj){let t=new N__namespace.TextStyle(this.ƀiv);this.ƀlj=N__namespace.TextMetrics.measureText(this.ƀlh,t);}return this.ƀlj}get ascent(){return this.ƀli.fontProperties.ascent}constructor(t,e){super(),this.ƀiv=Bt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀiu.destroyed&&this.ƀiu.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀiu.anchor.x,this.ƀiu.anchor.y)}set anchor(t){this.ƀi=t,this.ƀiu.anchor.set(t.x,t.y);}setText(t){return this.ƀlh!==t&&(this.ƀlh=t,this.ƀjf()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀiv.fill!==e&&(this.ƀiv.fill=e,this.ƀjf()),this}ƀjf(){this.ƀiu?.destroy(),this.ƀlc?.destroy(),this.ƀlc=void 0,this.ƀlj=void 0;let t=new N__namespace.TextStyle(this.ƀiv);this.ƀiu=new N__namespace.Text(this.ƀlh,t),this.ƀji(),this.ƀi&&this.ƀiu.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀiu.scale.set(Qi,Qi),this.ƀir.addChild(this.ƀiu),this.ƀiv.lineThrough&&(this.ƀlc=this.ƀe(this.ƀiu,this.ƀiv.fill),this.ƀir.addChild(this.ƀlc));}ƀji(){let t=N__namespace.TextMetrics.measureText(this.ƀlh,new N__namespace.TextStyle({...this.ƀiv,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀiu.calculateBounds=function(){this.updateText(true),this._bounds.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this._bounds.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=N__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new N__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=N__namespace.TextMetrics.measureText(l,t.style),y=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,w=0;t.style.align==="center"?w=0+(t.width-p.width)*.5:t.style.align==="right"&&(w=0+t.width-p.width),w=Math.floor(w),n.moveTo(Math.floor(w),y),n.lineTo(Math.floor(w+p.width),y),a+=p.lineHeight;}),n.endFill(),n}};var li=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new Qt(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var Us=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},F=class extends gt{static{h(this,"CameraEntity");}constructor(){super(...arguments),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.offset=new actionsLib.Variable(helpersLib.Vector.zero),this.targetPosition=new actionsLib.Variable(void 0),this.focusingNewTargetInfo=new actionsLib.Variable(void 0);}};F=Us([yt()],F);var Ge=class{static{h(this,"PositionConversionHelper");}static includeScaleInScreenPosition(t,e,i){if(e!==1){let r=helpersLib.Vector.fromTo(i,t).multiplyNumber(1/e);return i.add(r)}else return t}};var $s=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Et=class extends mt{static{h(this,"CameraView");}constructor(t){super(),this.ƀdd=t,this.ƀkr=(()=>{let e=new u().attach(this);return e.ƀir=g.instance.ƀiq.stage,e})(),this.ƀjm=new u().setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀae=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀac=new u().displayParent(this.ƀjm).attach(this),this.ƀar=new u().displayParent(this.ƀjm).attach(this),this.ƀdq=new u().setSortableChildren(true).displayParent(this.ƀjm).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdp=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgs=new u().setSortableChildren(true).setZIndex(10).displayParent(this.ƀaq).attach(this),this.ƀab=new u().setZIndex(0).displayParent(this.ƀaq).attach(this),this.ƀh=new I(this.ƀjm,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaf=new I(this.ƀae,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),g.instance.screenSize.subscribe(e=>{this.ƀae.aspectRatio=e.x/e.y,this.ƀae.scale=Math.max(e.x,e.y),this.ƀae.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.zero});}).attach(this),this.ƀdd.position.subscribe(e=>{this.ƀaq.position=this.ƀbt(e);}).attach(this),this.ƀdd.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:0});}screenPositonToStagePosition(t){let e=Ge.includeScaleInScreenPosition(t,this.ƀkr.scale,g.instance.screenSizeCenter.value);return new helpersLib.Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgs.id,foreground:this.ƀdp.id,foregroundScreen:this.ƀdq.id}}appear(t,e,i){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),actionsLib.SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀh.animate({alpha:t?1:0})).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),actionsLib.SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀaf.animate({alpha:t?0:1})).chain(this);case "instant":return this.ƀh.set({alpha:t?1:0}),this.ƀaf.set({alpha:t?0:1}),actionsLib.SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}ƀbt(t){return helpersLib.Vector.fromTo(t,g.instance.screenSizeCenter.value)}};Et=$s([Qe({entity:F}),zs("design:paramtypes",[F])],Et);var Js=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ys=1500,_e=class{static{h(this,"CameraService");}createCamera(){return new F().attachToRoot()}getCameraPosition(){let t=F.getInstanceOrFail();return helpersLib.Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=F.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=F.getInstanceOrFail();e.focusingNewTargetInfo.value={time:g.time,duration:t?.duration??Ys,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??exports.FocusingAnimation.Instant};}update(t,e){let i=F.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀgf(i,r,t):i.position.value=r);}ƀgf(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===exports.FocusingAnimation.Instant)this.ƀbg(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbg(t,e);else {let n;r.focusingAnimation===exports.FocusingAnimation.EaseInOut?n=V.easeInOut(s):r.focusingAnimation===exports.FocusingAnimation.EaseOut?n=V.easeOut(s):n=1;let a=r.position.lerp(e,n);r.roundPosition&&(Math.abs(a.x-r.position.x)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(Math.round(a.x),a.y)),Math.abs(a.y-r.position.y)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(a.x,Math.round(a.y)))),t.position.value=a;}}}ƀbg(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};_e=Js([d()],_e);var Xs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ks=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},di=class{static{h(this,"CameraController");}constructor(t){this.ƀas=t;}createCamera(){return this.ƀas.createCamera().id}update(t,e){this.ƀas.update(t,e);}setPosition(t){this.ƀas.setPosition(t);}setTransition(t){this.ƀas.setTransition(t);}getCameraPosition(){return this.ƀas.getCameraPosition()}};di=Xs([Q(exports.CameraGateway),Ks("design:paramtypes",[_e])],di);var Zs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ui=class{static{h(this,"CameraViewController");}getLayers(){let t=F.getInstanceOrFail().id;return Et.getInstanceOrFail(t).getLayers()}appear(t,e,i){let r=F.getInstanceOrFail().id;return Et.getInstanceOrFail(r).appear(t,e,i)}screenPositonToStagePosition(t){let e=F.getInstanceOrFail().id;return Et.getInstanceOrFail(e).screenPositonToStagePosition(t)}};ui=Zs([Q(Pt)],ui);var ee=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=S.get(exports.CameraGateway),this.ƀat=S.get(Pt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha",i=0){return this.ƀat.appear(t,e,i)}screenPositonToStagePosition(t){return this.ƀat.screenPositonToStagePosition(t)}};var g=class o{static{h(this,"Game");}static get instance(){return this.ƀfy}static{this.pause=actionsLib.Reducer.createOr();}static{this.freeze=actionsLib.Reducer.createOr();}static get camera(){return this.ƀao}static get audio(){return this.ƀx}static appear(t,e){let i=e?.audio??"ease",r=e?.camera??"alpha";return actionsLib.ActionLib.all([this.audio.appear(t,i),this.camera.appear(t,r,i!=="instant"?0:500)]).mapToVoid().chainToRoot()}static get time(){return m.ƀll}static get setupOptions(){return this.ƀkd}constructor(t){if(this.ƀjp=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSize=this.ƀjp.notifier,this.ƀjq=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSizeCenter=this.ƀjq.notifier,this.devMode=false,o.ƀfy)throw new Error("There can be only one Game instance!");this.ƀbk={screenResolution:void 0,maxScreenResolution:void 0,devMode:false,backgroundColor:helpersLib.ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbk.devMode||false;let e=helpersLib.JsonHelper.removeUndefinedProperties({backgroundColor:this.ƀbk.backgroundColor,autoStart:false,antialias:this.ƀbk.antialias,resolution:this.ƀbk.resolution,width:this.ƀbk.screenResolution?.width,height:this.ƀbk.screenResolution?.height});this.ƀiq=new N__namespace.Application(e);let i=o.pause.effect(false).attachToRoot();o.freeze.subscribe(r=>{i.update(r),r?P.context.suspend():P.context.resume();}).attachToRoot();}async setup(t){o.ƀkd=t;let e=document.body.appendChild(this.ƀiq.view);this.ƀjz(e),await Promise.all([M.loadGameAssets(t.spriteAssetDefinitions),M.loadGameAssets(t.fontAssetDefinitions),P.load(t.soundAssetDefinitions)]),o.ƀfy=this,this.renderer=this.ƀiq.renderer,globalThis.ƀa=this.ƀiq,this.ƀfe(),o.ƀao=new ee,o.ƀx=J.ƀka(),this.ƀiq.start(),this.ƀiq.ticker.add(()=>{o.freeze.value||m.triggerUpdateTick(this.ƀiq.ticker.deltaMS);});}setResolution(t){if(this.ƀiq.renderer.resolution!==t){this.ƀiq.renderer.resolution=t;let e=this.ƀer();this.ƀiq.renderer.resize(e.x,e.y);}}ƀfe(){this.ƀdb(),this.ƀjy(),window.addEventListener("resize",t=>{this.ƀdb(),this.ƀjy();});}ƀdb(){let t=this.ƀer();(t.x!==this.ƀiq.screen.width||t.y!==this.ƀiq.screen.height)&&this.ƀiq.renderer.resize(t.x,t.y);}ƀjy(){let t=new helpersLib.Vector(this.ƀiq.screen.width,this.ƀiq.screen.height);this.ƀjp.value=t,this.ƀjq.value=t.multiplyNumber(.5).round();}ƀer(){let t=this.ƀbk.screenResolution?.width??window.innerWidth,e=this.ƀbk.screenResolution?.height??window.innerHeight;return this.ƀbk.maxScreenResolution&&(t=Math.min(t,this.ƀbk.maxScreenResolution.width),e=Math.min(e,this.ƀbk.maxScreenResolution.height)),new helpersLib.Vector(t,e)}ƀjz(t){this.ƀbk.maxScreenResolution&&(t.style.maxWidth=`${this.ƀbk.maxScreenResolution?.width}px`,t.style.maxHeight=`${this.ƀbk.maxScreenResolution?.height}px`),t.style.width="100%",t.style.height="100%";}};var ie=class o extends actionsLib.IDAttachable{static{h(this,"Sound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`Sound: Could not find sound definition with name ${t}.`);return new o(i,e)}get volume(){return this.ƀdr.gain.value}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀdr.gain.value=t,this}constructor(t,e){super(),this.ƀkk=t,this.ƀdr=P.context.createGain(),this.ƀdr.connect(J.ƀfy.ƀkj),this.ƀfi=this.ƀdr,e?.volume!==void 0&&(this.volume=e.volume),this.ƀiw(e?.time??0);}destroy(){this.destroyed||(super.destroy(),this.ƀla(),this.ƀdr?.disconnect());}ƀlv(){this.ƀfi.disconnect(),this.ƀfi.connect(J.ƀfy.ƀhi);}ƀiw(t){this.ƀla();let e=this.ƀkk.loop;if(this.ƀkt=helpersLib.NumberHelper.clamp(t,0,e?e.to:this.ƀkk.duration),e){let i=e.from,r=e.to;this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:this.ƀkt<i?i:r,loop:false,onComplete:h(()=>{this.ƀkn.disconnect(),this.ƀix({soundID:this.ƀkk.id,start:i,end:r,loop:true});},"onComplete")});}else this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:void 0,loop:false,onComplete:h(()=>this.destroy(),"onComplete")});}ƀla(){this.ƀkn&&(this.ƀkn.onended=null,this.ƀkn.stop(),this.ƀkn.disconnect());}ƀix(t){this.ƀkn=P.createSource(t.soundID),this.ƀkn.connect(this.ƀdr),t.onComplete&&(this.ƀkn.onended=t.onComplete),t.loop?(this.ƀkn.loop=true,this.ƀkn.loopStart=t.start,this.ƀkn.loopEnd=t.end??this.ƀkn.buffer.duration,this.ƀkn.start(0,t.start)):this.ƀkn.start(0,t.start,t.end?t.end-t.start:void 0);}};var so=800,re=-128,nt=class o extends ie{static{h(this,"AdvancedSound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}constructor(t,e){super(t,e),this.ƀll=new actionsLib.Variable(0),this.time=this.ƀll.notifier,this.ƀkw=P.context.currentTime-this.ƀkt,this.ƀll.value=this.ƀkt,m.beforeSceneUpdateAction.subscribe(()=>{this.ƀll.value=P.context.currentTime-this.ƀkw;}).attach(this),this.ƀfi.disconnect(),this.ƀkb(e?.fade?helpersLib.NumberHelper.clamp(e.fade,0,1):0),this.ƀkc(e?.muffle?helpersLib.NumberHelper.clamp(e.muffle,0,1):0),this.ƀfi.connect(J.ƀfy.ƀkj);}ƀkb(t=0){this.ƀdk=P.context.createGain(),this.ƀdk.gain.value=1-t,this.ƀdj=new I(this.ƀdk.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀfi.connect(this.ƀdk),this.ƀfi=this.ƀdk;}ƀkc(t=0){this.ƀhg=P.context.createBiquadFilter(),this.ƀhg.type="highshelf",this.ƀhg.frequency.value=so,this.ƀhg.gain.value=t*re,this.ƀhh=new I(this.ƀhg.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀfi.connect(this.ƀhg),this.ƀfi=this.ƀhg;}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.fade(1,Y).notIdle().chain(this).tap(()=>this.destroy()).chainToRoot())}notifyOnTime(t){return this.time.value>t?actionsLib.SingleEvent.createDestroyed():actionsLib.SingleEvent.create(e=>{let i=this.time.filter(r=>r>=t).tap(()=>e()).attach(this);return ()=>i.destroy()})}setFade(t){t=helpersLib.NumberHelper.clamp(t,0,1),this.ƀdj.set({value:1-t});}fade(t,e=500){t=helpersLib.NumberHelper.clamp(t,0,1);let i=t>1-this.ƀdk.gain.value;return e===0?(this.ƀdj.set({value:1-t}),actionsLib.SingleEvent.instant()):this.ƀdj.animate({value:1-t},{duration:e,animation:i?x.easeOut:x.easeIn}).chain(this)}setMuffle(t){t=helpersLib.NumberHelper.clamp(t,0,1),this.ƀhh.set({value:t*re});}muffle(t,e=500){t=helpersLib.NumberHelper.clamp(t,0,1);let i=t>this.ƀhg.gain.value/re;return e===0?(this.ƀhh.set({value:t*re}),actionsLib.SingleEvent.instant()):this.ƀhh.animate({value:t*re},{duration:e,animation:i?x.easeIn:x.easeOut}).chain(this)}destroy(){this.destroyed||(this.ƀdk.disconnect(),this.ƀhg.disconnect()),super.destroy();}};var se=class o extends actionsLib.IDAttachable{static{h(this,"Music");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}get time(){switch(this.ƀkm.value.type){case "paused":return this.ƀkm.value.value.time;case "playing":return this.ƀkm.value.value.time.value;default:{this.ƀkm.value;throw new Error(`Unexpected case! "${this.ƀkm.value}"`)}}}get volume(){return this.ƀkm.value.value.volume}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀkm.value.value.volume=t,this}constructor(t,e){super(),this.ƀhx={stopPlayingOnPause:true,...e},this.ƀkl=t.id;let i;if(this.ƀhx.stopPlayingOnPause&&g.pause.value)i={type:"paused",value:{time:0,volume:1}};else {let r=new nt(t,this.ƀhx).attach(this);r.ƀlv(),i={type:"playing",value:r};}this.ƀkm=new actionsLib.Variable(i),this.ƀhx.stopPlayingOnPause&&(this.ƀid=g.pause.subscribe(r=>this.ƀfd(r)).attach(this));}notifyOnTime(t){return actionsLib.SingleEvent.create(e=>{let i=this.ƀkm.asyncMapDropOngoing((r,s)=>{switch(r.type){case "paused":s.drop();break;case "playing":return r.value.notifyOnTime(t);default:{throw new Error(`Unexpected case! "${r}"`)}}}).toSingleEvent().tap(()=>e()).attach(this);return ()=>i.destroy()})}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),actionsLib.SingleEvent.instant().asyncTap(()=>actionsLib.ActionLib.all([this.ƀkm.value.type==="playing"?this.ƀkm.value.value.close():actionsLib.SingleEvent.instant(),this.ƀdl?.onDestroy()??actionsLib.SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀfd(t){if(t){if(this.ƀkm.value.type==="playing"){let e=this.ƀkm.value.value;this.ƀkm.value={type:"paused",value:{time:e.time.value,volume:e.volume}},this.ƀdl=e,actionsLib.ActionLib.all([e.fade(1,Y),e.muffle(1,Y)]).tap(()=>{this.ƀdl=void 0,e.destroy();}).attach(this);}}else if(this.ƀkm.value.type==="paused"){let{volume:e,time:i}=this.ƀkm.value.value,r=nt.createByName(this.ƀkl,{volume:e,time:i,fade:1,muffle:1}).attach(this);r.ƀlv(),actionsLib.ActionLib.all([r.fade(0,Y),r.muffle(0,Y)]).attach(this),this.ƀkm.value={type:"playing",value:r};}}};var mi=class extends actionsLib.IDAttachable{static{h(this,"MusicPlayer");}get time(){return this.ƀiy?this.ƀiy.time:0}get volume(){return this.ƀmf}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀmf=t,this.ƀiy&&(this.ƀiy.volume=t),this.ƀic&&(this.ƀic.volume=t),this}constructor(t){super(),this.ƀmf=1,this.ƀhx={stopPlayingOnPause:true,playWhenPaused:void 0,volume:1,...t},this.ƀmf=this.ƀhx.volume,this.ƀhx.playWhenPaused&&this.ƀke(this.ƀhx.playWhenPaused);}play(t){if(this.ƀbb)throw new Error("Play is called while music player is destroyed.");return this.ƀco=t,actionsLib.SingleEvent.instant().asyncTap(()=>{let e=this.ƀiy;if(e)return this.ƀiy=void 0,e.close()}).map(()=>{if(this.ƀco===t)return this.ƀiy=se.createByName(t,{stopPlayingOnPause:this.ƀhx.stopPlayingOnPause,volume:this.ƀmf}).attach(this),this.ƀiy}).chain(this)}stop(){return actionsLib.SingleEvent.instant().asyncTap(()=>{let t=this.ƀiy;if(t)return t.close().tap(()=>{t===this.ƀiy&&(this.ƀiy=void 0);})}).chain(this)}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),actionsLib.SingleEvent.instant().asyncTap(()=>actionsLib.ActionLib.all([this.ƀiy?.close()??actionsLib.SingleEvent.instant(),this.ƀic?.close()??actionsLib.SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀke(t){this.ƀid=g.pause.toSequence().asyncMapDropOngoing(e=>e&&m.wait(Y).map(()=>e)).tap(e=>{if(e)this.ƀic=nt.createByName(t,{fade:1,volume:this.ƀmf}).attach(this),this.ƀic.fade(0);else if(this.ƀic){let i=this.ƀic;this.ƀic.fade(1).tap(()=>i.destroy()).attach(this),this.ƀic=void 0;}}).attach(this);}};var yi=class extends u{static{h(this,"UpdatableContainer");}},gi=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀby=t,this.ƀcu=new Map,this.ƀhx={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcu.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhx.trackBy(r,s),a;this.ƀcu.has(n)?(a=this.ƀcu.get(n),e.delete(n),a.update(r)):(a=this.ƀby(r).displayParent(this).attach(this),this.ƀcu.set(n,a)),this.ƀhx.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhx.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhx.positioning.spacing);}),e.forEach(r=>{this.ƀcu.get(r).destroy(),this.ƀcu.delete(r);});}};var ne=class o extends u{static{h(this,"MenuUI");}static{this.ƀga=actionsLib.Reducer.createExistenceChecker();}static{this.isAnyMenuTransitioning=this.ƀga.notifier;}constructor(t,e){super(),this.ƀhp=new actionsLib.SingleAction,this.onCreate=this.ƀhp.notifier,this.ƀhr=new actionsLib.SingleAction,this.onOpen=this.ƀhr.notifier,this.ƀhm=new actionsLib.SingleAction,this.onClose=this.ƀhm.notifier,this.ƀbb=false;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,backgroundDarkeningRatio:.3,...e};this.setAlpha(0),this.ƀp=new I(this,"alpha",{animation:x.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState});let r=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.backgroundDarkeningRatio).setInteractive(true).displayParent(this).attach(this);this.ƀha=k.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),g.instance.screenSize.subscribe(n=>{r.aspectRatio=n.x/n.y,r.scale=Math.max(n.x,n.y),r.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(n.multiplyNumber(.5));}).attach(this),this.ƀhp.resolve();let s=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:1}).chain(this).tap(()=>{this.ƀhr.resolve(),s.destroy(),i.closeOnBackgroundClick&&r.on(exports.ContainerEventType.Click).take(1).tap(()=>this.close()).attach(this);}).attachToRoot();}getBoundingMask(){return this.ƀha.getBoundingMask()}close(){if(!this.ƀbb){this.ƀbb=true;let t=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:0}).chain(this).map(()=>{this.ƀhm.resolve(),t.destroy(),this.destroy();}).chainToRoot();}return this.onClose.toSingleEvent()}};var xi=class extends gt{static{h(this,"MenuEntity");}static subscribeIsOpen(){return actionsLib.ActionLib.merge(this.continuesSubscription().map(t=>t.type==="open"),actionsLib.SingleEvent.instant(this.getInstance()!==void 0))}constructor(t){super(),this.ƀhx=t,queueMicrotask(()=>{if(!this.ƀhb)throw new Error("MenuEntity: MenuEntity has to have a MenuView.")});}ƀjh(t){this.ƀhb=t,this.ƀhb.onClose.subscribe(()=>this.destroy()).attach(this);}onCreate(){return this.ƀhb.onCreate.toSingleEvent()}onOpen(){return this.ƀhb.onOpen.toSingleEvent()}onClose(){return this.ƀhb.onClose.toSingleEvent()}close(){return this.ƀhb.close()}};var vi=class extends mt{static{h(this,"MenuView");}constructor(t,e,i){super();let r=helpersLib.JsonHelper.removeUndefinedProperties({appearAnimationDuration:i.appearAnimationDuration,backgroundDarkeningRatio:i.backgroundDarkeningRatio,closeOnBackgroundClick:t.ƀhx.closeOnBackgroundClick}),s=new ne(e,r).displayParent(g.camera.layers.foregroundScreen).attach(this);t.ƀjh(s);let n=new actionsLib.SingleAction;s.onCreate.subscribe(()=>n.resolve(s)).attach(this),this.onCreate=n.notifier,this.onOpen=s.onOpen.notifier,this.onClose=s.onClose.notifier;}};var go=.65,wo=.01,He=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀjr}get contentSize(){return this.ƀbm.size.ceil()}constructor(t,e,i,r){this.ƀbm=t,this.ƀv=e,this.ƀia=i,this.ƀki=r,this.ƀfx=false,this.ƀjr=e-i*2,this.ƀbm.y=i,this.ƀld=i;}onWheel(t){this.setTarget(this.ƀld-t*go);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀld=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀia-this.contentSize.y,this.ƀia);}jumpToTarget(){this.ƀbm.y=this.ƀld;}update(t){let e=this.contentSize;if(e.y<=this.ƀjr){switch(this.ƀki){case "start":this.ƀld=this.ƀia;break;case "center":this.ƀld=(this.ƀv-e.y)*.5;break;case "end":this.ƀld=this.ƀv-e.y-this.ƀia;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}this.ƀfx||(this.ƀbm.y=this.ƀld);}this.ƀfx=true;let i=this.ƀld-this.ƀbm.y;this.ƀbm.y=this.ƀbm.y+i*wo*t;}};var vo=15,bi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbn}get contentSize(){return this.ƀjs.contentSize}constructor(t,e={}){super();let i={padding:vo,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new xt(r,t,i.padding).attach(this);let s=new N__namespace.Graphics;s.beginFill(0,1e-9),s.drawRect(0,0,t.x,t.y),s.endFill(),r.ƀir.addChild(s);let n=new u().displayParent(r).attach(this);this.ƀjs=new He(n,t.y,i.padding,i.smallContentAlign),this.ƀbn=new helpersLib.Vector(t.x,this.ƀjs.scrollHeight),s.eventMode="dynamic",s.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),n.setInteractive(true),n.ƀir.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),m.afterSceneUpdateAction.subscribe(a=>this.ƀjs.update(a.delta)).attach(this),this.addChildTo=n;}scrollToTop(t){this.ƀjs.scrollToTop(),t?.instant&&this.ƀjs.jumpToTarget();}scrollToBottom(t){this.ƀjs.scrollToBottom(),t?.instant&&this.ƀjs.jumpToTarget();}};var bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class Si{static{h(this,"KeyboardService");}constructor(){this.ƀgh=new actionsLib.Action,this.keyPressed=this.ƀgh.notifier,this.ƀgi=new actionsLib.Action,this.keyReleased=this.ƀgi.notifier,this.ƀgo=new Set,this.ƀgn=new Set,window.addEventListener("keydown",t=>{this.ƀgo.add(t.code),this.ƀgn.add(t.code),!t.repeat&&this.ƀgh.trigger({key:t.key,code:t.code});}),window.addEventListener("keyup",t=>{this.ƀgo.delete(t.code),this.ƀgi.trigger({key:t.key,code:t.code});}),window.addEventListener("blur",()=>{this.ƀgo.clear();}),m.afterSceneUpdateAction.subscribe(()=>this.ƀgn.clear()).attachToRoot();}isKeyDown(t,e){return (e?.onlyPressedThisFrame?this.ƀgn:this.ƀgo).has(t)}};exports.KeyboardService=bo([d(),So("design:paramtypes",[])],exports.KeyboardService);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Eo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class he{static{h(this,"MouseService");}constructor(){this.ƀfw=new actionsLib.Variable(false),this.initialMouseMovementHappened=this.ƀfw.notifier,this.ƀks=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀks.notifier,this.ƀjo=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀjo.notifier,this.ƀgr=new actionsLib.Variable(false),this.mainButtonState=this.ƀgr.notifier,this.ƀjt=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀjt.notifier,this.ƀku(),window.addEventListener("pointerdown",t=>{t.button===0?this.ƀgr.value=true:t.button===2&&(this.ƀjt.value=true);},{capture:true}),window.addEventListener("pointerup",t=>{t.button===0?this.ƀgr.value=false:t.button===2&&(this.ƀjt.value=false);},{capture:true}),window.addEventListener("blur",()=>{this.ƀgr.value=false,this.ƀjt.value=false;},{capture:true});}ƀku(){let t=helpersLib.Vector.zero;window.addEventListener("pointermove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfw.value=true;},{capture:true}),m.beforeSceneUpdateAction.subscribe(()=>{this.ƀjo.value=this.ƀaz(t);}).attachToRoot(),m.afterSceneUpdateAction.subscribe(()=>{let e=g.camera.screenPositonToStagePosition(this.ƀjo.value);e.isEqual(this.ƀks.value)?g.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:t.x,clientY:t.y,pointerType:"mouse"})):this.ƀks.value=e;}).attachToRoot();}ƀaz(t){let i=g.instance.renderer.view.getBoundingClientRect(),r=i.width,s=i.height;if(r<=0||s<=0)return helpersLib.Vector.zero;let n=g.instance.renderer,a=(t.x-i.left)/r*n.screen.width,l=(t.y-i.top)/s*n.screen.height;return a=helpersLib.NumberHelper.clamp(a,0,n.screen.width),l=helpersLib.NumberHelper.clamp(l,0,n.screen.height),new helpersLib.Vector(a,l)}};exports.MouseService=Po([d(),Eo("design:paramtypes",[])],exports.MouseService);var To=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ro=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class Pi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdo}get lastFocusedPosition(){return this.ƀgk}constructor(t){this.ƀhe=t,this.ƀht=new actionsLib.Action,this.onTargetFocus=this.ƀht.notifier,this.ƀln=0,this.ƀlo=false,this.ƀdo=false,this.ƀgk=void 0,m.beforeSceneUpdateAction.subscribe(e=>this.ƀlr(e.delta)).attachToRoot();}ƀlr(t){if(this.ƀhf){let e=this.ƀeq(this.ƀhe.stagePosition.value,this.ƀhf);this.ƀif===void 0?this.ƀif=e:this.ƀav(e,t);}this.ƀhf=this.ƀhe.stagePosition.value;}ƀav(t,e){this.ƀif-t>10?(this.ƀln=Math.max(250,this.ƀln),this.ƀlo=true):this.ƀln>1e3&&(this.ƀlo=true);let i=this.ƀln>=300&&this.ƀlo;this.ƀgg(i,t,e);}ƀgg(t,e,i){(t||e>this.ƀif)&&(this.ƀif=e),t?(this.ƀlo=false,this.ƀln=0,this.ƀdo=true,this.ƀgk=this.ƀhe.stagePosition.value,this.ƀht.trigger(this.ƀgk)):(this.ƀln+=i,this.ƀdo=false);}ƀeq(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=To([d(),Ro("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var Ei=10.8,Ti=10.01;exports.PhysicsShapeType=void 0;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(exports.PhysicsShapeType||(exports.PhysicsShapeType={}));var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return helpersLib.Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new helpersLib.Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new U__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},at=class extends q(){static{h(this,"PhysicsInternalGateway");}};at=Mo([d()],at);var b=class o extends W{static{h(this,"PhysicsEntity");}static{this.ƀhz=new Map;}static{this.ƀij=new Map;}static getFromP2BodyID(t){return o.ƀhz.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhz.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀij.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀij.values())}get area(){return this.ƀu}get mass(){return this.ƀgv}get collisions(){return this.ƀbc}constructor(t,e,i){super(),this.ƀhn=new actionsLib.Action,this.onCollision=this.ƀhn.notifier,this.type="dynamic",this.ƀu=0,this.ƀgv=0,this.ƀbc=[],this.physicsWorldID=t,this.ƀil=S.get(at);let r=this.ƀil.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀil.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀik=this.ƀil.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀim=this.ƀil.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀil.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgv=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀil.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhz.set(this.p2Body.id,this),o.ƀij.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀil.removeBody(this.physicsWorldID,this.p2Body),o.ƀhz.delete(this.p2Body.id),o.ƀij.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀik,this.ƀim,t.ƀik,t.ƀim)}ƀjv(t){this.ƀbc=t,t.length>0&&this.ƀhn.trigger(t);}};var le=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new helpersLib.Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:helpersLib.Vector.zero,rotationalSpeed:0}}};var Ri=class extends W{static{h(this,"MovableEntity");}constructor(){super(),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),m.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀkz(t,e);}).attach(this);}ƀkz(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new helpersLib.Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ii=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),this.ƀfp=false,this.ƀfq=false,this.ƀfs=false,this.ƀfr=false,this.ƀig(),this.ƀgp(),S.get(at).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀkz(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀkz(t,e){this.ƀfp=true,this.ƀfq=true,this.ƀfs=true,this.ƀfr=true,this.ƀig();}ƀig(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new helpersLib.Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀgp(){this.position.subscribe(t=>{this.ƀfp?this.ƀfp=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfq?this.ƀfq=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfs?this.ƀfs=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfr?this.ƀfr=false:this.p2Body.angularVelocity=t;}).attach(this);}};var ht="border";var Fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s};exports.PhysicsGateway=class ce extends q(){static{h(this,"PhysicsGateway");}};exports.PhysicsGateway=Fo([d()],exports.PhysicsGateway);var Vo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},No=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends W{static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new actionsLib.Variable(false),this.lastP2Time=new actionsLib.Variable(0),this.onPhysicsStep=new actionsLib.Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=Vo([yt(),No("design:paramtypes",[helpersLib.Vector,Boolean,U__default.default.World,Map,Map,Map,Map])],v);var Uo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},X=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};X=Uo([d()],X);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},We=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀii=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀii.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};We=Wo([d(),$o("design:paramtypes",[X])],We);var zo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},lt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀii=t,this.ƀz=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀz.getCollidableGrids(t,i).forEach(s=>{let n=G.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=50){return e.aabbNeedsUpdate=true,e.updateAABB(),Xt.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀz.get(t,e,i);return r||(r=this.ƀcb(t,e,i),this.ƀz.set(t,e,i,r)),r}ƀcb(t,e,i){let r=new helpersLib.Grid({size:new helpersLib.Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀii.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀeh(s,e);r.setArea(a,false);}}),r}ƀeh(t,e){let i=f.aabbToBoundingBox(t.aabb);return G.areaToGridArea(i,e)}};lt=zo([d(),ko("design:paramtypes",[X,We])],lt);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Nt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀih=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=50);let n=v.getInstanceByIDOrFail(t),a,l;helpersLib.Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=G.positionToGridPosition(e,s.gridCellSize),p=G.positionToGridPosition(a,s.gridCellSize),y=this.ƀih.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let A=f.aabbToBoundingBox(l.aabb),Tt=G.areaToGridArea(A,s.gridCellSize);y.setArea(Tt,true);}let w=Kt.findPath(y,c,p,s.neighborType);return w.path=w.path.map(A=>G.gridPositionToPosition(A,s.gridCellSize)),w}findPathDirection(t,e,i,r,s=50){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let w=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(w.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=G.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let w=this.ƀih.getAvilabilityGrid(n,s,r);p=new Zt(l,w),n.vectorFieldCache.set(c,p);}let y=G.positionToGridPosition(e,s);return p.getDirectionToTarget(y)}};Nt=Xo([d(),Ko("design:paramtypes",[lt])],Nt);var Qo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},tn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Z=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀaa=t,this.ƀib=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀaa.getAvilabilityGrid(a,n,r).map((c,p)=>({position:G.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀib.findPathDirection(t,c.position,i,r),y;p===void 0?y=T.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):y=T.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new I(y,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>y.destroy()).attach(y);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,helpersLib.ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new I(a,"alpha",{duration:n,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,helpersLib.ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let y=p.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(p.line.from,p.line.to,y).toSprite().displayParent(l).attach(t);}),new I(l,"alpha",{duration:a,animation:x.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new helpersLib.Radian(t.angle),n=i?.color??helpersLib.ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcw(c,n).displayParent(a).attachToRoot();}),new I(a,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcw(t,e){switch(t.type){case U__default.default.Shape.PARTICLE:throw new Error("Not implemented");case U__default.default.Shape.LINE:throw new Error("Not implemented");case U__default.default.Shape.PLANE:throw new Error("Not implemented");case U__default.default.Shape.CIRCLE:throw new Error("Not implemented");case U__default.default.Shape.CAPSULE:throw new Error("Not implemented");case U__default.default.Shape.BOX:throw new Error("Not implemented");case U__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case U__default.default.Shape.CONVEX:return this.ƀcv(t,e);default:throw new Error("Not implemented")}}ƀcv(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Z=Qo([d(),tn("design:paramtypes",[lt,Nt])],Z);var sn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},on=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},$e=class{static{h(this,"HitTestService");}constructor(t){this.ƀlg=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdt(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new U__default.default.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?helpersLib.ColorHelper.red:helpersLib.ColorHelper.green;this.ƀlg.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdt(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};$e=sn([d(),on("design:paramtypes",[Z])],$e);var an=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ze=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀjg(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀbc=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀjg(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀff(r.p2Body),r.entity.ƀjv(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀff(t){let e=f.arrayToVector(t.velocity);e.length>Ei&&(e=e.normalize(Ei),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-Ti),Ti);}ƀjg(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdz(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdz(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeo(i);return {collisionDetailsA:this.ƀdy(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdy(s,i.bodyB.mass,a,c,e.area)}}ƀdy(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeo(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};ze=an([d()],ze);var hn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ln=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ke=class extends le{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};ke=hn([yt(),ln("design:paramtypes",[Number,Object])],ke);var cn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=1e4,Je=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbv(t,new helpersLib.Vector(e.x/2,-j/2),new helpersLib.Vector(e.x+j*2,j),i),this.ƀbv(t,new helpersLib.Vector(e.x/2,e.y+j/2),new helpersLib.Vector(e.x+j*2,j),i),this.ƀbv(t,new helpersLib.Vector(-j/2,e.y/2),new helpersLib.Vector(j,e.y+j*2),i),this.ƀbv(t,new helpersLib.Vector(e.x+j/2,e.y/2),new helpersLib.Vector(j,e.y+j*2),i);}ƀbv(t,e,i,r){return new ke(t,{shapeDefinition:{materialName:ht,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};Je=cn([d()],Je);var dn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},fr=new U__default.default.Material,un={id:ht,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Lt=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new U__default.default.Material),n.set(a.id,a);}),s.has(ht))throw new Error(`Material with name ${ht} cannot be defined, pick another name for the material.`);return s.set(ht,fr),n.set(ht,un),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀem(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀel(e,i.materialDefinitions)}ƀem(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀel(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀee(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀem(n.materialA,s),l=this.ƀem(n.materialB,s);t.addContactMaterial(new U__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀee(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀem(s.id,r);t.addContactMaterial(new U__default.default.ContactMaterial(n,fr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Lt=dn([d()],Lt);var fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ht=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgz=t,this.ƀaj=e,this.ƀaa=i,this.ƀbd=r,this.ƀii=s;}createPhysicsWorld(t){let e=new U__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgz.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀii.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&m.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀbd.registerPhysicsWorld(a),t.modifyUpdateCycle?m.registerUpdateModifier((l,c)=>this.ƀkz(a,l,c)):m.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀkz(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀaa.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀkz(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀbd.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ht=fn([d(),mn("design:paramtypes",[Lt,Je,lt,ze,X])],Ht);var gn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ut=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new U__default.default.RaycastResult,s=new U__default.default.Ray({mode:U__default.default.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbq(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new U__default.default.Ray({mode:U__default.default.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbq(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbq(n,e));},"callback")});return t.p2World.raycast(new U__default.default.RaycastResult,s),Array.from(r.values())}ƀbq(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Ut=gn([d()],Ut);var wn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},dt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};dt=wn([d()],dt);var xn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Wt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbr(r,t.length))}ƀbr(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:helpersLib.Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Wt=xn([d()],Wt);var bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Tn=15,Xe=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcg(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀjb.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀlg.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(y=>{let{p2Body:w,...A}=y;return A})}ƀcg(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(helpersLib.Radian.get90).vector,p=c.normalize(i.x);a.push(new helpersLib.Line(t,t.add(p))),a.push(new helpersLib.Line(t,t.add(p.multiplyNumber(-1))));let y=l.normalize(i.y);a.push(new helpersLib.Line(t,t.add(y))),a.push(new helpersLib.Line(t,t.add(y.multiplyNumber(-1))));let w=Math.round(i.y/Tn),A=i.y/(w*2+1)*2,Tt=l.normalize(A),pe=i.x,yr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(w).forEach(ft=>{let Rt=A*(ft+1),Oi=Tt.multiplyNumber(ft+1),de=c.normalize(this.ƀex(pe,yr,Rt)),ue=t.add(Oi);a.push(new helpersLib.Line(ue,ue.add(de))),a.push(new helpersLib.Line(ue,ue.add(de.multiplyNumber(-1))));let fe=t.add(Oi.multiplyNumber(-1));a.push(new helpersLib.Line(fe,fe.add(de))),a.push(new helpersLib.Line(fe,fe.add(de.multiplyNumber(-1))));}),a.map(ft=>{if(s){let Rt=this.ƀjc.castClosest(n,ft,r);return {line:ft,hits:Rt?[Rt]:[]}}else {let Rt=this.ƀjc.castAllFirstContacts(n,ft,r);return {line:ft,hits:Rt}}})}ƀex(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀft.applyImpulse(r.body,r.hitPosition(),s,n);});});}};Xe=bn([d(),Sn("design:paramtypes",[Ut,Z,Wt,dt])],Xe);var Rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},In=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ke=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeu(i),c=this.ƀcg(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀjb.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀlg.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcg(t,e,i,r,s,n){let a=new helpersLib.Radian(helpersLib.PI_360/r),l=new helpersLib.Vector(0,-e),c=a.vector;return helpersLib.ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new helpersLib.Line(t,p)}).map(p=>{if(s){let y=this.ƀjc.castClosest(n,p,i);return {line:p,hits:y?[y]:[]}}else {let y=this.ƀjc.castAllFirstContacts(n,p,i);return {line:p,hits:y}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀft.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=helpersLib.Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀft.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeu(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};Ke=Rn([d(),In("design:paramtypes",[Ut,Z,Wt,dt])],Ke);var Mn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$t=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};$t=Mn([d()],$t);var Bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Gn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ai=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀip=t,this.ƀib=e,this.ƀlg=i,this.ƀdh=r,this.ƀda=s,this.ƀfk=n,this.ƀio=a,this.ƀft=l;}createPhysicsWorld(t){return this.ƀip.createPhysicsWorld(t)}getMapSize(t){return this.ƀio.getMapSize(t)}setPaused(t,e){this.ƀip.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀfk.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀib.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀib.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀft.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdh.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀda.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=50){this.ƀlg.printPathfindingTestGrid(t,e,i,r,s,n);}};Ai=Bn([Q(exports.PhysicsGateway),Gn("design:paramtypes",[Ht,Nt,Z,Ke,Xe,$e,$t,dt])],Ai);var _n=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ze=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case exports.PhysicsShapeType.Point:return this.ƀbx(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbx(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcf(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀch(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbx(t,e,i,r,s,n){let a=new U__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcf(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(w=>new U__default.default.Convex({vertices:w.map(A=>[A.x,A.y]),collisionGroup:a,collisionMask:l})).map(w=>(w.material=i,w)),p=c.reduce((w,A)=>w+A.area,0),y=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(w=>y.addShape(w)),y.setDensity(r.density),y}ƀch(t,e,i,r,s,n){let a=new U__default.default.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};Ze=_n([d()],Ze);var Fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ci=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀip=t,this.ƀin=e,this.ƀkf=i,this.ƀio=r,this.ƀii=s;}createBody(t,e,i,r,s){return this.ƀkf.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀin.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀin.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀii.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀii.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀip.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀip.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀio.subscribeToPhysicsStep(t,e)}};Ci=Fn([Q(at),Vn("design:paramtypes",[Ht,Lt,Ze,$t,X])],Ci);exports.AdvancedSound=nt;exports.AnimationFlicker=Bi;exports.AnimationInterpolationFunctions=V;exports.Animations=x;exports.Animator=I;exports.BORDER_MATERIAL_NAME=ht;exports.BardLegendsHardReset=R;exports.Camera=ee;exports.ClosestAvailableSpaceHelper=Xt;exports.Container=u;exports.ControllerDecorator=Q;exports.DEFAULT_SHADER_RESOLUTION=D;exports.DeltaTime=ni;exports.DisplayObjectArray=gi;exports.Entity=W;exports.EntityDecorator=yt;exports.FadeInContent=Hi;exports.Game=g;exports.Gateway=q;exports.Graphics=T;exports.ImmovablePhysicsEntity=le;exports.MenuEntity=xi;exports.MenuUI=ne;exports.MenuView=vi;exports.MovableEntity=Ri;exports.MovablePhysicsEntity=Ii;exports.Music=se;exports.MusicPlayer=mi;exports.PathFinder=Kt;exports.PhysicsEntity=b;exports.Placeholder=hi;exports.ROTATIONAL_SPEED_LIMIT=Ti;exports.RichText=li;exports.SOUND_TRANSITION_DURATION=Y;exports.SPEED_LIMIT=Ei;exports.Scene=me;exports.SceneDecorator=Cr;exports.ScrollAreaUI=bi;exports.ScrollMaskUI=xt;exports.Service=S;exports.ServiceDecorator=d;exports.SingletonEntity=gt;exports.SlideInContent=Ji;exports.SlideInContentByIndex=oi;exports.SlideStateAnimation=Ie;exports.Sound=ie;exports.Sprite=k;exports.StateAnimation=Dt;exports.Text=Qt;exports.ThroughEmptyStateAnimation=be;exports.UpdatableContainer=yi;exports.UpdateCycle=m;exports.VectorFieldPathFinder=Zt;exports.VectorSet=bt;exports.View=mt;exports.ViewDecorator=Qe;
package/dist/index.mjs CHANGED
@@ -64,4 +64,4 @@ import {Action,ActionLib,SingleEvent,IDAttachable,SingleAction,Sequence,Variable
64
64
  highestAlpha = centerColor.a;`,e+=`
65
65
 
66
66
  gl_FragColor = vec4(color, 1.0) * highestAlpha;
67
- }`,e}constructor(t,e){if(super(o.ƀev(),o.ƀed(t*D)),this.ƀdf=t,this.resolution=D,this.ƀdf=t*D,this.ƀdf<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀdf>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");Comparator.isInteger(this.ƀdf)||(this.ƀdf=Math.floor(this.ƀdf));let i=ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀdf*this.ƀdf,this.padding=this.ƀdf;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*D),1/(e.height*D)]),t.applyFilter(this,e,i,r);}};var Te=class extends N.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=D;let e={blurRadius:1,expand:0,color:ColorHelper.white,blendMode:Ct.Screen,...t};this.ƀdg=new Ee(e.expand,e.color);let i=Comparator.isNumber(e.blurRadius)?new Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Ot(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=N.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀdg.apply(t,e,s,N.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Jt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀey=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbh(e),s=Comparator.isNumber(r.blurRadius)?new Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀef(t.texture,s,r.expand,r.color,i),a=new N.Sprite(n);return this.ƀjx(a,Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀef(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀey.has(n))return o.ƀey.get(n);{let a=this.ƀeg(t,e,i,r);return o.ƀey.set(n,a),a}}else return this.ƀeg(t,e,i,r)}static ƀeg(t,e,i,r){let s=new N.Sprite(t);this.ƀdi(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=g.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀjx(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdi(t,e){if(t.isSprite){let s=new N.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbh(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:ColorHelper.white,blendMode:Ct.Add};return t&&(e={...e,...t}),e}};R.onHardReset.subscribe(()=>{Jt.ƀey.clear();}).attachToRoot();var k=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=g.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.ƀir,i=e.parent;i&&i.removeChild(e);let r=g.instance.renderer.generateTexture(e,{resolution:2,scaleMode:N.SCALE_MODES.LINEAR,multisample:N.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:Vector.zero,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀlk=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀkq=t,this.pixiSprite=new N.Sprite(M.getAsset(t.id)),this.ƀir.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgu?.destroy(),this.ƀak?.destroy(),this.ƀkq.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀkq.id),this.ƀis&&M.destroyAsset(this.ƀis.texture.id)),this.ƀis&&!this.ƀis.destroyed&&this.ƀis.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀlk}set textureScale(t){this.ƀlk=t,this.pixiSprite.scale.set(t);}get size(){return new Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀkq.boundingShapes&&!this.ƀir.hitArea&&(this.ƀir.hitArea=new ls(this.ƀkq.boundingShapes,this.size,Vector.fromVec2(this.ƀkq.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===N.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=N.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=N.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new N.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀis)return this.ƀis.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀis)this.ƀis.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=Vector.fromVec2(this.ƀkq.anchor).to(t);return new Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀis&&(this.ƀis.destroy(),this.ƀis=void 0),t&&(this.ƀis=Jt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀkq.destroyAssetOnDestroy),this.ƀis.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀis.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.ƀir.addChild(this.ƀis)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbw().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgu){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgu=this.ƀbw(),this.ƀgu.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgu.pixiSprite.renderable=false,this.ƀgu.displayParent(this);}return this.ƀgu}ƀbw(){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀkq.boundingShapes,ColorHelper.white).toSprite().attach(this)}download(){let t=g.instance.renderer.extract.canvas(this.ƀir);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}},ls=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀkg=t.map(r=>new N.Polygon(r.map(s=>new N.Point(s.x,s.y))));}contains(t,e){return this.ƀkg.some(i=>i.contains(t,e))}};var Re=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,y=Math.floor(c/p),w=c-p*y;y>=1&&w<i.dashLength&&(w+=p,y--);let A=s.normalize(w/2),Tt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(A)}),l=l.add(A),y>0){let pe=s.normalize(i.dashLength);ArrayHelper.createEmptyArray(y).forEach(()=>{l=l.add(Tt),a.push({from:l,to:l.add(pe)}),l=l.add(pe);});}return l=l.add(Tt),a.push({from:l,to:l.add(A)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcx=new Map;}static createArrow(t,e){let i=new N.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new N.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:ColorHelper.white,...i},s=new N.Graphics;return s.lineStyle(r.width,r.color),Re.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new N.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new N.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=ColorHelper.white){let i=new N.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new N.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new N.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new N.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new N.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new N.Graphics,s=new Radian(PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.ƀir.addChild(t),this.pixiGraphics=t,this.ƀan=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀan,cache:false,...t},i=this.ƀes(e.cacheName,e.cache),r={id:i.textureID,scale:1,size:i.bounds,anchor:{x:0,y:0},destroyAssetOnDestroy:!e.cache},s=new k(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀes(t,e){if(e){let i=o.ƀcx.get(t);return i||(i=this.ƀci(),o.ƀcx.set(t,i)),i}else return this.ƀci()}ƀci(){let t=g.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {textureID:t.id,bounds:new Vector(e.x,e.y)}}};var si=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},xt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcx=new Map;}constructor(t,e,i,r=tt.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===tt.Horizontal?this.ƀcc(e,i,s):this.ƀcj(e,i,s),this.ƀgu=k.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgu);}ƀcj(t,e,i){e>0&&this.ƀbz(new Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new Vector(t.x,t.y-e*2),ColorHelper.white).toSprite().setPosition(new Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new Vector(t.x,e)).setPosition(new Vector(t.x,t.y),{round:false}).setRotation(Radian.get180).displayParent(i).attach(i);}ƀcc(t,e,i){e>0&&this.ƀbz(new Vector(t.y,e)).setPosition(new Vector(0,t.y),{round:false}).setRotation(Radian.get270).displayParent(i).attach(i),T.createRectangle(new Vector(t.x-e*2,t.y),ColorHelper.white).toSprite().setPosition(new Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new Vector(t.y,e)).setPosition(new Vector(t.x,0),{round:false}).setRotation(Radian.get90).displayParent(i).attach(i);}ƀbz(t){let i={id:this.ƀca(t.y),scale:1,size:t,anchor:{x:0,y:0}};return new k(i,{textureSize:t,ignoreAnchor:true})}ƀca(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcx.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new si;ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=N.Texture.from(r);i=M.insertAsset(a),o.ƀcx.set(e,i);}else throw new Error("Canvas context is null")}return i}};var et;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(et||(et={}));var Ie=class extends Attachable{static{h(this,"SlideStateAnimation");}onStateChange(t){return this.ƀhs.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀhu.subscribe(e=>t(e.value,e.index)).attach(this),this}get state(){return {value:this.ƀky.state.value,item:this.ƀfv,nextItem:this.ƀhj,queuedItem:this.ƀky.state.queuedItem,animationState:this.ƀo}}constructor(t){super(),this.ƀo="idle",this.ƀhs=new Action,this.ƀhu=new Action,this.ƀhx={duration:500,animation:x.easeInOutCubic,...t},this.ƀky=new Dt({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((e,i)=>this.ƀfb(e,i)).onValueChange(e=>this.ƀfg(e)).attach(this);}setIndex(t,e){if(!Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfv===void 0?(this.ƀfv=t,this.ƀhs.trigger({state:et.Appear,index:t}),this.ƀky.setItem(t,e)):this.ƀfv!==t?this.ƀhj!==t?this.ƀo==="idle"?(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀhj=t,this.ƀhs.trigger({state:et.Appear,index:this.ƀhj}),this.ƀky.setItem(t,e)):this.ƀky.setItem(t,e):this.ƀo==="reverting"&&this.ƀhj===t&&(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀky.setItem(t,e)):(this.ƀo==="transitionForward"||this.ƀo==="transitionBackward")&&(this.ƀo="reverting",this.ƀky.setItem(t,e));}ƀfb(t,e){switch(this.ƀfv!==void 0&&this.ƀfv!==t&&this.ƀfv!==e&&this.ƀhs.trigger({state:et.Disappear,index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhj!==t&&this.ƀhj!==e&&this.ƀhs.trigger({state:et.Disappear,index:this.ƀhj}),e!==void 0&&e!==this.ƀfv&&e!==this.ƀhj&&this.ƀhs.trigger({state:et.Appear,index:e}),this.ƀo){case "idle":break;case "transitionForward":case "transitionBackward":e===void 0?(this.ƀo="idle",this.ƀfv=this.ƀhj,this.ƀhj=void 0):this.ƀfv!==t&&this.ƀfc(t,e);break;case "reverting":e===void 0?(this.ƀo="idle",this.ƀhj=void 0):this.ƀfv!==e&&this.ƀfc(t,e);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀfc(t,e){this.ƀfv=t,this.ƀhj=e,this.ƀhu.trigger({value:0,index:this.ƀfv}),this.ƀo=this.ƀfv<this.ƀhj?"transitionForward":"transitionBackward";}ƀfg(t){let e=1;(this.ƀo==="transitionBackward"||this.ƀo==="reverting"&&this.ƀfv!==void 0&&this.ƀhj!==void 0&&this.ƀfv>this.ƀhj)&&(e=-1),(this.ƀo==="idle"||t!==0)&&this.ƀhu.trigger({value:NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhu.trigger({value:NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀhj});}};var tt;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(tt||(tt={}));var oi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀby=t,this.ƀcs="x",this.ƀbo=new Map,this.ƀhx={duration:300,animation:x.easeInOutCubic,size:new Vector(500,500),margin:20,direction:tt.Horizontal,...e};let i=this.ƀhx.direction===tt.Horizontal?new Vector(this.ƀhx.size.x+this.ƀhx.margin*2,this.ƀhx.size.y):new Vector(this.ƀhx.size.x,this.ƀhx.size.y+this.ƀhx.margin*2),r=new u().setPosition(this.ƀhx.direction===tt.Horizontal?new Vector(-this.ƀhx.margin,0):new Vector(0,-this.ƀhx.margin),{round:false}).displayParent(this).attach(this);this.ƀcd(i,this.ƀhx.margin,this.ƀhx.direction,r),this.ƀcs=this.ƀhx.direction===tt.Horizontal?"x":"y",this.ƀky=new Ie({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((s,n)=>{if(s===et.Appear){let a=new u().displayParent(this).attach(this);this.ƀbo.set(n,a),this.ƀby({index:n,container:a});}else {let a=this.ƀbo.get(n);a&&(a.destroy(),this.ƀbo.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbo.get(n);if(a){let l={x:0,y:0};l[this.ƀcs]=i[this.ƀcs]*s+this.ƀhx.margin,a.setPosition(Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀky.setIndex(t,e),this}ƀcd(t,e,i,r){new xt(r,new Vector(t.x,t.y),e,i).attach(this);}},Ji=class extends oi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var bt=class{static{h(this,"VectorSet");}constructor(){this.ƀlx=new Map;}add(t){let e=this.ƀlx.get(t.x);e||(e=new Set,this.ƀlx.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀlx.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀlx.get(t.x);return e?e.delete(t.y):false}};var ni=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var G=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new Vector(.5,.5)).multiplyNumber(e)}};var Xt=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=G.areaToGridArea(e,i);if(this.ƀau(t,s))return Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new bt,s=new Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new Rectangle(n,n.add(i));if(this.ƀau(t,a))return Vector.fromTo(e,n);t.getNeighborPositions(n,GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀau(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new Vector(r,i)))return false;return true}};var Yi=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},Rs=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀfa=t,this.ƀkv=e,this.ƀhw=new BinaryHeap("min"),this.ƀba=[],this.ƀhl=new Grid({size:t.size,defaultValue:void 0});let i=new Yi(this.ƀkv,0,Number.MAX_SAFE_INTEGER);this.ƀhw.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀhw.size>0}getNeighbors(t,e){return this.ƀfa.getNeighborPositions(t.position,e).filter(i=>this.ƀfa.get(i)).map(i=>this.ƀhl.get(i)||this.ƀce(i))}popLowestPathCostNode(){let t=this.ƀhw.pop();return this.ƀhw.delete(t),t.closed=true,this.ƀba.push(t),t}changeNodeCost(t,e,i,r){this.ƀhw.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀhw.add(t.pathLength,t);}getBestClosedNode(){return this.ƀba.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀce(t){let e=new Yi(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀhl.set(t,e),this.ƀhw.add(e.pathLength,e),e}},Kt=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new Rs(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var Zt=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀle=t,this.ƀy=e,this.ƀfj=this.ƀei(this.ƀy.size),this.ƀmg=new Grid({size:this.ƀy.size,defaultValue:this.ƀfj}),this.ƀct=new Grid({size:this.ƀy.size,defaultValue:void 0});let i=new bt,r=new Queue;for(this.ƀdv(this.ƀy.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀmg.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀmg.getOrFail(n);this.ƀen(n,this.ƀy).forEach(l=>{if(!i.has(l.position)){let c=this.ƀmg.getOrFail(l.position),p=a+l.distance;this.ƀy.getOrFail(l.position)&&p<c&&(this.ƀmg.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀle)){if(t=this.ƀmg.movePositionInsideGrid(t),this.ƀct.has(t))return this.ƀct.get(t);{let e=this.ƀen(t,this.ƀy),i;return this.ƀmg.getOrFail(t)>=this.ƀfj?e.some(s=>this.ƀy.get(s.position))&&(e.some(n=>!this.ƀy.get(n.position))?i=this.ƀec(e):i=this.ƀdx(t,e)):i=this.ƀdx(t,e),this.ƀct.set(t,i),i}}}ƀec(t){let e=t.filter(i=>this.ƀy.get(i.position)).map(i=>i.direction.radian);return Radian.getAverage(...e)}ƀdx(t,e){let i=e.filter(r=>this.ƀmg.getOrFail(r.position)<this.ƀfj).reduce((r,s)=>{let n=this.ƀmg.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀfj}).bestDirections;return this.ƀet(i,t)}ƀet(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),Vector.zero);if(i.isZero()||!this.ƀgb(e,i))return Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀgb(t,e){let i=t.add(this.ƀly(e));return this.ƀy.isPointWithinBounds(i)&&this.ƀy.getOrFail(i)}ƀen(t,e){return this.ƀmg.getNeighborDirections(t,GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdv(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new Vector(r,i));return e}ƀly(t){let e=t.normalize().round();return new Vector(e.x,e.y)}ƀei(t){return (t.x+t.y)*20}};var P=class o{static{h(this,"AudioAssets");}static{this.ƀam=new Map;}static{this.context=new AudioContext;}static async load(t){await Promise.all(t.map(e=>fetch(e.url).then(i=>i.arrayBuffer()).then(i=>this.context.decodeAudioData(i)).then(i=>this.ƀam.set(e.id,i))));}static createSource(t){let e=o.ƀdw(t),i=o.context.createBufferSource();return i.buffer=e,i}static ƀdw(t){let e=this.ƀam.get(t);if(!e)throw new Error(`Audio: Sound with id ${t} was not loaded.`);return e}};R.onHardReset.subscribe(()=>{P.context=new AudioContext,P.ƀam.clear();}).attachToRoot();var Y=800,J=class o{static{h(this,"Audio");}static ƀka(){return this.ƀfy=new o,this.ƀfy}constructor(){this.ƀgx=P.context.createGain(),this.ƀgw=P.context.createGain(),this.ƀhi=P.context.createGain(),this.ƀkj=P.context.createGain(),this.ƀgx.connect(P.context.destination),this.ƀgw.connect(this.ƀgx),this.ƀhi.connect(this.ƀgw),this.ƀkj.connect(this.ƀgw),this.ƀgy=new I(this.ƀgx.gain,"value",{duration:500*2,animation:x.easeIn,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀgy.set({value:0});}setVolumes(t){this.ƀgw.gain.value=t.master,this.ƀhi.gain.value=t.music,this.ƀkj.gain.value=t.sound;}appear(t,e="ease"){switch(e){case "ease":return this.ƀgy.set({value:t?0:1}),this.ƀgy.animate({value:t?1:0}).chainToRoot();case "instant":return this.ƀgy.set({value:t?1:0}),SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}};R.onHardReset.subscribe(()=>{J.ƀka();}).attachToRoot();var Ms=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},st=class extends q(){static{h(this,"CameraGateway");}};st=Ms([d()],st);var Bs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Pt=class extends q(){static{h(this,"CameraViewGateway");}};Pt=Bs([d()],Pt);var Ki;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Ki||(Ki={}));var ot;(function(o){o[o.Instant=1]="Instant",o[o.EaseInOut=2]="EaseInOut",o[o.EaseOut=3]="EaseOut";})(ot||(ot={}));var hi=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀit=new N.Graphics,this.ƀit.beginFill(0,1e-9),this.ƀit.drawRect(0,0,t.x,t.y),this.ƀit.endFill(),this.ƀir.addChild(this.ƀit);}destroy(){this.destroyed||(super.destroy(),this.ƀit.destroy());}};var Bt=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:Radian.get60,distance:10,color:ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return JsonHelper.removeUndefinedProperties({fontFamily:e.fontFamily,fill:ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r})}};var Ce=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=RichTextSeparator.process(t,i),s=this.ƀfu(r,e),n=this.ƀs(s);return this.ƀko(n)}static ƀfu(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Bt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀea(a.tags,e,i),p=s(l,c),y=N.TextMetrics.measureText(" ",new N.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:y.width}})}static ƀea(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbf(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbf(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀko(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀkp(s.text).map(a=>{let l=new N.TextStyle(s.pixiStyle),c=N.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀkp(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcm.length===0}get remainingWidth(){return this.ƀmh-this.ƀcp}constructor(t,e){this.ƀmh=t,this.ƀgm=[],this.ƀcm=[],this.ƀcp=0,this.ƀgl=new Vector(0,0),this.ƀcn=0;let i={rectangleCutOption:void 0,horizontalAlignment:"left",verticalAlignment:"bottom",...e};if(this.ƀfm=i.horizontalAlignment,this.ƀlz=i.verticalAlignment,i.rectangleCutOption){if(i.rectangleCutOption.position.x<0||i.rectangleCutOption.position.x>=this.ƀmh||i.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcq={direction:i.rectangleCutOption.direction,rectangle:this.ƀbs(i.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcn,t.y),i=this.ƀej(this.ƀgl.y,this.ƀgl.y+e);return this.ƀcp+t.x<=i}insertWord(t){let e=Math.max(this.ƀcn,t.style.height);if(this.ƀcm.length===0){let i=this.ƀek(this.ƀgl.y,this.ƀgl.y+e);this.ƀgl=new Vector(i,this.ƀgl.y),this.ƀcp=this.ƀgl.x;}this.ƀcm.push({chunk:t,position:new Vector(this.ƀcp,this.ƀgl.y)}),this.ƀcn=e,this.ƀcp+=t.style.width;}newLine(){let t=this.ƀgl.y+this.ƀcn,e=this.ƀek(t,t);this.ƀdn(),this.ƀgl=new Vector(e,t),this.ƀcp=this.ƀgl.x,this.ƀcn=0;}print(){return this.ƀdn(),this.ƀgm}ƀdn(){this.ƀcm.length>0&&(this.ƀgm.push(this.ƀg(this.ƀcm)),this.ƀcm=[]);}ƀg(t){return t=this.ƀmb(t),t=this.ƀfo(t),t}ƀfo(t){if(this.ƀfm==="left")return t;let e=this.ƀgl.y+this.ƀcn,i=this.ƀek(this.ƀgl.y,e),s=this.ƀej(this.ƀgl.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀfm==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new Vector(l.position.x+a,l.position.y)},l))}ƀmb(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀlz){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀlz;throw new Error(`Unexpected case! "${this.ƀlz}"`)}}return r={chunk:r.chunk,position:new Vector(r.position.x,r.position.y+s)},r})}ƀek(t,e){return this.ƀcq&&(this.ƀcq.direction==="topLeft"||this.ƀcq.direction==="bottomLeft")&&(this.ƀcq.rectangle.isPointInside(new Vector(0,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new Vector(0,e),{includeEdges:false}))?this.ƀcq.rectangle.bottomRight.x:0}ƀej(t,e){return this.ƀcq&&(this.ƀcq.direction==="topRight"||this.ƀcq.direction==="bottomRight")&&(this.ƀcq.rectangle.isPointInside(new Vector(this.ƀmh,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new Vector(this.ƀmh,e),{includeEdges:false}))?this.ƀcq.rectangle.topLeft.x:this.ƀmh}ƀbs(t){let e,i;switch(t.direction){case "topRight":e=new Vector(t.position.x,-1/0),i=new Vector(1/0,t.position.y);break;case "topLeft":e=new Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new Vector(1/0,1/0);break;case "bottomLeft":e=new Vector(-1/0,t.position.y),i=new Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new Rectangle(e,i)}};var De=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀmi(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀmi(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀmi(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀhc(t),t=this.ƀlp(t),this.ƀaw(t)}static ƀhc(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀlp(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀaw(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ce.process(t,e),r=JsonHelper.removeUndefinedProperties({rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=new Oe(e.default.wordWrapWidth??1/0,r),n=De.wrapText(i,s);return Me.process(n)}};var js=1,Qi=1/js,Qt=class extends u{static{h(this,"Text");}get ƀli(){if(!this.ƀlj){let t=new N.TextStyle(this.ƀiv);this.ƀlj=N.TextMetrics.measureText(this.ƀlh,t);}return this.ƀlj}get ascent(){return this.ƀli.fontProperties.ascent}constructor(t,e){super(),this.ƀiv=Bt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀiu.destroyed&&this.ƀiu.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new Vector(this.ƀiu.anchor.x,this.ƀiu.anchor.y)}set anchor(t){this.ƀi=t,this.ƀiu.anchor.set(t.x,t.y);}setText(t){return this.ƀlh!==t&&(this.ƀlh=t,this.ƀjf()),this}setColor(t){let e=ColorHelper.rgbToHex(t);return this.ƀiv.fill!==e&&(this.ƀiv.fill=e,this.ƀjf()),this}ƀjf(){this.ƀiu?.destroy(),this.ƀlc?.destroy(),this.ƀlc=void 0,this.ƀlj=void 0;let t=new N.TextStyle(this.ƀiv);this.ƀiu=new N.Text(this.ƀlh,t),this.ƀji(),this.ƀi&&this.ƀiu.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀiu.scale.set(Qi,Qi),this.ƀir.addChild(this.ƀiu),this.ƀiv.lineThrough&&(this.ƀlc=this.ƀe(this.ƀiu,this.ƀiv.fill),this.ƀir.addChild(this.ƀlc));}ƀji(){let t=N.TextMetrics.measureText(this.ƀlh,new N.TextStyle({...this.ƀiv,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀiu.calculateBounds=function(){this.updateText(true),this._bounds.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this._bounds.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=N.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new N.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=N.TextMetrics.measureText(l,t.style),y=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,w=0;t.style.align==="center"?w=0+(t.width-p.width)*.5:t.style.align==="right"&&(w=0+t.width-p.width),w=Math.floor(w),n.moveTo(Math.floor(w),y),n.lineTo(Math.floor(w+p.width),y),a+=p.lineHeight;}),n.endFill(),n}};var li=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new Qt(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var Us=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},F=class extends gt{static{h(this,"CameraEntity");}constructor(){super(...arguments),this.position=new Variable(Vector.zero),this.offset=new Variable(Vector.zero),this.targetPosition=new Variable(void 0),this.focusingNewTargetInfo=new Variable(void 0);}};F=Us([yt()],F);var Ge=class{static{h(this,"PositionConversionHelper");}static includeScaleInScreenPosition(t,e,i){if(e!==1){let r=Vector.fromTo(i,t).multiplyNumber(1/e);return i.add(r)}else return t}};var $s=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Et=class extends mt{static{h(this,"CameraView");}constructor(t){super(),this.ƀdd=t,this.ƀkr=(()=>{let e=new u().attach(this);return e.ƀir=g.instance.ƀiq.stage,e})(),this.ƀjm=new u().setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀae=T.createRectangle(new Vector(1,1),ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀac=new u().displayParent(this.ƀjm).attach(this),this.ƀar=new u().displayParent(this.ƀjm).attach(this),this.ƀdq=new u().setSortableChildren(true).displayParent(this.ƀjm).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdp=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgs=new u().setSortableChildren(true).setZIndex(10).displayParent(this.ƀaq).attach(this),this.ƀab=new u().setZIndex(0).displayParent(this.ƀaq).attach(this),this.ƀh=new I(this.ƀjm,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀaf=new I(this.ƀae,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),g.instance.screenSize.subscribe(e=>{this.ƀae.aspectRatio=e.x/e.y,this.ƀae.scale=Math.max(e.x,e.y),this.ƀae.setPosition(Vector.zero,{holdFrom:Vector.zero});}).attach(this),this.ƀdd.position.subscribe(e=>{this.ƀaq.position=this.ƀbt(e);}).attach(this),this.ƀdd.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:0});}screenPositonToStagePosition(t){let e=Ge.includeScaleInScreenPosition(t,this.ƀkr.scale,g.instance.screenSizeCenter.value);return new Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgs.id,foreground:this.ƀdp.id,foregroundScreen:this.ƀdq.id}}appear(t,e,i){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀh.animate({alpha:t?1:0})).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀaf.animate({alpha:t?0:1})).chain(this);case "instant":return this.ƀh.set({alpha:t?1:0}),this.ƀaf.set({alpha:t?0:1}),SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}ƀbt(t){return Vector.fromTo(t,g.instance.screenSizeCenter.value)}};Et=$s([Qe({entity:F}),zs("design:paramtypes",[F])],Et);var Js=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ys=1500,_e=class{static{h(this,"CameraService");}createCamera(){return new F().attachToRoot()}getCameraPosition(){let t=F.getInstanceOrFail();return Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=F.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=F.getInstanceOrFail();e.focusingNewTargetInfo.value={time:g.time,duration:t?.duration??Ys,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??ot.Instant};}update(t,e){let i=F.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀgf(i,r,t):i.position.value=r);}ƀgf(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===ot.Instant)this.ƀbg(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbg(t,e);else {let n;r.focusingAnimation===ot.EaseInOut?n=V.easeInOut(s):r.focusingAnimation===ot.EaseOut?n=V.easeOut(s):n=1;let a=r.position.lerp(e,n);r.roundPosition&&(Math.abs(a.x-r.position.x)>=r.roundPositionThreshold&&(a=new Vector(Math.round(a.x),a.y)),Math.abs(a.y-r.position.y)>=r.roundPositionThreshold&&(a=new Vector(a.x,Math.round(a.y)))),t.position.value=a;}}}ƀbg(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};_e=Js([d()],_e);var Xs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ks=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},di=class{static{h(this,"CameraController");}constructor(t){this.ƀas=t;}createCamera(){return this.ƀas.createCamera().id}update(t,e){this.ƀas.update(t,e);}setPosition(t){this.ƀas.setPosition(t);}setTransition(t){this.ƀas.setTransition(t);}getCameraPosition(){return this.ƀas.getCameraPosition()}};di=Xs([Q(st),Ks("design:paramtypes",[_e])],di);var Zs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ui=class{static{h(this,"CameraViewController");}getLayers(){let t=F.getInstanceOrFail().id;return Et.getInstanceOrFail(t).getLayers()}appear(t,e,i){let r=F.getInstanceOrFail().id;return Et.getInstanceOrFail(r).appear(t,e,i)}screenPositonToStagePosition(t){let e=F.getInstanceOrFail().id;return Et.getInstanceOrFail(e).screenPositonToStagePosition(t)}};ui=Zs([Q(Pt)],ui);var ee=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=S.get(st),this.ƀat=S.get(Pt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha",i=0){return this.ƀat.appear(t,e,i)}screenPositonToStagePosition(t){return this.ƀat.screenPositonToStagePosition(t)}};var g=class o{static{h(this,"Game");}static get instance(){return this.ƀfy}static{this.pause=Reducer.createOr();}static{this.freeze=Reducer.createOr();}static get camera(){return this.ƀao}static get audio(){return this.ƀx}static appear(t,e){let i=e?.audio??"ease",r=e?.camera??"alpha";return ActionLib.all([this.audio.appear(t,i),this.camera.appear(t,r,i!=="instant"?0:500)]).mapToVoid().chainToRoot()}static get time(){return m.ƀll}static get setupOptions(){return this.ƀkd}constructor(t){if(this.ƀjp=new Variable(Vector.zero),this.screenSize=this.ƀjp.notifier,this.ƀjq=new Variable(Vector.zero),this.screenSizeCenter=this.ƀjq.notifier,this.devMode=false,o.ƀfy)throw new Error("There can be only one Game instance!");this.ƀbk={screenResolution:void 0,maxScreenResolution:void 0,devMode:false,backgroundColor:ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbk.devMode||false;let e=JsonHelper.removeUndefinedProperties({backgroundColor:this.ƀbk.backgroundColor,autoStart:false,antialias:this.ƀbk.antialias,resolution:this.ƀbk.resolution,width:this.ƀbk.screenResolution?.width,height:this.ƀbk.screenResolution?.height});this.ƀiq=new N.Application(e);let i=o.pause.effect(false).attachToRoot();o.freeze.subscribe(r=>{i.update(r),r?P.context.suspend():P.context.resume();}).attachToRoot();}async setup(t){o.ƀkd=t;let e=document.body.appendChild(this.ƀiq.view);this.ƀjz(e),await Promise.all([M.loadGameAssets(t.spriteAssetDefinitions),M.loadGameAssets(t.fontAssetDefinitions),P.load(t.soundAssetDefinitions)]),o.ƀfy=this,this.renderer=this.ƀiq.renderer,globalThis.ƀa=this.ƀiq,this.ƀfe(),o.ƀao=new ee,o.ƀx=J.ƀka(),this.ƀiq.start(),this.ƀiq.ticker.add(()=>{o.freeze.value||m.triggerUpdateTick(this.ƀiq.ticker.deltaMS);});}setResolution(t){if(this.ƀiq.renderer.resolution!==t){this.ƀiq.renderer.resolution=t;let e=this.ƀer();this.ƀiq.renderer.resize(e.x,e.y);}}ƀfe(){this.ƀdb(),this.ƀjy(),window.addEventListener("resize",t=>{this.ƀdb(),this.ƀjy();});}ƀdb(){let t=this.ƀer();(t.x!==this.ƀiq.screen.width||t.y!==this.ƀiq.screen.height)&&this.ƀiq.renderer.resize(t.x,t.y);}ƀjy(){let t=new Vector(this.ƀiq.screen.width,this.ƀiq.screen.height);this.ƀjp.value=t,this.ƀjq.value=t.multiplyNumber(.5).round();}ƀer(){let t=this.ƀbk.screenResolution?.width??window.innerWidth,e=this.ƀbk.screenResolution?.height??window.innerHeight;return this.ƀbk.maxScreenResolution&&(t=Math.min(t,this.ƀbk.maxScreenResolution.width),e=Math.min(e,this.ƀbk.maxScreenResolution.height)),new Vector(t,e)}ƀjz(t){this.ƀbk.maxScreenResolution&&(t.style.maxWidth=`${this.ƀbk.maxScreenResolution?.width}px`,t.style.maxHeight=`${this.ƀbk.maxScreenResolution?.height}px`),t.style.width="100%",t.style.height="100%";}};var ie=class o extends IDAttachable{static{h(this,"Sound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`Sound: Could not find sound definition with name ${t}.`);return new o(i,e)}get volume(){return this.ƀdr.gain.value}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀdr.gain.value=t,this}constructor(t,e){super(),this.ƀkk=t,this.ƀdr=P.context.createGain(),this.ƀdr.connect(J.ƀfy.ƀkj),this.ƀfi=this.ƀdr,e?.volume!==void 0&&(this.volume=e.volume),this.ƀiw(e?.time??0);}destroy(){this.destroyed||(super.destroy(),this.ƀla(),this.ƀdr?.disconnect());}ƀlv(){this.ƀfi.disconnect(),this.ƀfi.connect(J.ƀfy.ƀhi);}ƀiw(t){this.ƀla();let e=this.ƀkk.loop;if(this.ƀkt=NumberHelper.clamp(t,0,e?e.to:this.ƀkk.duration),e){let i=e.from,r=e.to;this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:this.ƀkt<i?i:r,loop:false,onComplete:h(()=>{this.ƀkn.disconnect(),this.ƀix({soundID:this.ƀkk.id,start:i,end:r,loop:true});},"onComplete")});}else this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:void 0,loop:false,onComplete:h(()=>this.destroy(),"onComplete")});}ƀla(){this.ƀkn&&(this.ƀkn.onended=null,this.ƀkn.stop(),this.ƀkn.disconnect());}ƀix(t){this.ƀkn=P.createSource(t.soundID),this.ƀkn.connect(this.ƀdr),t.onComplete&&(this.ƀkn.onended=t.onComplete),t.loop?(this.ƀkn.loop=true,this.ƀkn.loopStart=t.start,this.ƀkn.loopEnd=t.end??this.ƀkn.buffer.duration,this.ƀkn.start(0,t.start)):this.ƀkn.start(0,t.start,t.end?t.end-t.start:void 0);}};var so=800,re=-128,nt=class o extends ie{static{h(this,"AdvancedSound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}constructor(t,e){super(t,e),this.ƀll=new Variable(0),this.time=this.ƀll.notifier,this.ƀkw=P.context.currentTime-this.ƀkt,this.ƀll.value=this.ƀkt,m.beforeSceneUpdateAction.subscribe(()=>{this.ƀll.value=P.context.currentTime-this.ƀkw;}).attach(this),this.ƀfi.disconnect(),this.ƀkb(e?.fade?NumberHelper.clamp(e.fade,0,1):0),this.ƀkc(e?.muffle?NumberHelper.clamp(e.muffle,0,1):0),this.ƀfi.connect(J.ƀfy.ƀkj);}ƀkb(t=0){this.ƀdk=P.context.createGain(),this.ƀdk.gain.value=1-t,this.ƀdj=new I(this.ƀdk.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀfi.connect(this.ƀdk),this.ƀfi=this.ƀdk;}ƀkc(t=0){this.ƀhg=P.context.createBiquadFilter(),this.ƀhg.type="highshelf",this.ƀhg.frequency.value=so,this.ƀhg.gain.value=t*re,this.ƀhh=new I(this.ƀhg.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀfi.connect(this.ƀhg),this.ƀfi=this.ƀhg;}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.fade(1,Y).notIdle().chain(this).tap(()=>this.destroy()).chainToRoot())}notifyOnTime(t){return this.time.value>t?SingleEvent.createDestroyed():SingleEvent.create(e=>{let i=this.time.filter(r=>r>=t).tap(()=>e()).attach(this);return ()=>i.destroy()})}setFade(t){t=NumberHelper.clamp(t,0,1),this.ƀdj.set({value:1-t});}fade(t,e=500){t=NumberHelper.clamp(t,0,1);let i=t>1-this.ƀdk.gain.value;return e===0?(this.ƀdj.set({value:1-t}),SingleEvent.instant()):this.ƀdj.animate({value:1-t},{duration:e,animation:i?x.easeOut:x.easeIn}).chain(this)}setMuffle(t){t=NumberHelper.clamp(t,0,1),this.ƀhh.set({value:t*re});}muffle(t,e=500){t=NumberHelper.clamp(t,0,1);let i=t>this.ƀhg.gain.value/re;return e===0?(this.ƀhh.set({value:t*re}),SingleEvent.instant()):this.ƀhh.animate({value:t*re},{duration:e,animation:i?x.easeIn:x.easeOut}).chain(this)}destroy(){this.destroyed||(this.ƀdk.disconnect(),this.ƀhg.disconnect()),super.destroy();}};var se=class o extends IDAttachable{static{h(this,"Music");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}get time(){switch(this.ƀkm.value.type){case "paused":return this.ƀkm.value.value.time;case "playing":return this.ƀkm.value.value.time.value;default:{this.ƀkm.value;throw new Error(`Unexpected case! "${this.ƀkm.value}"`)}}}get volume(){return this.ƀkm.value.value.volume}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀkm.value.value.volume=t,this}constructor(t,e){super(),this.ƀhx={stopPlayingOnPause:true,...e},this.ƀkl=t.id;let i;if(g.pause.value)i={type:"paused",value:{time:0,volume:1}};else {let r=new nt(t,this.ƀhx).attach(this);r.ƀlv(),i={type:"playing",value:r};}this.ƀkm=new Variable(i),this.ƀhx.stopPlayingOnPause&&(this.ƀid=g.pause.subscribe(r=>this.ƀfd(r)).attach(this));}notifyOnTime(t){return SingleEvent.create(e=>{let i=this.ƀkm.asyncMapDropOngoing((r,s)=>{switch(r.type){case "paused":s.drop();break;case "playing":return r.value.notifyOnTime(t);default:{throw new Error(`Unexpected case! "${r}"`)}}}).toSingleEvent().tap(()=>e()).attach(this);return ()=>i.destroy()})}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),SingleEvent.instant().asyncTap(()=>ActionLib.all([this.ƀkm.value.type==="playing"?this.ƀkm.value.value.close():SingleEvent.instant(),this.ƀdl?.onDestroy()??SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀfd(t){if(t){if(this.ƀkm.value.type==="playing"){let e=this.ƀkm.value.value;this.ƀkm.value={type:"paused",value:{time:e.time.value,volume:e.volume}},this.ƀdl=e,ActionLib.all([e.fade(1,Y),e.muffle(1,Y)]).tap(()=>{this.ƀdl=void 0,e.destroy();}).attach(this);}}else if(this.ƀkm.value.type==="paused"){let{volume:e,time:i}=this.ƀkm.value.value,r=nt.createByName(this.ƀkl,{volume:e,time:i,fade:1,muffle:1}).attach(this);r.ƀlv(),ActionLib.all([r.fade(0,Y),r.muffle(0,Y)]).attach(this),this.ƀkm.value={type:"playing",value:r};}}};var mi=class extends IDAttachable{static{h(this,"MusicPlayer");}get time(){return this.ƀiy?this.ƀiy.time:0}get volume(){return this.ƀmf}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀmf=t,this.ƀiy&&(this.ƀiy.volume=t),this.ƀic&&(this.ƀic.volume=t),this}constructor(t){super(),this.ƀmf=1,this.ƀhx={stopPlayingOnPause:true,playWhenPaused:void 0,volume:1,...t},this.ƀmf=this.ƀhx.volume,this.ƀhx.playWhenPaused&&this.ƀke(this.ƀhx.playWhenPaused);}play(t){if(this.ƀbb)throw new Error("Play is called while music player is destroyed.");return this.ƀco=t,SingleEvent.instant().asyncTap(()=>{let e=this.ƀiy;if(e)return this.ƀiy=void 0,e.close()}).map(()=>{if(this.ƀco===t)return this.ƀiy=se.createByName(t,{stopPlayingOnPause:this.ƀhx.stopPlayingOnPause,volume:this.ƀmf}).attach(this),this.ƀiy}).chain(this)}stop(){return SingleEvent.instant().asyncTap(()=>{let t=this.ƀiy;if(t)return t.close().tap(()=>{t===this.ƀiy&&(this.ƀiy=void 0);})}).chain(this)}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),SingleEvent.instant().asyncTap(()=>ActionLib.all([this.ƀiy?.close()??SingleEvent.instant(),this.ƀic?.close()??SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀke(t){this.ƀid=g.pause.toSequence().asyncMapDropOngoing(e=>e&&m.wait(Y).map(()=>e)).tap(e=>{if(e)this.ƀic=nt.createByName(t,{fade:1,volume:this.ƀmf}).attach(this),this.ƀic.fade(0);else if(this.ƀic){let i=this.ƀic;this.ƀic.fade(1).tap(()=>i.destroy()).attach(this),this.ƀic=void 0;}}).attach(this);}};var yi=class extends u{static{h(this,"UpdatableContainer");}},gi=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀby=t,this.ƀcu=new Map,this.ƀhx={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcu.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhx.trackBy(r,s),a;this.ƀcu.has(n)?(a=this.ƀcu.get(n),e.delete(n),a.update(r)):(a=this.ƀby(r).displayParent(this).attach(this),this.ƀcu.set(n,a)),this.ƀhx.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhx.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhx.positioning.spacing);}),e.forEach(r=>{this.ƀcu.get(r).destroy(),this.ƀcu.delete(r);});}};var ne=class o extends u{static{h(this,"MenuUI");}static{this.ƀga=Reducer.createExistenceChecker();}static{this.isAnyMenuTransitioning=this.ƀga.notifier;}constructor(t,e){super(),this.ƀhp=new SingleAction,this.onCreate=this.ƀhp.notifier,this.ƀhr=new SingleAction,this.onOpen=this.ƀhr.notifier,this.ƀhm=new SingleAction,this.onClose=this.ƀhm.notifier,this.ƀbb=false;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,backgroundDarkeningRatio:.3,...e};this.setAlpha(0),this.ƀp=new I(this,"alpha",{animation:x.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState});let r=T.createRectangle(new Vector(1,1),ColorHelper.black).toSprite({cache:true}).setAlpha(i.backgroundDarkeningRatio).setInteractive(true).displayParent(this).attach(this);this.ƀha=k.createByName(t).setPosition(new Vector(0,0)).setInteractive(true).displayParent(this).attach(this),g.instance.screenSize.subscribe(n=>{r.aspectRatio=n.x/n.y,r.scale=Math.max(n.x,n.y),r.setPosition(Vector.zero,{holdFrom:Vector.half}),this.setPosition(n.multiplyNumber(.5));}).attach(this),this.ƀhp.resolve();let s=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:1}).chain(this).tap(()=>{this.ƀhr.resolve(),s.destroy(),i.closeOnBackgroundClick&&r.on(At.Click).take(1).tap(()=>this.close()).attach(this);}).attachToRoot();}getBoundingMask(){return this.ƀha.getBoundingMask()}close(){if(!this.ƀbb){this.ƀbb=true;let t=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:0}).chain(this).map(()=>{this.ƀhm.resolve(),t.destroy(),this.destroy();}).chainToRoot();}return this.onClose.toSingleEvent()}};var xi=class extends gt{static{h(this,"MenuEntity");}static subscribeIsOpen(){return ActionLib.merge(this.continuesSubscription().map(t=>t.type==="open"),SingleEvent.instant(this.getInstance()!==void 0))}constructor(t){super(),this.ƀhx=t,queueMicrotask(()=>{if(!this.ƀhb)throw new Error("MenuEntity: MenuEntity has to have a MenuView.")});}ƀjh(t){this.ƀhb=t,this.ƀhb.onClose.subscribe(()=>this.destroy()).attach(this);}onCreate(){return this.ƀhb.onCreate.toSingleEvent()}onOpen(){return this.ƀhb.onOpen.toSingleEvent()}onClose(){return this.ƀhb.onClose.toSingleEvent()}close(){return this.ƀhb.close()}};var vi=class extends mt{static{h(this,"MenuView");}constructor(t,e,i){super();let r=JsonHelper.removeUndefinedProperties({appearAnimationDuration:i.appearAnimationDuration,backgroundDarkeningRatio:i.backgroundDarkeningRatio,closeOnBackgroundClick:t.ƀhx.closeOnBackgroundClick}),s=new ne(e,r).displayParent(g.camera.layers.foregroundScreen).attach(this);t.ƀjh(s);let n=new SingleAction;s.onCreate.subscribe(()=>n.resolve(s)).attach(this),this.onCreate=n.notifier,this.onOpen=s.onOpen.notifier,this.onClose=s.onClose.notifier;}};var go=.65,wo=.01,He=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀjr}get contentSize(){return this.ƀbm.size.ceil()}constructor(t,e,i,r){this.ƀbm=t,this.ƀv=e,this.ƀia=i,this.ƀki=r,this.ƀfx=false,this.ƀjr=e-i*2,this.ƀbm.y=i,this.ƀld=i;}onWheel(t){this.setTarget(this.ƀld-t*go);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀld=NumberHelper.clamp(t,this.ƀv-this.ƀia-this.contentSize.y,this.ƀia);}jumpToTarget(){this.ƀbm.y=this.ƀld;}update(t){let e=this.contentSize;if(e.y<=this.ƀjr){switch(this.ƀki){case "start":this.ƀld=this.ƀia;break;case "center":this.ƀld=(this.ƀv-e.y)*.5;break;case "end":this.ƀld=this.ƀv-e.y-this.ƀia;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}this.ƀfx||(this.ƀbm.y=this.ƀld);}this.ƀfx=true;let i=this.ƀld-this.ƀbm.y;this.ƀbm.y=this.ƀbm.y+i*wo*t;}};var vo=15,bi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbn}get contentSize(){return this.ƀjs.contentSize}constructor(t,e={}){super();let i={padding:vo,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new xt(r,t,i.padding).attach(this);let s=new N.Graphics;s.beginFill(0,1e-9),s.drawRect(0,0,t.x,t.y),s.endFill(),r.ƀir.addChild(s);let n=new u().displayParent(r).attach(this);this.ƀjs=new He(n,t.y,i.padding,i.smallContentAlign),this.ƀbn=new Vector(t.x,this.ƀjs.scrollHeight),s.eventMode="dynamic",s.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),n.setInteractive(true),n.ƀir.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),m.afterSceneUpdateAction.subscribe(a=>this.ƀjs.update(a.delta)).attach(this),this.addChildTo=n;}scrollToTop(t){this.ƀjs.scrollToTop(),t?.instant&&this.ƀjs.jumpToTarget();}scrollToBottom(t){this.ƀjs.scrollToBottom(),t?.instant&&this.ƀjs.jumpToTarget();}};var bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"KeyboardService");}constructor(){this.ƀgh=new Action,this.keyPressed=this.ƀgh.notifier,this.ƀgi=new Action,this.keyReleased=this.ƀgi.notifier,this.ƀgo=new Set,this.ƀgn=new Set,window.addEventListener("keydown",t=>{this.ƀgo.add(t.code),this.ƀgn.add(t.code),!t.repeat&&this.ƀgh.trigger({key:t.key,code:t.code});}),window.addEventListener("keyup",t=>{this.ƀgo.delete(t.code),this.ƀgi.trigger({key:t.key,code:t.code});}),window.addEventListener("blur",()=>{this.ƀgo.clear();}),m.afterSceneUpdateAction.subscribe(()=>this.ƀgn.clear()).attachToRoot();}isKeyDown(t,e){return (e?.onlyPressedThisFrame?this.ƀgn:this.ƀgo).has(t)}};Si=bo([d(),So("design:paramtypes",[])],Si);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Eo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},he=class{static{h(this,"MouseService");}constructor(){this.ƀfw=new Variable(false),this.initialMouseMovementHappened=this.ƀfw.notifier,this.ƀks=new Variable(Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀks.notifier,this.ƀjo=new Variable(Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀjo.notifier,this.ƀgr=new Variable(false),this.mainButtonState=this.ƀgr.notifier,this.ƀjt=new Variable(false),this.secondaryButtonState=this.ƀjt.notifier,this.ƀku(),window.addEventListener("pointerdown",t=>{t.button===0?this.ƀgr.value=true:t.button===2&&(this.ƀjt.value=true);},{capture:true}),window.addEventListener("pointerup",t=>{t.button===0?this.ƀgr.value=false:t.button===2&&(this.ƀjt.value=false);},{capture:true}),window.addEventListener("blur",()=>{this.ƀgr.value=false,this.ƀjt.value=false;},{capture:true});}ƀku(){let t=Vector.zero;window.addEventListener("pointermove",e=>{t=new Vector(e.clientX,e.clientY),this.ƀfw.value=true;},{capture:true}),m.beforeSceneUpdateAction.subscribe(()=>{this.ƀjo.value=this.ƀaz(t);}).attachToRoot(),m.afterSceneUpdateAction.subscribe(()=>{let e=g.camera.screenPositonToStagePosition(this.ƀjo.value);e.isEqual(this.ƀks.value)?g.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:t.x,clientY:t.y,pointerType:"mouse"})):this.ƀks.value=e;}).attachToRoot();}ƀaz(t){let i=g.instance.renderer.view.getBoundingClientRect(),r=i.width,s=i.height;if(r<=0||s<=0)return Vector.zero;let n=g.instance.renderer,a=(t.x-i.left)/r*n.screen.width,l=(t.y-i.top)/s*n.screen.height;return a=NumberHelper.clamp(a,0,n.screen.width),l=NumberHelper.clamp(l,0,n.screen.height),new Vector(a,l)}};he=Po([d(),Eo("design:paramtypes",[])],he);var To=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ro=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdo}get lastFocusedPosition(){return this.ƀgk}constructor(t){this.ƀhe=t,this.ƀht=new Action,this.onTargetFocus=this.ƀht.notifier,this.ƀln=0,this.ƀlo=false,this.ƀdo=false,this.ƀgk=void 0,m.beforeSceneUpdateAction.subscribe(e=>this.ƀlr(e.delta)).attachToRoot();}ƀlr(t){if(this.ƀhf){let e=this.ƀeq(this.ƀhe.stagePosition.value,this.ƀhf);this.ƀif===void 0?this.ƀif=e:this.ƀav(e,t);}this.ƀhf=this.ƀhe.stagePosition.value;}ƀav(t,e){this.ƀif-t>10?(this.ƀln=Math.max(250,this.ƀln),this.ƀlo=true):this.ƀln>1e3&&(this.ƀlo=true);let i=this.ƀln>=300&&this.ƀlo;this.ƀgg(i,t,e);}ƀgg(t,e,i){(t||e>this.ƀif)&&(this.ƀif=e),t?(this.ƀlo=false,this.ƀln=0,this.ƀdo=true,this.ƀgk=this.ƀhe.stagePosition.value,this.ƀht.trigger(this.ƀgk)):(this.ƀln+=i,this.ƀdo=false);}ƀeq(t,e){let i=Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};Pi=To([d(),Ro("design:paramtypes",[he])],Pi);var Ei=10.8,Ti=10.01,it;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(it||(it={}));var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new U.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},at=class extends q(){static{h(this,"PhysicsInternalGateway");}};at=Mo([d()],at);var b=class o extends W{static{h(this,"PhysicsEntity");}static{this.ƀhz=new Map;}static{this.ƀij=new Map;}static getFromP2BodyID(t){return o.ƀhz.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhz.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀij.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀij.values())}get area(){return this.ƀu}get mass(){return this.ƀgv}get collisions(){return this.ƀbc}constructor(t,e,i){super(),this.ƀhn=new Action,this.onCollision=this.ƀhn.notifier,this.type="dynamic",this.ƀu=0,this.ƀgv=0,this.ƀbc=[],this.physicsWorldID=t,this.ƀil=S.get(at);let r=this.ƀil.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀil.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀik=this.ƀil.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀim=this.ƀil.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀil.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgv=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀil.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhz.set(this.p2Body.id,this),o.ƀij.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀil.removeBody(this.physicsWorldID,this.p2Body),o.ƀhz.delete(this.p2Body.id),o.ƀij.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀik,this.ƀim,t.ƀik,t.ƀim)}ƀjv(t){this.ƀbc=t,t.length>0&&this.ƀhn.trigger(t);}};var le=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:Vector.zero,rotationalSpeed:0}}};var Ri=class extends W{static{h(this,"MovableEntity");}constructor(){super(),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),m.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀkz(t,e);}).attach(this);}ƀkz(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ii=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),this.ƀfp=false,this.ƀfq=false,this.ƀfs=false,this.ƀfr=false,this.ƀig(),this.ƀgp(),S.get(at).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀkz(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀkz(t,e){this.ƀfp=true,this.ƀfq=true,this.ƀfs=true,this.ƀfr=true,this.ƀig();}ƀig(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀgp(){this.position.subscribe(t=>{this.ƀfp?this.ƀfp=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfq?this.ƀfq=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfs?this.ƀfs=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfr?this.ƀfr=false:this.p2Body.angularVelocity=t;}).attach(this);}};var ht="border";var Fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ce=class extends q(){static{h(this,"PhysicsGateway");}};ce=Fo([d()],ce);var Vo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},No=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends W{static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new Variable(false),this.lastP2Time=new Variable(0),this.onPhysicsStep=new Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=Vo([yt(),No("design:paramtypes",[Vector,Boolean,U.World,Map,Map,Map,Map])],v);var Uo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},X=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};X=Uo([d()],X);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},We=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀii=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀii.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};We=Wo([d(),$o("design:paramtypes",[X])],We);var zo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},lt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀii=t,this.ƀz=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀz.getCollidableGrids(t,i).forEach(s=>{let n=G.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=50){return e.aabbNeedsUpdate=true,e.updateAABB(),Xt.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀz.get(t,e,i);return r||(r=this.ƀcb(t,e,i),this.ƀz.set(t,e,i,r)),r}ƀcb(t,e,i){let r=new Grid({size:new Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀii.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀeh(s,e);r.setArea(a,false);}}),r}ƀeh(t,e){let i=f.aabbToBoundingBox(t.aabb);return G.areaToGridArea(i,e)}};lt=zo([d(),ko("design:paramtypes",[X,We])],lt);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Nt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀih=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=50);let n=v.getInstanceByIDOrFail(t),a,l;Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=G.positionToGridPosition(e,s.gridCellSize),p=G.positionToGridPosition(a,s.gridCellSize),y=this.ƀih.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let A=f.aabbToBoundingBox(l.aabb),Tt=G.areaToGridArea(A,s.gridCellSize);y.setArea(Tt,true);}let w=Kt.findPath(y,c,p,s.neighborType);return w.path=w.path.map(A=>G.gridPositionToPosition(A,s.gridCellSize)),w}findPathDirection(t,e,i,r,s=50){let n=v.getInstanceByIDOrFail(t),a;if(Comparator.isNumber(i)){let w=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(w.p2Body.aabb);}else a=new Rectangle(i,i);let l=G.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let w=this.ƀih.getAvilabilityGrid(n,s,r);p=new Zt(l,w),n.vectorFieldCache.set(c,p);}let y=G.positionToGridPosition(e,s);return p.getDirectionToTarget(y)}};Nt=Xo([d(),Ko("design:paramtypes",[lt])],Nt);var Qo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},tn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Z=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀaa=t,this.ƀib=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀaa.getAvilabilityGrid(a,n,r).map((c,p)=>({position:G.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀib.findPathDirection(t,c.position,i,r),y;p===void 0?y=T.createRectangleBorders(new Vector(8,8),2,ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):y=T.createArrow(25,c.availability?ColorHelper.green:ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new I(y,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>y.destroy()).attach(y);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new I(a,"alpha",{duration:n,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let y=p.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(p.line.from,p.line.to,y).toSprite().displayParent(l).attach(t);}),new I(l,"alpha",{duration:a,animation:x.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new Radian(t.angle),n=i?.color??ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcw(c,n).displayParent(a).attachToRoot();}),new I(a,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcw(t,e){switch(t.type){case U.Shape.PARTICLE:throw new Error("Not implemented");case U.Shape.LINE:throw new Error("Not implemented");case U.Shape.PLANE:throw new Error("Not implemented");case U.Shape.CIRCLE:throw new Error("Not implemented");case U.Shape.CAPSULE:throw new Error("Not implemented");case U.Shape.BOX:throw new Error("Not implemented");case U.Shape.HEIGHTFIELD:throw new Error("Not implemented");case U.Shape.CONVEX:return this.ƀcv(t,e);default:throw new Error("Not implemented")}}ƀcv(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Z=Qo([d(),tn("design:paramtypes",[lt,Nt])],Z);var sn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},on=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},$e=class{static{h(this,"HitTestService");}constructor(t){this.ƀlg=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdt(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new U.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?ColorHelper.red:ColorHelper.green;this.ƀlg.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdt(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};$e=sn([d(),on("design:paramtypes",[Z])],$e);var an=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ze=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀjg(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀbc=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀjg(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀff(r.p2Body),r.entity.ƀjv(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀff(t){let e=f.arrayToVector(t.velocity);e.length>Ei&&(e=e.normalize(Ei),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-Ti),Ti);}ƀjg(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdz(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdz(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeo(i);return {collisionDetailsA:this.ƀdy(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdy(s,i.bodyB.mass,a,c,e.area)}}ƀdy(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeo(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};ze=an([d()],ze);var hn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ln=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ke=class extends le{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};ke=hn([yt(),ln("design:paramtypes",[Number,Object])],ke);var cn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=1e4,Je=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbv(t,new Vector(e.x/2,-j/2),new Vector(e.x+j*2,j),i),this.ƀbv(t,new Vector(e.x/2,e.y+j/2),new Vector(e.x+j*2,j),i),this.ƀbv(t,new Vector(-j/2,e.y/2),new Vector(j,e.y+j*2),i),this.ƀbv(t,new Vector(e.x+j/2,e.y/2),new Vector(j,e.y+j*2),i);}ƀbv(t,e,i,r){return new ke(t,{shapeDefinition:{materialName:ht,group:r,shapeType:it.Rectangle,shapeData:i},position:e,rotation:Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};Je=cn([d()],Je);var dn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},fr=new U.Material,un={id:ht,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Lt=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new U.Material),n.set(a.id,a);}),s.has(ht))throw new Error(`Material with name ${ht} cannot be defined, pick another name for the material.`);return s.set(ht,fr),n.set(ht,un),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀem(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀel(e,i.materialDefinitions)}ƀem(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀel(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀee(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀem(n.materialA,s),l=this.ƀem(n.materialB,s);t.addContactMaterial(new U.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀee(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀem(s.id,r);t.addContactMaterial(new U.ContactMaterial(n,fr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Lt=dn([d()],Lt);var fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ht=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgz=t,this.ƀaj=e,this.ƀaa=i,this.ƀbd=r,this.ƀii=s;}createPhysicsWorld(t){let e=new U.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgz.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀii.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&m.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀbd.registerPhysicsWorld(a),t.modifyUpdateCycle?m.registerUpdateModifier((l,c)=>this.ƀkz(a,l,c)):m.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀkz(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀaa.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀkz(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀbd.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ht=fn([d(),mn("design:paramtypes",[Lt,Je,lt,ze,X])],Ht);var gn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ut=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new U.RaycastResult,s=new U.Ray({mode:U.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbq(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new U.Ray({mode:U.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbq(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbq(n,e));},"callback")});return t.p2World.raycast(new U.RaycastResult,s),Array.from(r.values())}ƀbq(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Ut=gn([d()],Ut);var wn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},dt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};dt=wn([d()],dt);var xn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Wt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbr(r,t.length))}ƀbr(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Wt=xn([d()],Wt);var bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Tn=15,Xe=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcg(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀjb.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀlg.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(y=>{let{p2Body:w,...A}=y;return A})}ƀcg(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(Radian.get90).vector,p=c.normalize(i.x);a.push(new Line(t,t.add(p))),a.push(new Line(t,t.add(p.multiplyNumber(-1))));let y=l.normalize(i.y);a.push(new Line(t,t.add(y))),a.push(new Line(t,t.add(y.multiplyNumber(-1))));let w=Math.round(i.y/Tn),A=i.y/(w*2+1)*2,Tt=l.normalize(A),pe=i.x,yr=Math.pow(i.y,2);return ArrayHelper.createIntegerArray(w).forEach(ft=>{let Rt=A*(ft+1),Oi=Tt.multiplyNumber(ft+1),de=c.normalize(this.ƀex(pe,yr,Rt)),ue=t.add(Oi);a.push(new Line(ue,ue.add(de))),a.push(new Line(ue,ue.add(de.multiplyNumber(-1))));let fe=t.add(Oi.multiplyNumber(-1));a.push(new Line(fe,fe.add(de))),a.push(new Line(fe,fe.add(de.multiplyNumber(-1))));}),a.map(ft=>{if(s){let Rt=this.ƀjc.castClosest(n,ft,r);return {line:ft,hits:Rt?[Rt]:[]}}else {let Rt=this.ƀjc.castAllFirstContacts(n,ft,r);return {line:ft,hits:Rt}}})}ƀex(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀft.applyImpulse(r.body,r.hitPosition(),s,n);});});}};Xe=bn([d(),Sn("design:paramtypes",[Ut,Z,Wt,dt])],Xe);var Rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},In=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ke=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeu(i),c=this.ƀcg(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀjb.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀlg.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcg(t,e,i,r,s,n){let a=new Radian(PI_360/r),l=new Vector(0,-e),c=a.vector;return ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new Line(t,p)}).map(p=>{if(s){let y=this.ƀjc.castClosest(n,p,i);return {line:p,hits:y?[y]:[]}}else {let y=this.ƀjc.castAllFirstContacts(n,p,i);return {line:p,hits:y}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀft.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀft.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeu(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};Ke=Rn([d(),In("design:paramtypes",[Ut,Z,Wt,dt])],Ke);var Mn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$t=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};$t=Mn([d()],$t);var Bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Gn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ai=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀip=t,this.ƀib=e,this.ƀlg=i,this.ƀdh=r,this.ƀda=s,this.ƀfk=n,this.ƀio=a,this.ƀft=l;}createPhysicsWorld(t){return this.ƀip.createPhysicsWorld(t)}getMapSize(t){return this.ƀio.getMapSize(t)}setPaused(t,e){this.ƀip.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀfk.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀib.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀib.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀft.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdh.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀda.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=50){this.ƀlg.printPathfindingTestGrid(t,e,i,r,s,n);}};Ai=Bn([Q(ce),Gn("design:paramtypes",[Ht,Nt,Z,Ke,Xe,$e,$t,dt])],Ai);var _n=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ze=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case it.Point:return this.ƀbx(n,void 0,i,r,e.shapeDefinition.group,s);case it.Circle:return this.ƀbx(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case it.Polygon:return this.ƀcf(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case it.Rectangle:return this.ƀch(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbx(t,e,i,r,s,n){let a=new U.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new U.Body({type:n==="dynamic"?U.Body.DYNAMIC:U.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcf(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(w=>new U.Convex({vertices:w.map(A=>[A.x,A.y]),collisionGroup:a,collisionMask:l})).map(w=>(w.material=i,w)),p=c.reduce((w,A)=>w+A.area,0),y=new U.Body({type:n==="dynamic"?U.Body.DYNAMIC:U.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(w=>y.addShape(w)),y.setDensity(r.density),y}ƀch(t,e,i,r,s,n){let a=new U.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new U.Body({type:n==="dynamic"?U.Body.DYNAMIC:U.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};Ze=_n([d()],Ze);var Fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ci=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀip=t,this.ƀin=e,this.ƀkf=i,this.ƀio=r,this.ƀii=s;}createBody(t,e,i,r,s){return this.ƀkf.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀin.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀin.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀii.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀii.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀip.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀip.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀio.subscribeToPhysicsStep(t,e)}};Ci=Fn([Q(at),Vn("design:paramtypes",[Ht,Lt,Ze,$t,X])],Ci);export{nt as AdvancedSound,Bi as AnimationFlicker,V as AnimationInterpolationFunctions,x as Animations,E as AnimationsCompletionHandlingType,I as Animator,ht as BORDER_MATERIAL_NAME,R as BardLegendsHardReset,Ct as BlendMode,ee as Camera,st as CameraGateway,Xt as ClosestAvailableSpaceHelper,u as Container,At as ContainerEventType,Q as ControllerDecorator,ti as Cursor,D as DEFAULT_SHADER_RESOLUTION,ni as DeltaTime,gi as DisplayObjectArray,W as Entity,yt as EntityDecorator,Hi as FadeInContent,ot as FocusingAnimation,g as Game,q as Gateway,T as Graphics,le as ImmovablePhysicsEntity,Si as KeyboardService,xi as MenuEntity,ne as MenuUI,vi as MenuView,he as MouseService,Pi as MouseTargetFocusService,Ri as MovableEntity,Ii as MovablePhysicsEntity,se as Music,mi as MusicPlayer,Kt as PathFinder,b as PhysicsEntity,ce as PhysicsGateway,it as PhysicsShapeType,hi as Placeholder,Ti as ROTATIONAL_SPEED_LIMIT,C as ReAnimateHandlingType,li as RichText,Y as SOUND_TRANSITION_DURATION,Ei as SPEED_LIMIT,me as Scene,Cr as SceneDecorator,bi as ScrollAreaUI,tt as ScrollDirection,xt as ScrollMaskUI,S as Service,d as ServiceDecorator,gt as SingletonEntity,Ji as SlideInContent,oi as SlideInContentByIndex,Ie as SlideStateAnimation,et as SlideStateAnimationState,ie as Sound,k as Sprite,Dt as StateAnimation,Qt as Text,be as ThroughEmptyStateAnimation,yi as UpdatableContainer,m as UpdateCycle,Zt as VectorFieldPathFinder,bt as VectorSet,mt as View,Qe as ViewDecorator};
67
+ }`,e}constructor(t,e){if(super(o.ƀev(),o.ƀed(t*D)),this.ƀdf=t,this.resolution=D,this.ƀdf=t*D,this.ƀdf<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀdf>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");Comparator.isInteger(this.ƀdf)||(this.ƀdf=Math.floor(this.ƀdf));let i=ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀdf*this.ƀdf,this.padding=this.ƀdf;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*D),1/(e.height*D)]),t.applyFilter(this,e,i,r);}};var Te=class extends N.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=D;let e={blurRadius:1,expand:0,color:ColorHelper.white,blendMode:Ct.Screen,...t};this.ƀdg=new Ee(e.expand,e.color);let i=Comparator.isNumber(e.blurRadius)?new Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Ot(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=N.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀdg.apply(t,e,s,N.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Jt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀey=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbh(e),s=Comparator.isNumber(r.blurRadius)?new Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀef(t.texture,s,r.expand,r.color,i),a=new N.Sprite(n);return this.ƀjx(a,Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀef(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀey.has(n))return o.ƀey.get(n);{let a=this.ƀeg(t,e,i,r);return o.ƀey.set(n,a),a}}else return this.ƀeg(t,e,i,r)}static ƀeg(t,e,i,r){let s=new N.Sprite(t);this.ƀdi(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=g.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀjx(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdi(t,e){if(t.isSprite){let s=new N.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbh(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:ColorHelper.white,blendMode:Ct.Add};return t&&(e={...e,...t}),e}};R.onHardReset.subscribe(()=>{Jt.ƀey.clear();}).attachToRoot();var k=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=g.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.ƀir,i=e.parent;i&&i.removeChild(e);let r=g.instance.renderer.generateTexture(e,{resolution:2,scaleMode:N.SCALE_MODES.LINEAR,multisample:N.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:Vector.zero,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀlk=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀkq=t,this.pixiSprite=new N.Sprite(M.getAsset(t.id)),this.ƀir.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgu?.destroy(),this.ƀak?.destroy(),this.ƀkq.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀkq.id),this.ƀis&&M.destroyAsset(this.ƀis.texture.id)),this.ƀis&&!this.ƀis.destroyed&&this.ƀis.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀlk}set textureScale(t){this.ƀlk=t,this.pixiSprite.scale.set(t);}get size(){return new Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀkq.boundingShapes&&!this.ƀir.hitArea&&(this.ƀir.hitArea=new ls(this.ƀkq.boundingShapes,this.size,Vector.fromVec2(this.ƀkq.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===N.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=N.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=N.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new N.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀis)return this.ƀis.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀis)this.ƀis.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=Vector.fromVec2(this.ƀkq.anchor).to(t);return new Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀis&&(this.ƀis.destroy(),this.ƀis=void 0),t&&(this.ƀis=Jt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀkq.destroyAssetOnDestroy),this.ƀis.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀis.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.ƀir.addChild(this.ƀis)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbw().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgu){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgu=this.ƀbw(),this.ƀgu.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgu.pixiSprite.renderable=false,this.ƀgu.displayParent(this);}return this.ƀgu}ƀbw(){if(!this.ƀkq.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀkq.boundingShapes,ColorHelper.white).toSprite().attach(this)}download(){let t=g.instance.renderer.extract.canvas(this.ƀir);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}},ls=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀkg=t.map(r=>new N.Polygon(r.map(s=>new N.Point(s.x,s.y))));}contains(t,e){return this.ƀkg.some(i=>i.contains(t,e))}};var Re=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,y=Math.floor(c/p),w=c-p*y;y>=1&&w<i.dashLength&&(w+=p,y--);let A=s.normalize(w/2),Tt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(A)}),l=l.add(A),y>0){let pe=s.normalize(i.dashLength);ArrayHelper.createEmptyArray(y).forEach(()=>{l=l.add(Tt),a.push({from:l,to:l.add(pe)}),l=l.add(pe);});}return l=l.add(Tt),a.push({from:l,to:l.add(A)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcx=new Map;}static createArrow(t,e){let i=new N.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new N.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:ColorHelper.white,...i},s=new N.Graphics;return s.lineStyle(r.width,r.color),Re.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new N.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new N.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=ColorHelper.white){let i=new N.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new N.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new N.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new N.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new N.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new N.Graphics,s=new Radian(PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.ƀir.addChild(t),this.pixiGraphics=t,this.ƀan=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀan,cache:false,...t},i=this.ƀes(e.cacheName,e.cache),r={id:i.textureID,scale:1,size:i.bounds,anchor:{x:0,y:0},destroyAssetOnDestroy:!e.cache},s=new k(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀes(t,e){if(e){let i=o.ƀcx.get(t);return i||(i=this.ƀci(),o.ƀcx.set(t,i)),i}else return this.ƀci()}ƀci(){let t=g.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {textureID:t.id,bounds:new Vector(e.x,e.y)}}};var si=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},xt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcx=new Map;}constructor(t,e,i,r=tt.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===tt.Horizontal?this.ƀcc(e,i,s):this.ƀcj(e,i,s),this.ƀgu=k.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgu);}ƀcj(t,e,i){e>0&&this.ƀbz(new Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new Vector(t.x,t.y-e*2),ColorHelper.white).toSprite().setPosition(new Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new Vector(t.x,e)).setPosition(new Vector(t.x,t.y),{round:false}).setRotation(Radian.get180).displayParent(i).attach(i);}ƀcc(t,e,i){e>0&&this.ƀbz(new Vector(t.y,e)).setPosition(new Vector(0,t.y),{round:false}).setRotation(Radian.get270).displayParent(i).attach(i),T.createRectangle(new Vector(t.x-e*2,t.y),ColorHelper.white).toSprite().setPosition(new Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbz(new Vector(t.y,e)).setPosition(new Vector(t.x,0),{round:false}).setRotation(Radian.get90).displayParent(i).attach(i);}ƀbz(t){let i={id:this.ƀca(t.y),scale:1,size:t,anchor:{x:0,y:0}};return new k(i,{textureSize:t,ignoreAnchor:true})}ƀca(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcx.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new si;ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=N.Texture.from(r);i=M.insertAsset(a),o.ƀcx.set(e,i);}else throw new Error("Canvas context is null")}return i}};var et;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(et||(et={}));var Ie=class extends Attachable{static{h(this,"SlideStateAnimation");}onStateChange(t){return this.ƀhs.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀhu.subscribe(e=>t(e.value,e.index)).attach(this),this}get state(){return {value:this.ƀky.state.value,item:this.ƀfv,nextItem:this.ƀhj,queuedItem:this.ƀky.state.queuedItem,animationState:this.ƀo}}constructor(t){super(),this.ƀo="idle",this.ƀhs=new Action,this.ƀhu=new Action,this.ƀhx={duration:500,animation:x.easeInOutCubic,...t},this.ƀky=new Dt({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((e,i)=>this.ƀfb(e,i)).onValueChange(e=>this.ƀfg(e)).attach(this);}setIndex(t,e){if(!Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfv===void 0?(this.ƀfv=t,this.ƀhs.trigger({state:et.Appear,index:t}),this.ƀky.setItem(t,e)):this.ƀfv!==t?this.ƀhj!==t?this.ƀo==="idle"?(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀhj=t,this.ƀhs.trigger({state:et.Appear,index:this.ƀhj}),this.ƀky.setItem(t,e)):this.ƀky.setItem(t,e):this.ƀo==="reverting"&&this.ƀhj===t&&(this.ƀo=t>this.ƀfv?"transitionForward":"transitionBackward",this.ƀky.setItem(t,e)):(this.ƀo==="transitionForward"||this.ƀo==="transitionBackward")&&(this.ƀo="reverting",this.ƀky.setItem(t,e));}ƀfb(t,e){switch(this.ƀfv!==void 0&&this.ƀfv!==t&&this.ƀfv!==e&&this.ƀhs.trigger({state:et.Disappear,index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhj!==t&&this.ƀhj!==e&&this.ƀhs.trigger({state:et.Disappear,index:this.ƀhj}),e!==void 0&&e!==this.ƀfv&&e!==this.ƀhj&&this.ƀhs.trigger({state:et.Appear,index:e}),this.ƀo){case "idle":break;case "transitionForward":case "transitionBackward":e===void 0?(this.ƀo="idle",this.ƀfv=this.ƀhj,this.ƀhj=void 0):this.ƀfv!==t&&this.ƀfc(t,e);break;case "reverting":e===void 0?(this.ƀo="idle",this.ƀhj=void 0):this.ƀfv!==e&&this.ƀfc(t,e);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀfc(t,e){this.ƀfv=t,this.ƀhj=e,this.ƀhu.trigger({value:0,index:this.ƀfv}),this.ƀo=this.ƀfv<this.ƀhj?"transitionForward":"transitionBackward";}ƀfg(t){let e=1;(this.ƀo==="transitionBackward"||this.ƀo==="reverting"&&this.ƀfv!==void 0&&this.ƀhj!==void 0&&this.ƀfv>this.ƀhj)&&(e=-1),(this.ƀo==="idle"||t!==0)&&this.ƀhu.trigger({value:NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfv}),this.ƀhj!==void 0&&this.ƀhu.trigger({value:NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀhj});}};var tt;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(tt||(tt={}));var oi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀby=t,this.ƀcs="x",this.ƀbo=new Map,this.ƀhx={duration:300,animation:x.easeInOutCubic,size:new Vector(500,500),margin:20,direction:tt.Horizontal,...e};let i=this.ƀhx.direction===tt.Horizontal?new Vector(this.ƀhx.size.x+this.ƀhx.margin*2,this.ƀhx.size.y):new Vector(this.ƀhx.size.x,this.ƀhx.size.y+this.ƀhx.margin*2),r=new u().setPosition(this.ƀhx.direction===tt.Horizontal?new Vector(-this.ƀhx.margin,0):new Vector(0,-this.ƀhx.margin),{round:false}).displayParent(this).attach(this);this.ƀcd(i,this.ƀhx.margin,this.ƀhx.direction,r),this.ƀcs=this.ƀhx.direction===tt.Horizontal?"x":"y",this.ƀky=new Ie({duration:this.ƀhx.duration,animation:this.ƀhx.animation}).onStateChange((s,n)=>{if(s===et.Appear){let a=new u().displayParent(this).attach(this);this.ƀbo.set(n,a),this.ƀby({index:n,container:a});}else {let a=this.ƀbo.get(n);a&&(a.destroy(),this.ƀbo.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbo.get(n);if(a){let l={x:0,y:0};l[this.ƀcs]=i[this.ƀcs]*s+this.ƀhx.margin,a.setPosition(Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀky.setIndex(t,e),this}ƀcd(t,e,i,r){new xt(r,new Vector(t.x,t.y),e,i).attach(this);}},Ji=class extends oi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var bt=class{static{h(this,"VectorSet");}constructor(){this.ƀlx=new Map;}add(t){let e=this.ƀlx.get(t.x);e||(e=new Set,this.ƀlx.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀlx.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀlx.get(t.x);return e?e.delete(t.y):false}};var ni=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var G=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new Vector(.5,.5)).multiplyNumber(e)}};var Xt=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=G.areaToGridArea(e,i);if(this.ƀau(t,s))return Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new bt,s=new Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new Rectangle(n,n.add(i));if(this.ƀau(t,a))return Vector.fromTo(e,n);t.getNeighborPositions(n,GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀau(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new Vector(r,i)))return false;return true}};var Yi=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},Rs=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀfa=t,this.ƀkv=e,this.ƀhw=new BinaryHeap("min"),this.ƀba=[],this.ƀhl=new Grid({size:t.size,defaultValue:void 0});let i=new Yi(this.ƀkv,0,Number.MAX_SAFE_INTEGER);this.ƀhw.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀhw.size>0}getNeighbors(t,e){return this.ƀfa.getNeighborPositions(t.position,e).filter(i=>this.ƀfa.get(i)).map(i=>this.ƀhl.get(i)||this.ƀce(i))}popLowestPathCostNode(){let t=this.ƀhw.pop();return this.ƀhw.delete(t),t.closed=true,this.ƀba.push(t),t}changeNodeCost(t,e,i,r){this.ƀhw.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀhw.add(t.pathLength,t);}getBestClosedNode(){return this.ƀba.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀce(t){let e=new Yi(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀhl.set(t,e),this.ƀhw.add(e.pathLength,e),e}},Kt=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new Rs(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var Zt=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀle=t,this.ƀy=e,this.ƀfj=this.ƀei(this.ƀy.size),this.ƀmg=new Grid({size:this.ƀy.size,defaultValue:this.ƀfj}),this.ƀct=new Grid({size:this.ƀy.size,defaultValue:void 0});let i=new bt,r=new Queue;for(this.ƀdv(this.ƀy.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀmg.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀmg.getOrFail(n);this.ƀen(n,this.ƀy).forEach(l=>{if(!i.has(l.position)){let c=this.ƀmg.getOrFail(l.position),p=a+l.distance;this.ƀy.getOrFail(l.position)&&p<c&&(this.ƀmg.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀle)){if(t=this.ƀmg.movePositionInsideGrid(t),this.ƀct.has(t))return this.ƀct.get(t);{let e=this.ƀen(t,this.ƀy),i;return this.ƀmg.getOrFail(t)>=this.ƀfj?e.some(s=>this.ƀy.get(s.position))&&(e.some(n=>!this.ƀy.get(n.position))?i=this.ƀec(e):i=this.ƀdx(t,e)):i=this.ƀdx(t,e),this.ƀct.set(t,i),i}}}ƀec(t){let e=t.filter(i=>this.ƀy.get(i.position)).map(i=>i.direction.radian);return Radian.getAverage(...e)}ƀdx(t,e){let i=e.filter(r=>this.ƀmg.getOrFail(r.position)<this.ƀfj).reduce((r,s)=>{let n=this.ƀmg.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀfj}).bestDirections;return this.ƀet(i,t)}ƀet(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),Vector.zero);if(i.isZero()||!this.ƀgb(e,i))return Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀgb(t,e){let i=t.add(this.ƀly(e));return this.ƀy.isPointWithinBounds(i)&&this.ƀy.getOrFail(i)}ƀen(t,e){return this.ƀmg.getNeighborDirections(t,GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdv(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new Vector(r,i));return e}ƀly(t){let e=t.normalize().round();return new Vector(e.x,e.y)}ƀei(t){return (t.x+t.y)*20}};var P=class o{static{h(this,"AudioAssets");}static{this.ƀam=new Map;}static{this.context=new AudioContext;}static async load(t){await Promise.all(t.map(e=>fetch(e.url).then(i=>i.arrayBuffer()).then(i=>this.context.decodeAudioData(i)).then(i=>this.ƀam.set(e.id,i))));}static createSource(t){let e=o.ƀdw(t),i=o.context.createBufferSource();return i.buffer=e,i}static ƀdw(t){let e=this.ƀam.get(t);if(!e)throw new Error(`Audio: Sound with id ${t} was not loaded.`);return e}};R.onHardReset.subscribe(()=>{P.context=new AudioContext,P.ƀam.clear();}).attachToRoot();var Y=800,J=class o{static{h(this,"Audio");}static ƀka(){return this.ƀfy=new o,this.ƀfy}constructor(){this.ƀgx=P.context.createGain(),this.ƀgw=P.context.createGain(),this.ƀhi=P.context.createGain(),this.ƀkj=P.context.createGain(),this.ƀgx.connect(P.context.destination),this.ƀgw.connect(this.ƀgx),this.ƀhi.connect(this.ƀgw),this.ƀkj.connect(this.ƀgw),this.ƀgy=new I(this.ƀgx.gain,"value",{duration:500*2,animation:x.easeIn,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀgy.set({value:0});}setVolumes(t){this.ƀgw.gain.value=t.master,this.ƀhi.gain.value=t.music,this.ƀkj.gain.value=t.sound;}appear(t,e="ease"){switch(e){case "ease":return this.ƀgy.set({value:t?0:1}),this.ƀgy.animate({value:t?1:0}).chainToRoot();case "instant":return this.ƀgy.set({value:t?1:0}),SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}};R.onHardReset.subscribe(()=>{J.ƀka();}).attachToRoot();var Ms=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},st=class extends q(){static{h(this,"CameraGateway");}};st=Ms([d()],st);var Bs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Pt=class extends q(){static{h(this,"CameraViewGateway");}};Pt=Bs([d()],Pt);var Ki;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Ki||(Ki={}));var ot;(function(o){o[o.Instant=1]="Instant",o[o.EaseInOut=2]="EaseInOut",o[o.EaseOut=3]="EaseOut";})(ot||(ot={}));var hi=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀit=new N.Graphics,this.ƀit.beginFill(0,1e-9),this.ƀit.drawRect(0,0,t.x,t.y),this.ƀit.endFill(),this.ƀir.addChild(this.ƀit);}destroy(){this.destroyed||(super.destroy(),this.ƀit.destroy());}};var Bt=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:Radian.get60,distance:10,color:ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return JsonHelper.removeUndefinedProperties({fontFamily:e.fontFamily,fill:ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r})}};var Ce=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=RichTextSeparator.process(t,i),s=this.ƀfu(r,e),n=this.ƀs(s);return this.ƀko(n)}static ƀfu(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Bt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀea(a.tags,e,i),p=s(l,c),y=N.TextMetrics.measureText(" ",new N.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:y.width}})}static ƀea(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbf(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbf(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀko(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀkp(s.text).map(a=>{let l=new N.TextStyle(s.pixiStyle),c=N.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀkp(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcm.length===0}get remainingWidth(){return this.ƀmh-this.ƀcp}constructor(t,e){this.ƀmh=t,this.ƀgm=[],this.ƀcm=[],this.ƀcp=0,this.ƀgl=new Vector(0,0),this.ƀcn=0;let i={rectangleCutOption:void 0,horizontalAlignment:"left",verticalAlignment:"bottom",...e};if(this.ƀfm=i.horizontalAlignment,this.ƀlz=i.verticalAlignment,i.rectangleCutOption){if(i.rectangleCutOption.position.x<0||i.rectangleCutOption.position.x>=this.ƀmh||i.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcq={direction:i.rectangleCutOption.direction,rectangle:this.ƀbs(i.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcn,t.y),i=this.ƀej(this.ƀgl.y,this.ƀgl.y+e);return this.ƀcp+t.x<=i}insertWord(t){let e=Math.max(this.ƀcn,t.style.height);if(this.ƀcm.length===0){let i=this.ƀek(this.ƀgl.y,this.ƀgl.y+e);this.ƀgl=new Vector(i,this.ƀgl.y),this.ƀcp=this.ƀgl.x;}this.ƀcm.push({chunk:t,position:new Vector(this.ƀcp,this.ƀgl.y)}),this.ƀcn=e,this.ƀcp+=t.style.width;}newLine(){let t=this.ƀgl.y+this.ƀcn,e=this.ƀek(t,t);this.ƀdn(),this.ƀgl=new Vector(e,t),this.ƀcp=this.ƀgl.x,this.ƀcn=0;}print(){return this.ƀdn(),this.ƀgm}ƀdn(){this.ƀcm.length>0&&(this.ƀgm.push(this.ƀg(this.ƀcm)),this.ƀcm=[]);}ƀg(t){return t=this.ƀmb(t),t=this.ƀfo(t),t}ƀfo(t){if(this.ƀfm==="left")return t;let e=this.ƀgl.y+this.ƀcn,i=this.ƀek(this.ƀgl.y,e),s=this.ƀej(this.ƀgl.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀfm==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new Vector(l.position.x+a,l.position.y)},l))}ƀmb(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀlz){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀlz;throw new Error(`Unexpected case! "${this.ƀlz}"`)}}return r={chunk:r.chunk,position:new Vector(r.position.x,r.position.y+s)},r})}ƀek(t,e){return this.ƀcq&&(this.ƀcq.direction==="topLeft"||this.ƀcq.direction==="bottomLeft")&&(this.ƀcq.rectangle.isPointInside(new Vector(0,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new Vector(0,e),{includeEdges:false}))?this.ƀcq.rectangle.bottomRight.x:0}ƀej(t,e){return this.ƀcq&&(this.ƀcq.direction==="topRight"||this.ƀcq.direction==="bottomRight")&&(this.ƀcq.rectangle.isPointInside(new Vector(this.ƀmh,t),{includeEdges:false})||this.ƀcq.rectangle.isPointInside(new Vector(this.ƀmh,e),{includeEdges:false}))?this.ƀcq.rectangle.topLeft.x:this.ƀmh}ƀbs(t){let e,i;switch(t.direction){case "topRight":e=new Vector(t.position.x,-1/0),i=new Vector(1/0,t.position.y);break;case "topLeft":e=new Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new Vector(1/0,1/0);break;case "bottomLeft":e=new Vector(-1/0,t.position.y),i=new Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new Rectangle(e,i)}};var De=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀmi(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀmi(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀmi(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀhc(t),t=this.ƀlp(t),this.ƀaw(t)}static ƀhc(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀlp(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀaw(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ce.process(t,e),r=JsonHelper.removeUndefinedProperties({rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=new Oe(e.default.wordWrapWidth??1/0,r),n=De.wrapText(i,s);return Me.process(n)}};var js=1,Qi=1/js,Qt=class extends u{static{h(this,"Text");}get ƀli(){if(!this.ƀlj){let t=new N.TextStyle(this.ƀiv);this.ƀlj=N.TextMetrics.measureText(this.ƀlh,t);}return this.ƀlj}get ascent(){return this.ƀli.fontProperties.ascent}constructor(t,e){super(),this.ƀiv=Bt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀiu.destroyed&&this.ƀiu.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new Vector(this.ƀiu.anchor.x,this.ƀiu.anchor.y)}set anchor(t){this.ƀi=t,this.ƀiu.anchor.set(t.x,t.y);}setText(t){return this.ƀlh!==t&&(this.ƀlh=t,this.ƀjf()),this}setColor(t){let e=ColorHelper.rgbToHex(t);return this.ƀiv.fill!==e&&(this.ƀiv.fill=e,this.ƀjf()),this}ƀjf(){this.ƀiu?.destroy(),this.ƀlc?.destroy(),this.ƀlc=void 0,this.ƀlj=void 0;let t=new N.TextStyle(this.ƀiv);this.ƀiu=new N.Text(this.ƀlh,t),this.ƀji(),this.ƀi&&this.ƀiu.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀiu.scale.set(Qi,Qi),this.ƀir.addChild(this.ƀiu),this.ƀiv.lineThrough&&(this.ƀlc=this.ƀe(this.ƀiu,this.ƀiv.fill),this.ƀir.addChild(this.ƀlc));}ƀji(){let t=N.TextMetrics.measureText(this.ƀlh,new N.TextStyle({...this.ƀiv,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀiu.calculateBounds=function(){this.updateText(true),this._bounds.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this._bounds.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=N.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new N.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=N.TextMetrics.measureText(l,t.style),y=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,w=0;t.style.align==="center"?w=0+(t.width-p.width)*.5:t.style.align==="right"&&(w=0+t.width-p.width),w=Math.floor(w),n.moveTo(Math.floor(w),y),n.lineTo(Math.floor(w+p.width),y),a+=p.lineHeight;}),n.endFill(),n}};var li=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new Qt(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var Us=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},F=class extends gt{static{h(this,"CameraEntity");}constructor(){super(...arguments),this.position=new Variable(Vector.zero),this.offset=new Variable(Vector.zero),this.targetPosition=new Variable(void 0),this.focusingNewTargetInfo=new Variable(void 0);}};F=Us([yt()],F);var Ge=class{static{h(this,"PositionConversionHelper");}static includeScaleInScreenPosition(t,e,i){if(e!==1){let r=Vector.fromTo(i,t).multiplyNumber(1/e);return i.add(r)}else return t}};var $s=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Et=class extends mt{static{h(this,"CameraView");}constructor(t){super(),this.ƀdd=t,this.ƀkr=(()=>{let e=new u().attach(this);return e.ƀir=g.instance.ƀiq.stage,e})(),this.ƀjm=new u().setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀae=T.createRectangle(new Vector(1,1),ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(this.ƀkr).attach(this),this.ƀac=new u().displayParent(this.ƀjm).attach(this),this.ƀar=new u().displayParent(this.ƀjm).attach(this),this.ƀdq=new u().setSortableChildren(true).displayParent(this.ƀjm).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdp=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgs=new u().setSortableChildren(true).setZIndex(10).displayParent(this.ƀaq).attach(this),this.ƀab=new u().setZIndex(0).displayParent(this.ƀaq).attach(this),this.ƀh=new I(this.ƀjm,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀaf=new I(this.ƀae,"alpha",{duration:500,animation:x.easeInOutCubic,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),g.instance.screenSize.subscribe(e=>{this.ƀae.aspectRatio=e.x/e.y,this.ƀae.scale=Math.max(e.x,e.y),this.ƀae.setPosition(Vector.zero,{holdFrom:Vector.zero});}).attach(this),this.ƀdd.position.subscribe(e=>{this.ƀaq.position=this.ƀbt(e);}).attach(this),this.ƀdd.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:0});}screenPositonToStagePosition(t){let e=Ge.includeScaleInScreenPosition(t,this.ƀkr.scale,g.instance.screenSizeCenter.value);return new Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgs.id,foreground:this.ƀdp.id,foregroundScreen:this.ƀdq.id}}appear(t,e,i){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀh.animate({alpha:t?1:0})).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),SingleEvent.instant().asyncTap(()=>i>0&&m.wait(i)).asyncTap(()=>this.ƀaf.animate({alpha:t?0:1})).chain(this);case "instant":return this.ƀh.set({alpha:t?1:0}),this.ƀaf.set({alpha:t?0:1}),SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}ƀbt(t){return Vector.fromTo(t,g.instance.screenSizeCenter.value)}};Et=$s([Qe({entity:F}),zs("design:paramtypes",[F])],Et);var Js=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ys=1500,_e=class{static{h(this,"CameraService");}createCamera(){return new F().attachToRoot()}getCameraPosition(){let t=F.getInstanceOrFail();return Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=F.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=F.getInstanceOrFail();e.focusingNewTargetInfo.value={time:g.time,duration:t?.duration??Ys,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??ot.Instant};}update(t,e){let i=F.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀgf(i,r,t):i.position.value=r);}ƀgf(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===ot.Instant)this.ƀbg(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbg(t,e);else {let n;r.focusingAnimation===ot.EaseInOut?n=V.easeInOut(s):r.focusingAnimation===ot.EaseOut?n=V.easeOut(s):n=1;let a=r.position.lerp(e,n);r.roundPosition&&(Math.abs(a.x-r.position.x)>=r.roundPositionThreshold&&(a=new Vector(Math.round(a.x),a.y)),Math.abs(a.y-r.position.y)>=r.roundPositionThreshold&&(a=new Vector(a.x,Math.round(a.y)))),t.position.value=a;}}}ƀbg(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};_e=Js([d()],_e);var Xs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ks=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},di=class{static{h(this,"CameraController");}constructor(t){this.ƀas=t;}createCamera(){return this.ƀas.createCamera().id}update(t,e){this.ƀas.update(t,e);}setPosition(t){this.ƀas.setPosition(t);}setTransition(t){this.ƀas.setTransition(t);}getCameraPosition(){return this.ƀas.getCameraPosition()}};di=Xs([Q(st),Ks("design:paramtypes",[_e])],di);var Zs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ui=class{static{h(this,"CameraViewController");}getLayers(){let t=F.getInstanceOrFail().id;return Et.getInstanceOrFail(t).getLayers()}appear(t,e,i){let r=F.getInstanceOrFail().id;return Et.getInstanceOrFail(r).appear(t,e,i)}screenPositonToStagePosition(t){let e=F.getInstanceOrFail().id;return Et.getInstanceOrFail(e).screenPositonToStagePosition(t)}};ui=Zs([Q(Pt)],ui);var ee=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=S.get(st),this.ƀat=S.get(Pt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha",i=0){return this.ƀat.appear(t,e,i)}screenPositonToStagePosition(t){return this.ƀat.screenPositonToStagePosition(t)}};var g=class o{static{h(this,"Game");}static get instance(){return this.ƀfy}static{this.pause=Reducer.createOr();}static{this.freeze=Reducer.createOr();}static get camera(){return this.ƀao}static get audio(){return this.ƀx}static appear(t,e){let i=e?.audio??"ease",r=e?.camera??"alpha";return ActionLib.all([this.audio.appear(t,i),this.camera.appear(t,r,i!=="instant"?0:500)]).mapToVoid().chainToRoot()}static get time(){return m.ƀll}static get setupOptions(){return this.ƀkd}constructor(t){if(this.ƀjp=new Variable(Vector.zero),this.screenSize=this.ƀjp.notifier,this.ƀjq=new Variable(Vector.zero),this.screenSizeCenter=this.ƀjq.notifier,this.devMode=false,o.ƀfy)throw new Error("There can be only one Game instance!");this.ƀbk={screenResolution:void 0,maxScreenResolution:void 0,devMode:false,backgroundColor:ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbk.devMode||false;let e=JsonHelper.removeUndefinedProperties({backgroundColor:this.ƀbk.backgroundColor,autoStart:false,antialias:this.ƀbk.antialias,resolution:this.ƀbk.resolution,width:this.ƀbk.screenResolution?.width,height:this.ƀbk.screenResolution?.height});this.ƀiq=new N.Application(e);let i=o.pause.effect(false).attachToRoot();o.freeze.subscribe(r=>{i.update(r),r?P.context.suspend():P.context.resume();}).attachToRoot();}async setup(t){o.ƀkd=t;let e=document.body.appendChild(this.ƀiq.view);this.ƀjz(e),await Promise.all([M.loadGameAssets(t.spriteAssetDefinitions),M.loadGameAssets(t.fontAssetDefinitions),P.load(t.soundAssetDefinitions)]),o.ƀfy=this,this.renderer=this.ƀiq.renderer,globalThis.ƀa=this.ƀiq,this.ƀfe(),o.ƀao=new ee,o.ƀx=J.ƀka(),this.ƀiq.start(),this.ƀiq.ticker.add(()=>{o.freeze.value||m.triggerUpdateTick(this.ƀiq.ticker.deltaMS);});}setResolution(t){if(this.ƀiq.renderer.resolution!==t){this.ƀiq.renderer.resolution=t;let e=this.ƀer();this.ƀiq.renderer.resize(e.x,e.y);}}ƀfe(){this.ƀdb(),this.ƀjy(),window.addEventListener("resize",t=>{this.ƀdb(),this.ƀjy();});}ƀdb(){let t=this.ƀer();(t.x!==this.ƀiq.screen.width||t.y!==this.ƀiq.screen.height)&&this.ƀiq.renderer.resize(t.x,t.y);}ƀjy(){let t=new Vector(this.ƀiq.screen.width,this.ƀiq.screen.height);this.ƀjp.value=t,this.ƀjq.value=t.multiplyNumber(.5).round();}ƀer(){let t=this.ƀbk.screenResolution?.width??window.innerWidth,e=this.ƀbk.screenResolution?.height??window.innerHeight;return this.ƀbk.maxScreenResolution&&(t=Math.min(t,this.ƀbk.maxScreenResolution.width),e=Math.min(e,this.ƀbk.maxScreenResolution.height)),new Vector(t,e)}ƀjz(t){this.ƀbk.maxScreenResolution&&(t.style.maxWidth=`${this.ƀbk.maxScreenResolution?.width}px`,t.style.maxHeight=`${this.ƀbk.maxScreenResolution?.height}px`),t.style.width="100%",t.style.height="100%";}};var ie=class o extends IDAttachable{static{h(this,"Sound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`Sound: Could not find sound definition with name ${t}.`);return new o(i,e)}get volume(){return this.ƀdr.gain.value}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀdr.gain.value=t,this}constructor(t,e){super(),this.ƀkk=t,this.ƀdr=P.context.createGain(),this.ƀdr.connect(J.ƀfy.ƀkj),this.ƀfi=this.ƀdr,e?.volume!==void 0&&(this.volume=e.volume),this.ƀiw(e?.time??0);}destroy(){this.destroyed||(super.destroy(),this.ƀla(),this.ƀdr?.disconnect());}ƀlv(){this.ƀfi.disconnect(),this.ƀfi.connect(J.ƀfy.ƀhi);}ƀiw(t){this.ƀla();let e=this.ƀkk.loop;if(this.ƀkt=NumberHelper.clamp(t,0,e?e.to:this.ƀkk.duration),e){let i=e.from,r=e.to;this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:this.ƀkt<i?i:r,loop:false,onComplete:h(()=>{this.ƀkn.disconnect(),this.ƀix({soundID:this.ƀkk.id,start:i,end:r,loop:true});},"onComplete")});}else this.ƀix({soundID:this.ƀkk.id,start:this.ƀkt,end:void 0,loop:false,onComplete:h(()=>this.destroy(),"onComplete")});}ƀla(){this.ƀkn&&(this.ƀkn.onended=null,this.ƀkn.stop(),this.ƀkn.disconnect());}ƀix(t){this.ƀkn=P.createSource(t.soundID),this.ƀkn.connect(this.ƀdr),t.onComplete&&(this.ƀkn.onended=t.onComplete),t.loop?(this.ƀkn.loop=true,this.ƀkn.loopStart=t.start,this.ƀkn.loopEnd=t.end??this.ƀkn.buffer.duration,this.ƀkn.start(0,t.start)):this.ƀkn.start(0,t.start,t.end?t.end-t.start:void 0);}};var so=800,re=-128,nt=class o extends ie{static{h(this,"AdvancedSound");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}constructor(t,e){super(t,e),this.ƀll=new Variable(0),this.time=this.ƀll.notifier,this.ƀkw=P.context.currentTime-this.ƀkt,this.ƀll.value=this.ƀkt,m.beforeSceneUpdateAction.subscribe(()=>{this.ƀll.value=P.context.currentTime-this.ƀkw;}).attach(this),this.ƀfi.disconnect(),this.ƀkb(e?.fade?NumberHelper.clamp(e.fade,0,1):0),this.ƀkc(e?.muffle?NumberHelper.clamp(e.muffle,0,1):0),this.ƀfi.connect(J.ƀfy.ƀkj);}ƀkb(t=0){this.ƀdk=P.context.createGain(),this.ƀdk.gain.value=1-t,this.ƀdj=new I(this.ƀdk.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀfi.connect(this.ƀdk),this.ƀfi=this.ƀdk;}ƀkc(t=0){this.ƀhg=P.context.createBiquadFilter(),this.ƀhg.type="highshelf",this.ƀhg.frequency.value=so,this.ƀhg.gain.value=t*re,this.ƀhh=new I(this.ƀhg.gain,"value",{duration:500,animation:x.lineer,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState}),this.ƀfi.connect(this.ƀhg),this.ƀfi=this.ƀhg;}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.fade(1,Y).notIdle().chain(this).tap(()=>this.destroy()).chainToRoot())}notifyOnTime(t){return this.time.value>t?SingleEvent.createDestroyed():SingleEvent.create(e=>{let i=this.time.filter(r=>r>=t).tap(()=>e()).attach(this);return ()=>i.destroy()})}setFade(t){t=NumberHelper.clamp(t,0,1),this.ƀdj.set({value:1-t});}fade(t,e=500){t=NumberHelper.clamp(t,0,1);let i=t>1-this.ƀdk.gain.value;return e===0?(this.ƀdj.set({value:1-t}),SingleEvent.instant()):this.ƀdj.animate({value:1-t},{duration:e,animation:i?x.easeOut:x.easeIn}).chain(this)}setMuffle(t){t=NumberHelper.clamp(t,0,1),this.ƀhh.set({value:t*re});}muffle(t,e=500){t=NumberHelper.clamp(t,0,1);let i=t>this.ƀhg.gain.value/re;return e===0?(this.ƀhh.set({value:t*re}),SingleEvent.instant()):this.ƀhh.animate({value:t*re},{duration:e,animation:i?x.easeIn:x.easeOut}).chain(this)}destroy(){this.destroyed||(this.ƀdk.disconnect(),this.ƀhg.disconnect()),super.destroy();}};var se=class o extends IDAttachable{static{h(this,"Music");}static createByName(t,e){let i=g.setupOptions.soundDefinitions[t];if(!i)throw new Error(`AdvancedSound: Could not find sound definition with name ${t}.`);return new o(i,e)}get time(){switch(this.ƀkm.value.type){case "paused":return this.ƀkm.value.value.time;case "playing":return this.ƀkm.value.value.time.value;default:{this.ƀkm.value;throw new Error(`Unexpected case! "${this.ƀkm.value}"`)}}}get volume(){return this.ƀkm.value.value.volume}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀkm.value.value.volume=t,this}constructor(t,e){super(),this.ƀhx={stopPlayingOnPause:true,...e},this.ƀkl=t.id;let i;if(this.ƀhx.stopPlayingOnPause&&g.pause.value)i={type:"paused",value:{time:0,volume:1}};else {let r=new nt(t,this.ƀhx).attach(this);r.ƀlv(),i={type:"playing",value:r};}this.ƀkm=new Variable(i),this.ƀhx.stopPlayingOnPause&&(this.ƀid=g.pause.subscribe(r=>this.ƀfd(r)).attach(this));}notifyOnTime(t){return SingleEvent.create(e=>{let i=this.ƀkm.asyncMapDropOngoing((r,s)=>{switch(r.type){case "paused":s.drop();break;case "playing":return r.value.notifyOnTime(t);default:{throw new Error(`Unexpected case! "${r}"`)}}}).toSingleEvent().tap(()=>e()).attach(this);return ()=>i.destroy()})}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),SingleEvent.instant().asyncTap(()=>ActionLib.all([this.ƀkm.value.type==="playing"?this.ƀkm.value.value.close():SingleEvent.instant(),this.ƀdl?.onDestroy()??SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀfd(t){if(t){if(this.ƀkm.value.type==="playing"){let e=this.ƀkm.value.value;this.ƀkm.value={type:"paused",value:{time:e.time.value,volume:e.volume}},this.ƀdl=e,ActionLib.all([e.fade(1,Y),e.muffle(1,Y)]).tap(()=>{this.ƀdl=void 0,e.destroy();}).attach(this);}}else if(this.ƀkm.value.type==="paused"){let{volume:e,time:i}=this.ƀkm.value.value,r=nt.createByName(this.ƀkl,{volume:e,time:i,fade:1,muffle:1}).attach(this);r.ƀlv(),ActionLib.all([r.fade(0,Y),r.muffle(0,Y)]).attach(this),this.ƀkm.value={type:"playing",value:r};}}};var mi=class extends IDAttachable{static{h(this,"MusicPlayer");}get time(){return this.ƀiy?this.ƀiy.time:0}get volume(){return this.ƀmf}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀmf=t,this.ƀiy&&(this.ƀiy.volume=t),this.ƀic&&(this.ƀic.volume=t),this}constructor(t){super(),this.ƀmf=1,this.ƀhx={stopPlayingOnPause:true,playWhenPaused:void 0,volume:1,...t},this.ƀmf=this.ƀhx.volume,this.ƀhx.playWhenPaused&&this.ƀke(this.ƀhx.playWhenPaused);}play(t){if(this.ƀbb)throw new Error("Play is called while music player is destroyed.");return this.ƀco=t,SingleEvent.instant().asyncTap(()=>{let e=this.ƀiy;if(e)return this.ƀiy=void 0,e.close()}).map(()=>{if(this.ƀco===t)return this.ƀiy=se.createByName(t,{stopPlayingOnPause:this.ƀhx.stopPlayingOnPause,volume:this.ƀmf}).attach(this),this.ƀiy}).chain(this)}stop(){return SingleEvent.instant().asyncTap(()=>{let t=this.ƀiy;if(t)return t.close().tap(()=>{t===this.ƀiy&&(this.ƀiy=void 0);})}).chain(this)}close(){return this.ƀbb?this.onDestroy():(this.ƀbb=true,this.ƀid?.destroy(),SingleEvent.instant().asyncTap(()=>ActionLib.all([this.ƀiy?.close()??SingleEvent.instant(),this.ƀic?.close()??SingleEvent.instant()])).chain(this).tap(()=>this.destroy()).chainToRoot())}ƀke(t){this.ƀid=g.pause.toSequence().asyncMapDropOngoing(e=>e&&m.wait(Y).map(()=>e)).tap(e=>{if(e)this.ƀic=nt.createByName(t,{fade:1,volume:this.ƀmf}).attach(this),this.ƀic.fade(0);else if(this.ƀic){let i=this.ƀic;this.ƀic.fade(1).tap(()=>i.destroy()).attach(this),this.ƀic=void 0;}}).attach(this);}};var yi=class extends u{static{h(this,"UpdatableContainer");}},gi=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀby=t,this.ƀcu=new Map,this.ƀhx={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcu.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhx.trackBy(r,s),a;this.ƀcu.has(n)?(a=this.ƀcu.get(n),e.delete(n),a.update(r)):(a=this.ƀby(r).displayParent(this).attach(this),this.ƀcu.set(n,a)),this.ƀhx.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhx.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhx.positioning.spacing);}),e.forEach(r=>{this.ƀcu.get(r).destroy(),this.ƀcu.delete(r);});}};var ne=class o extends u{static{h(this,"MenuUI");}static{this.ƀga=Reducer.createExistenceChecker();}static{this.isAnyMenuTransitioning=this.ƀga.notifier;}constructor(t,e){super(),this.ƀhp=new SingleAction,this.onCreate=this.ƀhp.notifier,this.ƀhr=new SingleAction,this.onOpen=this.ƀhr.notifier,this.ƀhm=new SingleAction,this.onClose=this.ƀhm.notifier,this.ƀbb=false;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,backgroundDarkeningRatio:.3,...e};this.setAlpha(0),this.ƀp=new I(this,"alpha",{animation:x.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:C.CompletePrevious,completionHandling:E.StayInCurrentState});let r=T.createRectangle(new Vector(1,1),ColorHelper.black).toSprite({cache:true}).setAlpha(i.backgroundDarkeningRatio).setInteractive(true).displayParent(this).attach(this);this.ƀha=k.createByName(t).setPosition(new Vector(0,0)).setInteractive(true).displayParent(this).attach(this),g.instance.screenSize.subscribe(n=>{r.aspectRatio=n.x/n.y,r.scale=Math.max(n.x,n.y),r.setPosition(Vector.zero,{holdFrom:Vector.half}),this.setPosition(n.multiplyNumber(.5));}).attach(this),this.ƀhp.resolve();let s=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:1}).chain(this).tap(()=>{this.ƀhr.resolve(),s.destroy(),i.closeOnBackgroundClick&&r.on(At.Click).take(1).tap(()=>this.close()).attach(this);}).attachToRoot();}getBoundingMask(){return this.ƀha.getBoundingMask()}close(){if(!this.ƀbb){this.ƀbb=true;let t=o.ƀga.effect().attach(this);this.ƀp.animate({alpha:0}).chain(this).map(()=>{this.ƀhm.resolve(),t.destroy(),this.destroy();}).chainToRoot();}return this.onClose.toSingleEvent()}};var xi=class extends gt{static{h(this,"MenuEntity");}static subscribeIsOpen(){return ActionLib.merge(this.continuesSubscription().map(t=>t.type==="open"),SingleEvent.instant(this.getInstance()!==void 0))}constructor(t){super(),this.ƀhx=t,queueMicrotask(()=>{if(!this.ƀhb)throw new Error("MenuEntity: MenuEntity has to have a MenuView.")});}ƀjh(t){this.ƀhb=t,this.ƀhb.onClose.subscribe(()=>this.destroy()).attach(this);}onCreate(){return this.ƀhb.onCreate.toSingleEvent()}onOpen(){return this.ƀhb.onOpen.toSingleEvent()}onClose(){return this.ƀhb.onClose.toSingleEvent()}close(){return this.ƀhb.close()}};var vi=class extends mt{static{h(this,"MenuView");}constructor(t,e,i){super();let r=JsonHelper.removeUndefinedProperties({appearAnimationDuration:i.appearAnimationDuration,backgroundDarkeningRatio:i.backgroundDarkeningRatio,closeOnBackgroundClick:t.ƀhx.closeOnBackgroundClick}),s=new ne(e,r).displayParent(g.camera.layers.foregroundScreen).attach(this);t.ƀjh(s);let n=new SingleAction;s.onCreate.subscribe(()=>n.resolve(s)).attach(this),this.onCreate=n.notifier,this.onOpen=s.onOpen.notifier,this.onClose=s.onClose.notifier;}};var go=.65,wo=.01,He=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀjr}get contentSize(){return this.ƀbm.size.ceil()}constructor(t,e,i,r){this.ƀbm=t,this.ƀv=e,this.ƀia=i,this.ƀki=r,this.ƀfx=false,this.ƀjr=e-i*2,this.ƀbm.y=i,this.ƀld=i;}onWheel(t){this.setTarget(this.ƀld-t*go);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀld=NumberHelper.clamp(t,this.ƀv-this.ƀia-this.contentSize.y,this.ƀia);}jumpToTarget(){this.ƀbm.y=this.ƀld;}update(t){let e=this.contentSize;if(e.y<=this.ƀjr){switch(this.ƀki){case "start":this.ƀld=this.ƀia;break;case "center":this.ƀld=(this.ƀv-e.y)*.5;break;case "end":this.ƀld=this.ƀv-e.y-this.ƀia;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}this.ƀfx||(this.ƀbm.y=this.ƀld);}this.ƀfx=true;let i=this.ƀld-this.ƀbm.y;this.ƀbm.y=this.ƀbm.y+i*wo*t;}};var vo=15,bi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbn}get contentSize(){return this.ƀjs.contentSize}constructor(t,e={}){super();let i={padding:vo,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new xt(r,t,i.padding).attach(this);let s=new N.Graphics;s.beginFill(0,1e-9),s.drawRect(0,0,t.x,t.y),s.endFill(),r.ƀir.addChild(s);let n=new u().displayParent(r).attach(this);this.ƀjs=new He(n,t.y,i.padding,i.smallContentAlign),this.ƀbn=new Vector(t.x,this.ƀjs.scrollHeight),s.eventMode="dynamic",s.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),n.setInteractive(true),n.ƀir.addEventListener("wheel",a=>{this.ƀjs.onWheel(a.deltaY);}),m.afterSceneUpdateAction.subscribe(a=>this.ƀjs.update(a.delta)).attach(this),this.addChildTo=n;}scrollToTop(t){this.ƀjs.scrollToTop(),t?.instant&&this.ƀjs.jumpToTarget();}scrollToBottom(t){this.ƀjs.scrollToBottom(),t?.instant&&this.ƀjs.jumpToTarget();}};var bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"KeyboardService");}constructor(){this.ƀgh=new Action,this.keyPressed=this.ƀgh.notifier,this.ƀgi=new Action,this.keyReleased=this.ƀgi.notifier,this.ƀgo=new Set,this.ƀgn=new Set,window.addEventListener("keydown",t=>{this.ƀgo.add(t.code),this.ƀgn.add(t.code),!t.repeat&&this.ƀgh.trigger({key:t.key,code:t.code});}),window.addEventListener("keyup",t=>{this.ƀgo.delete(t.code),this.ƀgi.trigger({key:t.key,code:t.code});}),window.addEventListener("blur",()=>{this.ƀgo.clear();}),m.afterSceneUpdateAction.subscribe(()=>this.ƀgn.clear()).attachToRoot();}isKeyDown(t,e){return (e?.onlyPressedThisFrame?this.ƀgn:this.ƀgo).has(t)}};Si=bo([d(),So("design:paramtypes",[])],Si);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Eo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},he=class{static{h(this,"MouseService");}constructor(){this.ƀfw=new Variable(false),this.initialMouseMovementHappened=this.ƀfw.notifier,this.ƀks=new Variable(Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀks.notifier,this.ƀjo=new Variable(Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀjo.notifier,this.ƀgr=new Variable(false),this.mainButtonState=this.ƀgr.notifier,this.ƀjt=new Variable(false),this.secondaryButtonState=this.ƀjt.notifier,this.ƀku(),window.addEventListener("pointerdown",t=>{t.button===0?this.ƀgr.value=true:t.button===2&&(this.ƀjt.value=true);},{capture:true}),window.addEventListener("pointerup",t=>{t.button===0?this.ƀgr.value=false:t.button===2&&(this.ƀjt.value=false);},{capture:true}),window.addEventListener("blur",()=>{this.ƀgr.value=false,this.ƀjt.value=false;},{capture:true});}ƀku(){let t=Vector.zero;window.addEventListener("pointermove",e=>{t=new Vector(e.clientX,e.clientY),this.ƀfw.value=true;},{capture:true}),m.beforeSceneUpdateAction.subscribe(()=>{this.ƀjo.value=this.ƀaz(t);}).attachToRoot(),m.afterSceneUpdateAction.subscribe(()=>{let e=g.camera.screenPositonToStagePosition(this.ƀjo.value);e.isEqual(this.ƀks.value)?g.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:t.x,clientY:t.y,pointerType:"mouse"})):this.ƀks.value=e;}).attachToRoot();}ƀaz(t){let i=g.instance.renderer.view.getBoundingClientRect(),r=i.width,s=i.height;if(r<=0||s<=0)return Vector.zero;let n=g.instance.renderer,a=(t.x-i.left)/r*n.screen.width,l=(t.y-i.top)/s*n.screen.height;return a=NumberHelper.clamp(a,0,n.screen.width),l=NumberHelper.clamp(l,0,n.screen.height),new Vector(a,l)}};he=Po([d(),Eo("design:paramtypes",[])],he);var To=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ro=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdo}get lastFocusedPosition(){return this.ƀgk}constructor(t){this.ƀhe=t,this.ƀht=new Action,this.onTargetFocus=this.ƀht.notifier,this.ƀln=0,this.ƀlo=false,this.ƀdo=false,this.ƀgk=void 0,m.beforeSceneUpdateAction.subscribe(e=>this.ƀlr(e.delta)).attachToRoot();}ƀlr(t){if(this.ƀhf){let e=this.ƀeq(this.ƀhe.stagePosition.value,this.ƀhf);this.ƀif===void 0?this.ƀif=e:this.ƀav(e,t);}this.ƀhf=this.ƀhe.stagePosition.value;}ƀav(t,e){this.ƀif-t>10?(this.ƀln=Math.max(250,this.ƀln),this.ƀlo=true):this.ƀln>1e3&&(this.ƀlo=true);let i=this.ƀln>=300&&this.ƀlo;this.ƀgg(i,t,e);}ƀgg(t,e,i){(t||e>this.ƀif)&&(this.ƀif=e),t?(this.ƀlo=false,this.ƀln=0,this.ƀdo=true,this.ƀgk=this.ƀhe.stagePosition.value,this.ƀht.trigger(this.ƀgk)):(this.ƀln+=i,this.ƀdo=false);}ƀeq(t,e){let i=Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};Pi=To([d(),Ro("design:paramtypes",[he])],Pi);var Ei=10.8,Ti=10.01,it;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(it||(it={}));var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new U.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},at=class extends q(){static{h(this,"PhysicsInternalGateway");}};at=Mo([d()],at);var b=class o extends W{static{h(this,"PhysicsEntity");}static{this.ƀhz=new Map;}static{this.ƀij=new Map;}static getFromP2BodyID(t){return o.ƀhz.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhz.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀij.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀij.values())}get area(){return this.ƀu}get mass(){return this.ƀgv}get collisions(){return this.ƀbc}constructor(t,e,i){super(),this.ƀhn=new Action,this.onCollision=this.ƀhn.notifier,this.type="dynamic",this.ƀu=0,this.ƀgv=0,this.ƀbc=[],this.physicsWorldID=t,this.ƀil=S.get(at);let r=this.ƀil.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀil.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀik=this.ƀil.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀim=this.ƀil.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀil.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgv=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀil.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhz.set(this.p2Body.id,this),o.ƀij.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀil.removeBody(this.physicsWorldID,this.p2Body),o.ƀhz.delete(this.p2Body.id),o.ƀij.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀik,this.ƀim,t.ƀik,t.ƀim)}ƀjv(t){this.ƀbc=t,t.length>0&&this.ƀhn.trigger(t);}};var le=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:Vector.zero,rotationalSpeed:0}}};var Ri=class extends W{static{h(this,"MovableEntity");}constructor(){super(),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),m.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀkz(t,e);}).attach(this);}ƀkz(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ii=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),this.ƀfp=false,this.ƀfq=false,this.ƀfs=false,this.ƀfr=false,this.ƀig(),this.ƀgp(),S.get(at).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀkz(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀkz(t,e){this.ƀfp=true,this.ƀfq=true,this.ƀfs=true,this.ƀfr=true,this.ƀig();}ƀig(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀgp(){this.position.subscribe(t=>{this.ƀfp?this.ƀfp=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfq?this.ƀfq=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfs?this.ƀfs=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfr?this.ƀfr=false:this.p2Body.angularVelocity=t;}).attach(this);}};var ht="border";var Fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ce=class extends q(){static{h(this,"PhysicsGateway");}};ce=Fo([d()],ce);var Vo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},No=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends W{static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new Variable(false),this.lastP2Time=new Variable(0),this.onPhysicsStep=new Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=Vo([yt(),No("design:paramtypes",[Vector,Boolean,U.World,Map,Map,Map,Map])],v);var Uo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},X=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};X=Uo([d()],X);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},We=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀii=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀii.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};We=Wo([d(),$o("design:paramtypes",[X])],We);var zo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},lt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀii=t,this.ƀz=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀz.getCollidableGrids(t,i).forEach(s=>{let n=G.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=50){return e.aabbNeedsUpdate=true,e.updateAABB(),Xt.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀz.get(t,e,i);return r||(r=this.ƀcb(t,e,i),this.ƀz.set(t,e,i,r)),r}ƀcb(t,e,i){let r=new Grid({size:new Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀii.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀeh(s,e);r.setArea(a,false);}}),r}ƀeh(t,e){let i=f.aabbToBoundingBox(t.aabb);return G.areaToGridArea(i,e)}};lt=zo([d(),ko("design:paramtypes",[X,We])],lt);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Nt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀih=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=50);let n=v.getInstanceByIDOrFail(t),a,l;Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=G.positionToGridPosition(e,s.gridCellSize),p=G.positionToGridPosition(a,s.gridCellSize),y=this.ƀih.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let A=f.aabbToBoundingBox(l.aabb),Tt=G.areaToGridArea(A,s.gridCellSize);y.setArea(Tt,true);}let w=Kt.findPath(y,c,p,s.neighborType);return w.path=w.path.map(A=>G.gridPositionToPosition(A,s.gridCellSize)),w}findPathDirection(t,e,i,r,s=50){let n=v.getInstanceByIDOrFail(t),a;if(Comparator.isNumber(i)){let w=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(w.p2Body.aabb);}else a=new Rectangle(i,i);let l=G.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let w=this.ƀih.getAvilabilityGrid(n,s,r);p=new Zt(l,w),n.vectorFieldCache.set(c,p);}let y=G.positionToGridPosition(e,s);return p.getDirectionToTarget(y)}};Nt=Xo([d(),Ko("design:paramtypes",[lt])],Nt);var Qo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},tn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Z=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀaa=t,this.ƀib=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀaa.getAvilabilityGrid(a,n,r).map((c,p)=>({position:G.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀib.findPathDirection(t,c.position,i,r),y;p===void 0?y=T.createRectangleBorders(new Vector(8,8),2,ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):y=T.createArrow(25,c.availability?ColorHelper.green:ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new I(y,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>y.destroy()).attach(y);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new I(a,"alpha",{duration:n,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let y=p.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(p.line.from,p.line.to,y).toSprite().displayParent(l).attach(t);}),new I(l,"alpha",{duration:a,animation:x.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new Radian(t.angle),n=i?.color??ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcw(c,n).displayParent(a).attachToRoot();}),new I(a,"alpha",{duration:1e3,animation:x.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcw(t,e){switch(t.type){case U.Shape.PARTICLE:throw new Error("Not implemented");case U.Shape.LINE:throw new Error("Not implemented");case U.Shape.PLANE:throw new Error("Not implemented");case U.Shape.CIRCLE:throw new Error("Not implemented");case U.Shape.CAPSULE:throw new Error("Not implemented");case U.Shape.BOX:throw new Error("Not implemented");case U.Shape.HEIGHTFIELD:throw new Error("Not implemented");case U.Shape.CONVEX:return this.ƀcv(t,e);default:throw new Error("Not implemented")}}ƀcv(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Z=Qo([d(),tn("design:paramtypes",[lt,Nt])],Z);var sn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},on=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},$e=class{static{h(this,"HitTestService");}constructor(t){this.ƀlg=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdt(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new U.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?ColorHelper.red:ColorHelper.green;this.ƀlg.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdt(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};$e=sn([d(),on("design:paramtypes",[Z])],$e);var an=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ze=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀjg(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀbc=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀjg(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀff(r.p2Body),r.entity.ƀjv(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀff(t){let e=f.arrayToVector(t.velocity);e.length>Ei&&(e=e.normalize(Ei),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-Ti),Ti);}ƀjg(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdz(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdz(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeo(i);return {collisionDetailsA:this.ƀdy(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdy(s,i.bodyB.mass,a,c,e.area)}}ƀdy(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeo(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};ze=an([d()],ze);var hn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ln=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ke=class extends le{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};ke=hn([yt(),ln("design:paramtypes",[Number,Object])],ke);var cn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=1e4,Je=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbv(t,new Vector(e.x/2,-j/2),new Vector(e.x+j*2,j),i),this.ƀbv(t,new Vector(e.x/2,e.y+j/2),new Vector(e.x+j*2,j),i),this.ƀbv(t,new Vector(-j/2,e.y/2),new Vector(j,e.y+j*2),i),this.ƀbv(t,new Vector(e.x+j/2,e.y/2),new Vector(j,e.y+j*2),i);}ƀbv(t,e,i,r){return new ke(t,{shapeDefinition:{materialName:ht,group:r,shapeType:it.Rectangle,shapeData:i},position:e,rotation:Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};Je=cn([d()],Je);var dn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},fr=new U.Material,un={id:ht,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Lt=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new U.Material),n.set(a.id,a);}),s.has(ht))throw new Error(`Material with name ${ht} cannot be defined, pick another name for the material.`);return s.set(ht,fr),n.set(ht,un),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀem(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀel(e,i.materialDefinitions)}ƀem(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀel(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀee(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀem(n.materialA,s),l=this.ƀem(n.materialB,s);t.addContactMaterial(new U.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀee(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀem(s.id,r);t.addContactMaterial(new U.ContactMaterial(n,fr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Lt=dn([d()],Lt);var fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ht=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgz=t,this.ƀaj=e,this.ƀaa=i,this.ƀbd=r,this.ƀii=s;}createPhysicsWorld(t){let e=new U.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgz.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀii.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&m.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀbd.registerPhysicsWorld(a),t.modifyUpdateCycle?m.registerUpdateModifier((l,c)=>this.ƀkz(a,l,c)):m.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀkz(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀaa.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀkz(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀbd.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ht=fn([d(),mn("design:paramtypes",[Lt,Je,lt,ze,X])],Ht);var gn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ut=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new U.RaycastResult,s=new U.Ray({mode:U.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbq(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new U.Ray({mode:U.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbq(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbq(n,e));},"callback")});return t.p2World.raycast(new U.RaycastResult,s),Array.from(r.values())}ƀbq(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Ut=gn([d()],Ut);var wn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},dt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};dt=wn([d()],dt);var xn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Wt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbr(r,t.length))}ƀbr(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Wt=xn([d()],Wt);var bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Tn=15,Xe=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcg(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀjb.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀlg.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(y=>{let{p2Body:w,...A}=y;return A})}ƀcg(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(Radian.get90).vector,p=c.normalize(i.x);a.push(new Line(t,t.add(p))),a.push(new Line(t,t.add(p.multiplyNumber(-1))));let y=l.normalize(i.y);a.push(new Line(t,t.add(y))),a.push(new Line(t,t.add(y.multiplyNumber(-1))));let w=Math.round(i.y/Tn),A=i.y/(w*2+1)*2,Tt=l.normalize(A),pe=i.x,yr=Math.pow(i.y,2);return ArrayHelper.createIntegerArray(w).forEach(ft=>{let Rt=A*(ft+1),Oi=Tt.multiplyNumber(ft+1),de=c.normalize(this.ƀex(pe,yr,Rt)),ue=t.add(Oi);a.push(new Line(ue,ue.add(de))),a.push(new Line(ue,ue.add(de.multiplyNumber(-1))));let fe=t.add(Oi.multiplyNumber(-1));a.push(new Line(fe,fe.add(de))),a.push(new Line(fe,fe.add(de.multiplyNumber(-1))));}),a.map(ft=>{if(s){let Rt=this.ƀjc.castClosest(n,ft,r);return {line:ft,hits:Rt?[Rt]:[]}}else {let Rt=this.ƀjc.castAllFirstContacts(n,ft,r);return {line:ft,hits:Rt}}})}ƀex(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀft.applyImpulse(r.body,r.hitPosition(),s,n);});});}};Xe=bn([d(),Sn("design:paramtypes",[Ut,Z,Wt,dt])],Xe);var Rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},In=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ke=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀjc=t,this.ƀlg=e,this.ƀjb=i,this.ƀft=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeu(i),c=this.ƀcg(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀjb.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀlg.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcg(t,e,i,r,s,n){let a=new Radian(PI_360/r),l=new Vector(0,-e),c=a.vector;return ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new Line(t,p)}).map(p=>{if(s){let y=this.ƀjc.castClosest(n,p,i);return {line:p,hits:y?[y]:[]}}else {let y=this.ƀjc.castAllFirstContacts(n,p,i);return {line:p,hits:y}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀft.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀft.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeu(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};Ke=Rn([d(),In("design:paramtypes",[Ut,Z,Wt,dt])],Ke);var Mn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},$t=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};$t=Mn([d()],$t);var Bn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Gn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ai=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀip=t,this.ƀib=e,this.ƀlg=i,this.ƀdh=r,this.ƀda=s,this.ƀfk=n,this.ƀio=a,this.ƀft=l;}createPhysicsWorld(t){return this.ƀip.createPhysicsWorld(t)}getMapSize(t){return this.ƀio.getMapSize(t)}setPaused(t,e){this.ƀip.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀfk.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀib.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀib.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀft.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdh.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀda.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=50){this.ƀlg.printPathfindingTestGrid(t,e,i,r,s,n);}};Ai=Bn([Q(ce),Gn("design:paramtypes",[Ht,Nt,Z,Ke,Xe,$e,$t,dt])],Ai);var _n=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ze=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case it.Point:return this.ƀbx(n,void 0,i,r,e.shapeDefinition.group,s);case it.Circle:return this.ƀbx(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case it.Polygon:return this.ƀcf(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case it.Rectangle:return this.ƀch(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbx(t,e,i,r,s,n){let a=new U.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new U.Body({type:n==="dynamic"?U.Body.DYNAMIC:U.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcf(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(w=>new U.Convex({vertices:w.map(A=>[A.x,A.y]),collisionGroup:a,collisionMask:l})).map(w=>(w.material=i,w)),p=c.reduce((w,A)=>w+A.area,0),y=new U.Body({type:n==="dynamic"?U.Body.DYNAMIC:U.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(w=>y.addShape(w)),y.setDensity(r.density),y}ƀch(t,e,i,r,s,n){let a=new U.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new U.Body({type:n==="dynamic"?U.Body.DYNAMIC:U.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};Ze=_n([d()],Ze);var Fn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ci=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀip=t,this.ƀin=e,this.ƀkf=i,this.ƀio=r,this.ƀii=s;}createBody(t,e,i,r,s){return this.ƀkf.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀin.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀin.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀii.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀii.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀip.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀip.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀio.subscribeToPhysicsStep(t,e)}};Ci=Fn([Q(at),Vn("design:paramtypes",[Ht,Lt,Ze,$t,X])],Ci);export{nt as AdvancedSound,Bi as AnimationFlicker,V as AnimationInterpolationFunctions,x as Animations,E as AnimationsCompletionHandlingType,I as Animator,ht as BORDER_MATERIAL_NAME,R as BardLegendsHardReset,Ct as BlendMode,ee as Camera,st as CameraGateway,Xt as ClosestAvailableSpaceHelper,u as Container,At as ContainerEventType,Q as ControllerDecorator,ti as Cursor,D as DEFAULT_SHADER_RESOLUTION,ni as DeltaTime,gi as DisplayObjectArray,W as Entity,yt as EntityDecorator,Hi as FadeInContent,ot as FocusingAnimation,g as Game,q as Gateway,T as Graphics,le as ImmovablePhysicsEntity,Si as KeyboardService,xi as MenuEntity,ne as MenuUI,vi as MenuView,he as MouseService,Pi as MouseTargetFocusService,Ri as MovableEntity,Ii as MovablePhysicsEntity,se as Music,mi as MusicPlayer,Kt as PathFinder,b as PhysicsEntity,ce as PhysicsGateway,it as PhysicsShapeType,hi as Placeholder,Ti as ROTATIONAL_SPEED_LIMIT,C as ReAnimateHandlingType,li as RichText,Y as SOUND_TRANSITION_DURATION,Ei as SPEED_LIMIT,me as Scene,Cr as SceneDecorator,bi as ScrollAreaUI,tt as ScrollDirection,xt as ScrollMaskUI,S as Service,d as ServiceDecorator,gt as SingletonEntity,Ji as SlideInContent,oi as SlideInContentByIndex,Ie as SlideStateAnimation,et as SlideStateAnimationState,ie as Sound,k as Sprite,Dt as StateAnimation,Qt as Text,be as ThroughEmptyStateAnimation,yi as UpdatableContainer,m as UpdateCycle,Zt as VectorFieldPathFinder,bt as VectorSet,mt as View,Qe as ViewDecorator};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bard-legends-framework",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Bard Legends Framework",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {