bard-legends-framework 1.1.1 → 1.1.3

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
@@ -1,4 +1,4 @@
1
- 'use strict';var actionsLib=require('actions-lib');require('reflect-metadata');var helpersLib=require('helpers-lib'),W=require('p2'),V=require('pixi.js'),scriptEngineLib=require('script-engine-lib');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var W__default=/*#__PURE__*/_interopDefault(W);var V__namespace=/*#__PURE__*/_interopNamespace(V);var lr=Object.defineProperty;var h=(o,t)=>lr(o,"name",{value:t,configurable:true});var G=class{static{h(this,"BardLegendsHardReset");}static{this.ƀet=new actionsLib.Action;}static{this.onHardReset=this.ƀet.notifier;}static hardReset(){actionsLib.ActionLib.hardReset(),this.ƀet.trigger();}};function d(){return function(o){let t=P.ƀed(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var P=class{static{h(this,"Service");}static{this.ƀit=new Map;}static get(t){let e=this.ƀit.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀif([],t.$meta.paramtypes);e=new t(...i),this.ƀit.set(t,e);}return e}static ƀed(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e}static ƀif(t,e){let i=[...t];if(e.length>t.length){let s=e.slice(t.length).map(n=>{if(n&&n.$meta?.type==="service")return this.get(n)});i.push(...s);}return i}};G.onHardReset.subscribe(()=>{P.ƀit=new Map;}).attachToRoot();var U=class{static{h(this,"ControllerLink");}constructor(){this.ƀbn=[],this.ƀie=[];}trigger(t,...e){let i=this.ƀbn.find(r=>!!r[t]);if(i)return i[t](...e);throw new Error(`ServiceLink: no defined function with the name: "${t}", found in the linked controllers!`)}registerController(t){Reflect.ownKeys(t.constructor.prototype).filter(e=>e!=="constructor").map(e=>e.toString()).forEach(e=>{if(this.ƀie.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀie.push(e);}),this.ƀbn.push(t);}};function q(o){return function(t){let e=P.ƀed(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=P.ƀif([],e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);o.controllerLink.registerController(r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var y=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new actionsLib.Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀil=new actionsLib.Action;}static{this.sceneUpdateAction=this.ƀil.notifier;}static{this.ƀf=new actionsLib.Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀjx=0;}static{this.ƀkf=void 0;}static wait(t){let e=this.ƀjx+t;return actionsLib.SingleEvent.create(i=>{let r=o.beforeSceneUpdateAction.subscribe(s=>{s.time>=e&&i();}).attachToRoot();return ()=>r.destroy()})}static registerUpdateModifier(t){if(!this.ƀkf)this.ƀkf=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkf=void 0;}static triggerUpdateTick(t){this.ƀkf&&(t=this.ƀkf(this.ƀjx,t)),this.ƀjx+=t,this.ƀfs=t,t>0&&(o.ƀad.trigger({time:this.ƀjx,delta:t}),o.ƀil.trigger({time:this.ƀjx,delta:t}),o.ƀf.trigger({time:this.ƀjx,delta:t}));}static get lastDelta(){return this.ƀfs}static{this.ƀfs=0;}};G.onHardReset.subscribe(()=>{y.ƀad.clear(),y.ƀil.clear(),y.ƀf.clear(),y.ƀkf=void 0,y.ƀjx=0;}).attachToRoot();var _=class o{static{h(this,"EntityStoreHelper");}static{this.ƀax=new Map;}static registerEntityClass(t){this.ƀax.set(t.id,new Map);}static registerEntity(t){this.ƀax.get(t.classID).set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀax.get(i)?.delete(e);}static getEntity(t,e){return this.ƀax.get(t.id)?.get(e)}static getSingleton(t){let e=o.getEntities(t);if(e.length>1)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has multiple instances! Name: "${this.name}"`);return e[0]}static getSingletonOrFail(t){let e=this.getSingleton(t);if(!e)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has no instance! Name: "${this.name}"`);return e}static getEntities(t){let e=this.ƀax.get(t.id);return Array.from(e.values())}};G.onHardReset.subscribe(()=>{_.ƀax.clear();}).attachToRoot();var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀko=new Map;}static registerView(t,e){o.ƀko.has(e)||o.ƀko.set(e,[]);let i=o.ƀko.get(e);i&&i.push(t),_.getEntities(e).forEach(s=>{this.ƀci(s,t);});}static ƀci(t,e){try{let i=P.ƀif([this],e.$meta.paramtypes);o.entityID=t.id;let r=new e(t,...i.slice(1));t.destroyed?r.destroy():t.ƀkn.ƀkp.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcx=t,this.ƀkp=[];}createViews(){if(!this.ƀcx.destroyed){let t=o.ƀko.get(this.ƀcx.constructor);t&&t.forEach(e=>{o.ƀci(this.ƀcx,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkp.length;i++){let r=this.ƀkp[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkp.forEach(t=>{t.destroy();});}};G.onHardReset.subscribe(()=>{rt.ƀko=new Map;}).attachToRoot();function dt(){return function(o){o.$meta={type:"entity"},_.registerEntityClass(o);}}h(dt,"EntityDecorator");var $=class extends actionsLib.IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return _.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=_.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return _.getEntities(this)}constructor(){super(),this.ƀkn=new rt(this),_.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀkn.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀkn.destroyViews(),_.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀkn.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀkn.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀkn.createViews(),this}update(t,e){}};var ut=class extends ${static{h(this,"SingletonEntity");}static getInstance(){return _.getSingleton(this)}static getInstanceOrFail(){return _.getSingletonOrFail(this)}constructor(){if(super(),this.constructor.getEntities().length>1)throw this.attachToRoot(),new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! "${this}"`)}};function yr(){return function(o){return o.$meta={paramtypes:P.ƀed(o),type:"scene"},o}}h(yr,"SceneDecorator");var St=class o extends actionsLib.IDAttachable{static{h(this,"Scene");}static{this.ƀik=false;}static{this.ƀb=new actionsLib.Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveScene(){return o.ƀb.value}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static isActive(){return o.ƀb.value instanceof this}static getInstance(){return o.ƀb.value instanceof this?o.ƀb.value:void 0}static getInstanceOrFail(){if(!o.ƀb.value)throw new Error("Scene: getInstance is called when there is no active scene!");if(!(o.ƀb.value instanceof this))throw new Error(`Scene: getInstance is called while "${this.name}" was not the active scene. Current scene is: "${o.ƀb.value}"!`);return o.ƀb.value}static open(...t){if(o.ƀik)throw new Error("Scene: you cannot open a scene while a scene is transitioning!");if(o.ƀb.value)throw new Error("Scene: you cannot open a scene while there is already another active scene!");let e=t[0];o.ƀik=true;let i=P.ƀif([],this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀik=false,r)).chainToRoot()}constructor(){super(),this.ƀgo=new actionsLib.Action,this.onClose=this.ƀgo.notifier,y.sceneUpdateAction.subscribe(t=>this.update(t.time,t.delta)).attach(this);}close(...t){if(o.ƀb.value!==this)throw new Error("Internal Error: Scene instance is accessed while it is not the active scene!");if(o.ƀik)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀik=true;let e=t[0];return this.prepareToClose().map(()=>(super.destroy(),o.ƀb.set(void 0),o.ƀik=false,this.ƀgo.trigger(e),e)).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};G.onHardReset.subscribe(()=>{St.ƀb.set(void 0);}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:P.ƀed(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var Wt=class extends actionsLib.IDAttachable{static{h(this,"View");}static getInstance(t){return this.$meta.entity.validateID(t)?this.$meta.viewInstances.get(t):void 0}static getInstanceOrFail(t){if(!this.$meta.entity.validateID(t))throw new Error(`View: getInstance is called with entity id: "${t}", that is not belonging to the class: "${this.$meta.entity}"`);let i=this.$meta.viewInstances.get(t);if(!i)throw new Error(`View: getInstanceOrFail is called with entity id: "${t}", that is not found!`);return i}constructor(){super(),this.attachToRoot(),this.ƀcy=rt.entityID,this.ƀej().set(this.ƀcy,this);}destroy(){this.destroyed||(super.destroy(),this.ƀej().delete(this.ƀcy));}update(t,e){}ƀej(){return this.constructor.$meta.viewInstances}};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 W__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Pr=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=new U,Ct=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return J.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return J.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return J.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return J.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return J.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return J.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return J.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return J.trigger("subscribeToPhysicsStep",t,e)}};Ct=Pr([d()],Ct);var b=class o extends ${static{h(this,"PhysicsEntity");}static{this.ƀhd=new Map;}static{this.ƀhk=new Map;}static getFromP2BodyID(t){return o.ƀhd.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhd.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhk.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhk.values())}get area(){return this.ƀu}get mass(){return this.ƀge}get collisions(){return this.ƀaz}constructor(t,e,i){super(),this.ƀgp=new actionsLib.Action,this.onCollision=this.ƀgp.notifier,this.type="dynamic",this.ƀu=0,this.ƀge=0,this.ƀaz=[],this.physicsWorldID=t,this.ƀhm=P.get(Ct);let r=this.ƀhm.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhm.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀhl=this.ƀhm.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhn=this.ƀhm.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhm.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀge=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhm.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.ƀhd.set(this.p2Body.id,this),o.ƀhk.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhm.removeBody(this.physicsWorldID,this.p2Body),o.ƀhd.delete(this.p2Body.id),o.ƀhk.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀhl,this.ƀhn,t.ƀhl,t.ƀhn)}ƀiu(t){this.ƀaz=t,t.length>0&&this.ƀgp.trigger(t);}};var Ut=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 Xe=class extends ${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),y.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀjm(t,e);}).attach(this);}ƀjm(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 Ke=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.ƀfa=false,this.ƀfb=false,this.ƀfd=false,this.ƀfc=false,this.ƀhh(),this.ƀfy(),P.get(Ct).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjm(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}}ƀjm(t,e){this.ƀfa=true,this.ƀfb=true,this.ƀfd=true,this.ƀfc=true,this.ƀhh();}ƀhh(){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;}ƀfy(){this.position.subscribe(t=>{this.ƀfa?this.ƀfa=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfb?this.ƀfb=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfd?this.ƀfd=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.angularVelocity=t;}).attach(this);}};var Ze=10.8,Qe=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 st="border";var Y=class{static{h(this,"AnimationInterpolationFunctions");}static boomerangTime(t){return 1-Math.abs(t-.5)*2}static lineer(t){return t}static easeIn(t){return Math.pow(t,2)}static easeOut(t){return 1-Math.pow(1-t,2)}static easeInOut(t){return t<.5?2*t*t:(t-=1,1-2*t*t)}static easeInOutCubic(t){let e=2*t-2;return t<.5?4*Math.pow(t,3):(t-1)*Math.pow(e,2)+1}},Er=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return Y.lineer(t)}},Rr=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return Y.easeIn(t)}},Ir=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return Y.easeOut(t)}},Ar=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return Y.easeInOut(t)}},Or=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return Y.easeInOutCubic(t)}},Ai=class{static{h(this,"AnimationFlicker");}start(){this.ƀjy=new Array(10).fill(0),helpersLib.Random.integerBetween(0,9),this.ƀjy[helpersLib.Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(helpersLib.Random.integerBetween(0,9),this.ƀjy[helpersLib.Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(helpersLib.Random.integerBetween(0,9),this.ƀjy[helpersLib.Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀjy[e]}},S=class{static{h(this,"Animations");}static{this.lineer=new Er;}static{this.easeIn=new Rr;}static{this.easeOut=new Ir;}static{this.easeInOut=new Ar;}static{this.easeInOutCubic=new Or;}};exports.ReAnimateHandlingType=void 0;(function(o){o[o.ThrowError=1]="ThrowError",o[o.IgnoreNewAnimation=2]="IgnoreNewAnimation",o[o.CompletePrevious=3]="CompletePrevious";})(exports.ReAnimateHandlingType||(exports.ReAnimateHandlingType={}));exports.AnimationsCompletionHandlingType=void 0;(function(o){o[o.ReturnToOriginal=1]="ReturnToOriginal",o[o.StayInCurrentState=2]="StayInCurrentState",o[o.JumpToEnd=3]="JumpToEnd",o[o.Loop=4]="Loop";})(exports.AnimationsCompletionHandlingType||(exports.AnimationsCompletionHandlingType={}));var A=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdk(t){let e=o.ƀk.get(t);return e||(e=new helpersLib.MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀgy!==void 0}get target(){return this.ƀjp}get value(){return this.ƀkh||(this.ƀkh=new actionsLib.Variable(this.ƀjp)),this.ƀkh.notifier}constructor(t,e,i){this.ƀfm=false,this.ƀjb=false,this.ƀjp=t,this.ƀhb={duration:200,animation:S.lineer,reAnimateHandling:exports.ReAnimateHandlingType.ThrowError,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState,...i},this.ƀl=helpersLib.Comparator.isArray(e)?e:[e],this.ƀfz(t,this.ƀl);}animate(t,e){let i={...this.ƀhb,...e};if(this.ƀgy)switch(i.reAnimateHandling){case exports.ReAnimateHandlingType.ThrowError:throw new Error("Animator: new animation triggered while another is not complete yet.");case exports.ReAnimateHandlingType.IgnoreNewAnimation:return actionsLib.SingleEvent.instant();case exports.ReAnimateHandlingType.CompletePrevious:this.ƀiv(i.completionHandling,this.ƀgy.ƀhw,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return actionsLib.SingleEvent.create(s=>{this.ƀfm&&(this.ƀjb=true);let n=this.ƀl.reduce((c,p)=>(c[p]={ƀjj:this.ƀjp[p],ƀjr:t[p]},c),{}),a={ƀct:i.duration,ƀcu:0,ƀhw:n,ƀbg:i.completionHandling,ƀm:i.animation,ƀbf:s};if(a.ƀbg!==exports.AnimationsCompletionHandlingType.Loop&&this.ƀfk(a)){this.ƀgy=void 0,s();return}else a.ƀm.start();let l=this.ƀgy;return this.ƀgy=a,this.ƀcw(),l?.ƀbf(),()=>{this.ƀgy===a&&(this.ƀjp instanceof actionsLib.Attachable&&this.ƀjp.destroyed||this.ƀiv(a.ƀbg,a.ƀhw,true),this.ƀgy=void 0,this.ƀke?.destroy(),this.ƀke=void 0);}})}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjp[r]!==t[r]&&(e=true,this.ƀjp[r]=t[r]);}e&&this.ƀkh?.set(this.ƀjp),this.ƀgy?.ƀbf();}completeAnimation(t){if(this.ƀgy){t=t??this.ƀgy.ƀbg,this.ƀiv(t,this.ƀgy.ƀhw,true);let e=this.ƀgy.ƀbf;this.ƀgy=void 0,e();}}ƀcw(){this.ƀke||(this.ƀke=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfm=true;try{let e=this.ƀgy;if(!e)return;e.ƀcu+=t.delta;let i=e.ƀcu>=e.ƀct;if(i)if(e.ƀbg===exports.AnimationsCompletionHandlingType.Loop)e.ƀcu%=e.ƀct,e.ƀm.start(),i=!1;else {this.ƀiv(e.ƀbg,e.ƀhw,!1),this.ƀgy=void 0,e.ƀbf(),this.ƀgy||(this.ƀke?.destroy(),this.ƀke=void 0);return}if(!i){let r=e.ƀm.multiplierFunction(e.ƀcu/e.ƀct),s=!1;for(let n=0;n<this.ƀl.length;n++){let a=this.ƀl[n],l=e.ƀhw[a],p=(l.ƀjr-l.ƀjj)*r+l.ƀjj;p!==this.ƀjp[a]&&(s=!0,this.ƀjp[a]=p);}s&&this.ƀkh?.set(this.ƀjp);}}finally{this.ƀfm=false,this.ƀjb&&(this.ƀjb=false,this.ƀke?.destroy(),this.ƀke=void 0,this.ƀcw());}}).attachToRoot());}ƀfk(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjp[i]!==t.ƀhw[i].ƀjr)return false}return true}ƀiv(t,e,i){switch(t){case exports.AnimationsCompletionHandlingType.ReturnToOriginal:this.ƀih(e);break;case exports.AnimationsCompletionHandlingType.StayInCurrentState:i||this.ƀfp(e);break;case exports.AnimationsCompletionHandlingType.JumpToEnd:this.ƀfp(e);break;case exports.AnimationsCompletionHandlingType.Loop:this.ƀih(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀih(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjp[r]!==t[r].ƀjj&&(e=true,this.ƀjp[r]=t[r].ƀjj);}e&&this.ƀkh?.set(this.ƀjp);}ƀfp(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjp[r]!==t[r].ƀjr&&(e=true,this.ƀjp[r]=t[r].ƀjr);}e&&this.ƀkh?.set(this.ƀjp);}ƀfz(t,e){let i=o.ƀdk(t);for(let r of e){if(i.has(r))throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(t,void 0,2)}", Property: "${r}"`);i.set(r,this);}}};exports.ContainerEventType=void 0;(function(o){o.Click="click",o.MouseOver="mouseover",o.MouseOut="mouseout",o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerUpOutside="pointerupoutside",o.PointerMove="pointermove",o.PointerCancel="pointercancel",o.PointerOver="pointerover",o.PointerOut="pointerout",o.PointerEnter="pointerenter",o.PointerLeave="pointerleave",o.Added="added",o.Removed="removed",o.Update="update",o.Change="change";})(exports.ContainerEventType||(exports.ContainerEventType={}));exports.Cursor=void 0;(function(o){o.Default="default",o.Pointer="pointer";})(exports.Cursor||(exports.Cursor={}));var ue=class extends actionsLib.IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgi=false,this.ƀdd=false,this.ƀii=1,this.ƀw=1,this.pixiContainer=new V__namespace.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new helpersLib.Vector(this.pixiContainer.width,this.pixiContainer.height)}setSize(t){return this.pixiContainer.width=t.x,this.pixiContainer.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.pixiContainer.getLocalBounds(),r=new helpersLib.Vector(this.pixiContainer.scale.x,this.pixiContainer.scale.y),s=new helpersLib.Vector(i.x,i.y).multiply(r),n=new helpersLib.Vector(i.width,i.height).multiply(r),a=s.add(n.multiply(e.holdFrom));t=t.subtract(a);}return e?.round!==false&&(t=t.round({rollHalfsDown:true})),this.position=t,this}get position(){return new helpersLib.Vector(this.pixiContainer.x,this.pixiContainer.y)}set position(t){this.pixiContainer.position=t;}get x(){return this.pixiContainer.x}set x(t){this.pixiContainer.x=t;}get y(){return this.pixiContainer.y}set y(t){this.pixiContainer.y=t;}on(t){return actionsLib.Sequence.create(e=>{let i=h(r=>e(),"handle");return this.pixiContainer.on(t,i),()=>this.pixiContainer.off(t,i)})}setRotation(t){return this.rotation=t,this}get rotation(){return new helpersLib.Radian(this.pixiContainer.rotation)}set rotation(t){this.pixiContainer.rotation=t.value;}get rotationValue(){return this.rotation.value}set rotationValue(t){this.rotation=new helpersLib.Radian(t);}setZIndex(t){return this.zIndex=t,this}get zIndex(){return this.pixiContainer.zIndex}set zIndex(t){this.pixiContainer.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new helpersLib.Radian(this.pixiContainer.skew.x)}set skewX(t){this.pixiContainer.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new helpersLib.Radian(this.pixiContainer.skew.y)}set skewY(t){this.pixiContainer.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.pixiContainer.sortableChildren}set sortableChildren(t){this.pixiContainer.sortableChildren=t;}setAlpha(t){return this.pixiContainer.alpha=t,this}get alpha(){return this.pixiContainer.alpha}set alpha(t){this.pixiContainer.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.pixiContainer.interactive}set interactive(t){t?this.pixiContainer.eventMode="dynamic":this.pixiContainer.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.pixiContainer.cursor}set cursor(t){this.pixiContainer.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.pixiContainer.addChild(t.pixiContainer),this.pixiContainer.mask=t.getMask(),this.ƀgc=t):(this.ƀgc&&this.pixiContainer.removeChild(this.ƀgc.pixiContainer),this.pixiContainer.mask=null),this}hitTest(t){if(this.pixiContainer.parent)if(this.pixiContainer.hitArea){let e=this.pixiContainer.toLocal(t);return this.pixiContainer.hitArea.contains(e.x,e.y)}else return this.pixiContainer.getBounds().contains(t.x,t.y);else return false}get boundingBox(){let t=this.pixiContainer.getLocalBounds();return new helpersLib.Rectangle(new helpersLib.Vector(t.x,t.y),new helpersLib.Vector(t.x+t.width,t.y+t.height))}ignoreBounds(t=true){return t?(this.ƀhc||(this.ƀhc=this.pixiContainer.calculateBounds),this.pixiContainer.calculateBounds=()=>this.pixiContainer.ƀal.clear()):this.ƀhc&&(this.pixiContainer.calculateBounds=this.ƀhc),this}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgi}set mirror(t){this.ƀgi=t,this.ƀkg();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdd}set flip(t){this.ƀdd=t,this.ƀkg();}setScale(t){return this.scale=t,this}get scale(){return this.ƀii}set scale(t){this.ƀii=t,this.ƀkg();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀkg();}ƀkg(){this.pixiContainer.scale.set(this.ƀii,this.ƀii),this.ƀw<1?this.pixiContainer.scale.x*=this.ƀw:this.ƀw>1&&(this.pixiContainer.scale.y/=this.ƀw),this.ƀgi&&(this.pixiContainer.scale.x*=-1),this.ƀdd&&(this.pixiContainer.scale.y*=-1);}};var O=2;exports.BlendMode=void 0;(function(o){o[o.Normal=0]="Normal",o[o.Add=1]="Add",o[o.Screen=3]="Screen",o[o.Luminosity=16]="Luminosity",o[o.ColorDodge=7]="ColorDodge";})(exports.BlendMode||(exports.BlendMode={}));var fe=class{static{h(this,"GaussianValuesHelper");}static ƀdi(t,e){let i=e*e,r=1/(helpersLib.PI_360*i),s=-(t*t)/(2*i);return r*Math.exp(s)}static getValuesForLinearSamplingPascal(t){let e=t*2,i=Math.pow(2,e),r=.005*i,s=helpersLib.NumberHelper.pascalTriangleRow(e).slice(t).filter(l=>{if(l<r)i-=l*2;else return true}),n=1/i,a=s.map(l=>l*n);return this.ƀbs(a)}static getValuesForLinearSamplingGauss(t){if(t===0)return [{offset:0,multiplier:1}];if(t===1)return [{offset:0,multiplier:.5},{offset:1,multiplier:.25}];{let e=helpersLib.ArrayHelper.createIntegerArray(Math.ceil(t*.75)).map(r=>this.ƀdi(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbs(e)}}static ƀbs(t){let e=[{offset:0,multiplier:t[0]}];for(let i=1;i<t.length-1;i+=2){let r=t[i]+t[i+1],s=i+t[i+1]/r;e.push({offset:s,multiplier:r});}if(t.length%2===0){let i=t[t.length-1],r=t.length-1;e.push({offset:r,multiplier:i});}return e}};var Di=class ti extends V__namespace.Filter{static{h(this,"BlurFilterPass");}static ƀei(){return `
1
+ 'use strict';var actionsLib=require('actions-lib');require('reflect-metadata');var helpersLib=require('helpers-lib'),U=require('p2'),V=require('pixi.js'),scriptEngineLib=require('script-engine-lib');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var U__default=/*#__PURE__*/_interopDefault(U);var V__namespace=/*#__PURE__*/_interopNamespace(V);var hr=Object.defineProperty;var h=(o,t)=>hr(o,"name",{value:t,configurable:true});var G=class{static{h(this,"BardLegendsHardReset");}static{this.ƀet=new actionsLib.Action;}static{this.onHardReset=this.ƀet.notifier;}static hardReset(){actionsLib.ActionLib.hardReset(),this.ƀet.trigger();}};function d(){return function(o){let t=P.ƀed(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var P=class{static{h(this,"Service");}static{this.ƀiu=new Map;}static get(t){let e=this.ƀiu.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀig([],t.$meta.paramtypes);e=new t(...i),this.ƀiu.set(t,e);}return e}static ƀed(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e}static ƀig(t,e){let i=[...t];if(e.length>t.length){let s=e.slice(t.length).map(n=>{if(n&&n.$meta?.type==="service")return this.get(n)});i.push(...s);}return i}};G.onHardReset.subscribe(()=>{P.ƀiu=new Map;}).attachToRoot();var $=class{static{h(this,"ControllerLink");}constructor(){this.ƀbn=[],this.ƀie=[];}trigger(t,...e){let i=this.ƀbn.find(r=>!!r[t]);if(i)return i[t](...e);throw new Error(`ServiceLink: no defined function with the name: "${t}", found in the linked controllers!`)}registerController(t){Reflect.ownKeys(t.constructor.prototype).filter(e=>e!=="constructor").map(e=>e.toString()).forEach(e=>{if(this.ƀie.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀie.push(e);}),this.ƀbn.push(t);}};function q(o){return function(t){let e=P.ƀed(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=P.ƀig([],e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);o.controllerLink.registerController(r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var y=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new actionsLib.Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀim=new actionsLib.Action;}static{this.sceneUpdateAction=this.ƀim.notifier;}static{this.ƀf=new actionsLib.Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀjy=0;}static{this.ƀkg=void 0;}static wait(t){let e=this.ƀjy+t;return actionsLib.SingleEvent.create(i=>{let r=o.beforeSceneUpdateAction.subscribe(s=>{s.time>=e&&i();}).attachToRoot();return ()=>r.destroy()})}static registerUpdateModifier(t){if(!this.ƀkg)this.ƀkg=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkg=void 0;}static triggerUpdateTick(t){this.ƀkg&&(t=this.ƀkg(this.ƀjy,t)),this.ƀjy+=t,this.ƀfs=t,t>0&&(o.ƀad.trigger({time:this.ƀjy,delta:t}),o.ƀim.trigger({time:this.ƀjy,delta:t}),o.ƀf.trigger({time:this.ƀjy,delta:t}));}static get lastDelta(){return this.ƀfs}static{this.ƀfs=0;}};G.onHardReset.subscribe(()=>{y.ƀad.clear(),y.ƀim.clear(),y.ƀf.clear(),y.ƀkg=void 0,y.ƀjy=0;}).attachToRoot();var _=class o{static{h(this,"EntityStoreHelper");}static{this.ƀax=new Map;}static registerEntityClass(t){this.ƀax.set(t.id,new Map);}static registerEntity(t){this.ƀax.get(t.classID).set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀax.get(i)?.delete(e);}static getEntity(t,e){return this.ƀax.get(t.id)?.get(e)}static getSingleton(t){let e=o.getEntities(t);if(e.length>1)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has multiple instances! Name: "${this.name}"`);return e[0]}static getSingletonOrFail(t){let e=this.getSingleton(t);if(!e)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has no instance! Name: "${this.name}"`);return e}static getEntities(t){let e=this.ƀax.get(t.id);return Array.from(e.values())}};G.onHardReset.subscribe(()=>{_.ƀax.clear();}).attachToRoot();var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀkp=new Map;}static registerView(t,e){o.ƀkp.has(e)||o.ƀkp.set(e,[]);let i=o.ƀkp.get(e);i&&i.push(t),_.getEntities(e).forEach(s=>{this.ƀci(s,t);});}static ƀci(t,e){try{let i=P.ƀig([this],e.$meta.paramtypes);o.entityID=t.id;let r=new e(t,...i.slice(1));t.destroyed?r.destroy():t.ƀko.ƀkq.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcx=t,this.ƀkq=[];}createViews(){if(!this.ƀcx.destroyed){let t=o.ƀkp.get(this.ƀcx.constructor);t&&t.forEach(e=>{o.ƀci(this.ƀcx,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkq.length;i++){let r=this.ƀkq[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkq.forEach(t=>{t.destroy();});}};G.onHardReset.subscribe(()=>{rt.ƀkp=new Map;}).attachToRoot();function dt(){return function(o){o.$meta={type:"entity"},_.registerEntityClass(o);}}h(dt,"EntityDecorator");var z=class extends actionsLib.IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return _.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=_.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return _.getEntities(this)}constructor(){super(),this.ƀko=new rt(this),_.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀko.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀko.destroyViews(),_.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀko.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀko.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀko.createViews(),this}update(t,e){}};var ut=class extends z{static{h(this,"SingletonEntity");}static getInstance(){return _.getSingleton(this)}static getInstanceOrFail(){return _.getSingletonOrFail(this)}constructor(){if(super(),this.constructor.getEntities().length>1)throw this.attachToRoot(),new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! "${this}"`)}};function gr(){return function(o){return o.$meta={paramtypes:P.ƀed(o),type:"scene"},o}}h(gr,"SceneDecorator");var St=class o extends actionsLib.IDAttachable{static{h(this,"Scene");}static{this.ƀil=false;}static{this.ƀb=new actionsLib.Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveScene(){return o.ƀb.value}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static isActive(){return o.ƀb.value instanceof this}static getInstance(){return o.ƀb.value instanceof this?o.ƀb.value:void 0}static getInstanceOrFail(){if(!o.ƀb.value)throw new Error("Scene: getInstance is called when there is no active scene!");if(!(o.ƀb.value instanceof this))throw new Error(`Scene: getInstance is called while "${this.name}" was not the active scene. Current scene is: "${o.ƀb.value}"!`);return o.ƀb.value}static open(...t){if(o.ƀil)throw new Error("Scene: you cannot open a scene while a scene is transitioning!");if(o.ƀb.value)throw new Error("Scene: you cannot open a scene while there is already another active scene!");let e=t[0];o.ƀil=true;let i=P.ƀig([],this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀil=false,r)).chainToRoot()}constructor(){super(),this.ƀgo=new actionsLib.Action,this.onClose=this.ƀgo.notifier,y.sceneUpdateAction.subscribe(t=>this.update(t.time,t.delta)).attach(this);}close(...t){if(o.ƀb.value!==this)throw new Error("Internal Error: Scene instance is accessed while it is not the active scene!");if(o.ƀil)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀil=true;let e=t[0];return this.prepareToClose().map(()=>(super.destroy(),o.ƀb.set(void 0),o.ƀil=false,this.ƀgo.trigger(e),e)).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};G.onHardReset.subscribe(()=>{St.ƀb.set(void 0);}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:P.ƀed(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var Wt=class extends actionsLib.IDAttachable{static{h(this,"View");}static getInstance(t){return this.$meta.entity.validateID(t)?this.$meta.viewInstances.get(t):void 0}static getInstanceOrFail(t){if(!this.$meta.entity.validateID(t))throw new Error(`View: getInstance is called with entity id: "${t}", that is not belonging to the class: "${this.$meta.entity}"`);let i=this.$meta.viewInstances.get(t);if(!i)throw new Error(`View: getInstanceOrFail is called with entity id: "${t}", that is not found!`);return i}constructor(){super(),this.attachToRoot(),this.ƀcy=rt.entityID,this.ƀej().set(this.ƀcy,this);}destroy(){this.destroyed||(super.destroy(),this.ƀej().delete(this.ƀcy));}update(t,e){}ƀej(){return this.constructor.$meta.viewInstances}};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 br=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=new $,Ct=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return J.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return J.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return J.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return J.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return J.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return J.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return J.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return J.trigger("subscribeToPhysicsStep",t,e)}};Ct=br([d()],Ct);var b=class o extends z{static{h(this,"PhysicsEntity");}static{this.ƀhd=new Map;}static{this.ƀhk=new Map;}static getFromP2BodyID(t){return o.ƀhd.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhd.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhk.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhk.values())}get area(){return this.ƀu}get mass(){return this.ƀge}get collisions(){return this.ƀaz}constructor(t,e,i){super(),this.ƀgp=new actionsLib.Action,this.onCollision=this.ƀgp.notifier,this.type="dynamic",this.ƀu=0,this.ƀge=0,this.ƀaz=[],this.physicsWorldID=t,this.ƀhm=P.get(Ct);let r=this.ƀhm.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhm.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀhl=this.ƀhm.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhn=this.ƀhm.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhm.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀge=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhm.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.ƀhd.set(this.p2Body.id,this),o.ƀhk.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhm.removeBody(this.physicsWorldID,this.p2Body),o.ƀhd.delete(this.p2Body.id),o.ƀhk.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀhl,this.ƀhn,t.ƀhl,t.ƀhn)}ƀiv(t){this.ƀaz=t,t.length>0&&this.ƀgp.trigger(t);}};var Ut=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 Xe=class extends z{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),y.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀjn(t,e);}).attach(this);}ƀjn(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 Ke=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.ƀfa=false,this.ƀfb=false,this.ƀfd=false,this.ƀfc=false,this.ƀhh(),this.ƀfy(),P.get(Ct).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjn(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}}ƀjn(t,e){this.ƀfa=true,this.ƀfb=true,this.ƀfd=true,this.ƀfc=true,this.ƀhh();}ƀhh(){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;}ƀfy(){this.position.subscribe(t=>{this.ƀfa?this.ƀfa=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfb?this.ƀfb=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfd?this.ƀfd=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.angularVelocity=t;}).attach(this);}};var Ze=10.8,Qe=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 st="border";var Y=class{static{h(this,"AnimationInterpolationFunctions");}static boomerangTime(t){return 1-Math.abs(t-.5)*2}static lineer(t){return t}static easeIn(t){return Math.pow(t,2)}static easeOut(t){return 1-Math.pow(1-t,2)}static easeInOut(t){return t<.5?2*t*t:(t-=1,1-2*t*t)}static easeInOutCubic(t){let e=2*t-2;return t<.5?4*Math.pow(t,3):(t-1)*Math.pow(e,2)+1}},Tr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return Y.lineer(t)}},Er=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return Y.easeIn(t)}},Rr=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return Y.easeOut(t)}},Ir=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return Y.easeInOut(t)}},Ar=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return Y.easeInOutCubic(t)}},Ai=class{static{h(this,"AnimationFlicker");}start(){this.ƀjz=new Array(10).fill(0),helpersLib.Random.integerBetween(0,9),this.ƀjz[helpersLib.Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(helpersLib.Random.integerBetween(0,9),this.ƀjz[helpersLib.Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(helpersLib.Random.integerBetween(0,9),this.ƀjz[helpersLib.Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀjz[e]}},S=class{static{h(this,"Animations");}static{this.lineer=new Tr;}static{this.easeIn=new Er;}static{this.easeOut=new Rr;}static{this.easeInOut=new Ir;}static{this.easeInOutCubic=new Ar;}};exports.ReAnimateHandlingType=void 0;(function(o){o[o.ThrowError=1]="ThrowError",o[o.IgnoreNewAnimation=2]="IgnoreNewAnimation",o[o.CompletePrevious=3]="CompletePrevious";})(exports.ReAnimateHandlingType||(exports.ReAnimateHandlingType={}));exports.AnimationsCompletionHandlingType=void 0;(function(o){o[o.ReturnToOriginal=1]="ReturnToOriginal",o[o.StayInCurrentState=2]="StayInCurrentState",o[o.JumpToEnd=3]="JumpToEnd",o[o.Loop=4]="Loop";})(exports.AnimationsCompletionHandlingType||(exports.AnimationsCompletionHandlingType={}));var A=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdk(t){let e=o.ƀk.get(t);return e||(e=new helpersLib.MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀgy!==void 0}get target(){return this.ƀjq}get value(){return this.ƀki||(this.ƀki=new actionsLib.Variable(this.ƀjq)),this.ƀki.notifier}constructor(t,e,i){this.ƀfm=false,this.ƀjc=false,this.ƀjq=t,this.ƀhb={duration:200,animation:S.lineer,reAnimateHandling:exports.ReAnimateHandlingType.ThrowError,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState,...i},this.ƀl=helpersLib.Comparator.isArray(e)?e:[e],this.ƀfz(t,this.ƀl);}animate(t,e){let i={...this.ƀhb,...e};if(this.ƀgy)switch(i.reAnimateHandling){case exports.ReAnimateHandlingType.ThrowError:throw new Error("Animator: new animation triggered while another is not complete yet.");case exports.ReAnimateHandlingType.IgnoreNewAnimation:return actionsLib.SingleEvent.instant();case exports.ReAnimateHandlingType.CompletePrevious:this.ƀiw(i.completionHandling,this.ƀgy.ƀhw,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return actionsLib.SingleEvent.create(s=>{this.ƀfm&&(this.ƀjc=true);let n=this.ƀl.reduce((c,p)=>(c[p]={ƀjk:this.ƀjq[p],ƀjs:t[p]},c),{}),a={ƀct:i.duration,ƀcu:0,ƀhw:n,ƀbg:i.completionHandling,ƀm:i.animation,ƀbf:s};if(a.ƀbg!==exports.AnimationsCompletionHandlingType.Loop&&this.ƀfk(a)){this.ƀgy=void 0,s();return}else a.ƀm.start();let l=this.ƀgy;return this.ƀgy=a,this.ƀcw(),l?.ƀbf(),()=>{this.ƀgy===a&&(this.ƀjq instanceof actionsLib.Attachable&&this.ƀjq.destroyed||this.ƀiw(a.ƀbg,a.ƀhw,true),this.ƀgy=void 0,this.ƀkf?.destroy(),this.ƀkf=void 0);}})}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjq[r]!==t[r]&&(e=true,this.ƀjq[r]=t[r]);}e&&this.ƀki?.set(this.ƀjq),this.ƀgy?.ƀbf();}completeAnimation(t){if(this.ƀgy){t=t??this.ƀgy.ƀbg,this.ƀiw(t,this.ƀgy.ƀhw,true);let e=this.ƀgy.ƀbf;this.ƀgy=void 0,e();}}ƀcw(){this.ƀkf||(this.ƀkf=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfm=true;try{let e=this.ƀgy;if(!e)return;e.ƀcu+=t.delta;let i=e.ƀcu>=e.ƀct;if(i)if(e.ƀbg===exports.AnimationsCompletionHandlingType.Loop)e.ƀcu%=e.ƀct,e.ƀm.start(),i=!1;else {this.ƀiw(e.ƀbg,e.ƀhw,!1),this.ƀgy=void 0,e.ƀbf(),this.ƀgy||(this.ƀkf?.destroy(),this.ƀkf=void 0);return}if(!i){let r=e.ƀm.multiplierFunction(e.ƀcu/e.ƀct),s=!1;for(let n=0;n<this.ƀl.length;n++){let a=this.ƀl[n],l=e.ƀhw[a],p=(l.ƀjs-l.ƀjk)*r+l.ƀjk;p!==this.ƀjq[a]&&(s=!0,this.ƀjq[a]=p);}s&&this.ƀki?.set(this.ƀjq);}}finally{this.ƀfm=false,this.ƀjc&&(this.ƀjc=false,this.ƀkf?.destroy(),this.ƀkf=void 0,this.ƀcw());}}).attachToRoot());}ƀfk(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjq[i]!==t.ƀhw[i].ƀjs)return false}return true}ƀiw(t,e,i){switch(t){case exports.AnimationsCompletionHandlingType.ReturnToOriginal:this.ƀii(e);break;case exports.AnimationsCompletionHandlingType.StayInCurrentState:i||this.ƀfp(e);break;case exports.AnimationsCompletionHandlingType.JumpToEnd:this.ƀfp(e);break;case exports.AnimationsCompletionHandlingType.Loop:this.ƀii(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀii(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjq[r]!==t[r].ƀjk&&(e=true,this.ƀjq[r]=t[r].ƀjk);}e&&this.ƀki?.set(this.ƀjq);}ƀfp(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjq[r]!==t[r].ƀjs&&(e=true,this.ƀjq[r]=t[r].ƀjs);}e&&this.ƀki?.set(this.ƀjq);}ƀfz(t,e){let i=o.ƀdk(t);for(let r of e){if(i.has(r))throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(t,void 0,2)}", Property: "${r}"`);i.set(r,this);}}};exports.ContainerEventType=void 0;(function(o){o.Click="click",o.MouseOver="mouseover",o.MouseOut="mouseout",o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerUpOutside="pointerupoutside",o.PointerMove="pointermove",o.PointerCancel="pointercancel",o.PointerOver="pointerover",o.PointerOut="pointerout",o.PointerEnter="pointerenter",o.PointerLeave="pointerleave",o.Added="added",o.Removed="removed",o.Update="update",o.Change="change";})(exports.ContainerEventType||(exports.ContainerEventType={}));exports.Cursor=void 0;(function(o){o.Default="default",o.Pointer="pointer";})(exports.Cursor||(exports.Cursor={}));var ue=class extends actionsLib.IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgi=false,this.ƀdd=false,this.ƀij=1,this.ƀw=1,this.pixiContainer=new V__namespace.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new helpersLib.Vector(this.pixiContainer.width,this.pixiContainer.height)}setSize(t){return this.pixiContainer.width=t.x,this.pixiContainer.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.pixiContainer.getLocalBounds(),r=new helpersLib.Vector(this.pixiContainer.scale.x,this.pixiContainer.scale.y),s=new helpersLib.Vector(i.x,i.y).multiply(r),n=new helpersLib.Vector(i.width,i.height).multiply(r),a=s.add(n.multiply(e.holdFrom));t=t.subtract(a);}return e?.round!==false&&(t=t.round({rollHalfsDown:true})),this.position=t,this}get position(){return new helpersLib.Vector(this.pixiContainer.x,this.pixiContainer.y)}set position(t){this.pixiContainer.position=t;}get x(){return this.pixiContainer.x}set x(t){this.pixiContainer.x=t;}get y(){return this.pixiContainer.y}set y(t){this.pixiContainer.y=t;}on(t){return actionsLib.Sequence.create(e=>{let i=h(r=>e(),"handle");return this.pixiContainer.on(t,i),()=>this.pixiContainer.off(t,i)})}setRotation(t){return this.rotation=t,this}get rotation(){return new helpersLib.Radian(this.pixiContainer.rotation)}set rotation(t){this.pixiContainer.rotation=t.value;}get rotationValue(){return this.rotation.value}set rotationValue(t){this.rotation=new helpersLib.Radian(t);}setZIndex(t){return this.zIndex=t,this}get zIndex(){return this.pixiContainer.zIndex}set zIndex(t){this.pixiContainer.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new helpersLib.Radian(this.pixiContainer.skew.x)}set skewX(t){this.pixiContainer.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new helpersLib.Radian(this.pixiContainer.skew.y)}set skewY(t){this.pixiContainer.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.pixiContainer.sortableChildren}set sortableChildren(t){this.pixiContainer.sortableChildren=t;}setAlpha(t){return this.pixiContainer.alpha=t,this}get alpha(){return this.pixiContainer.alpha}set alpha(t){this.pixiContainer.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.pixiContainer.interactive}set interactive(t){t?this.pixiContainer.eventMode="dynamic":this.pixiContainer.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.pixiContainer.cursor}set cursor(t){this.pixiContainer.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.pixiContainer.addChild(t.pixiContainer),this.pixiContainer.mask=t.getMask(),this.ƀgc=t):(this.ƀgc&&this.pixiContainer.removeChild(this.ƀgc.pixiContainer),this.pixiContainer.mask=null),this}hitTest(t){if(this.pixiContainer.parent)if(this.pixiContainer.hitArea){let e=this.pixiContainer.toLocal(t);return this.pixiContainer.hitArea.contains(e.x,e.y)}else return this.pixiContainer.getBounds().contains(t.x,t.y);else return false}get boundingBox(){let t=this.pixiContainer.getLocalBounds();return new helpersLib.Rectangle(new helpersLib.Vector(t.x,t.y),new helpersLib.Vector(t.x+t.width,t.y+t.height))}ignoreBounds(t=true){return t?(this.ƀhc||(this.ƀhc=this.pixiContainer.calculateBounds),this.pixiContainer.calculateBounds=()=>this.pixiContainer._bounds.clear()):this.ƀhc&&(this.pixiContainer.calculateBounds=this.ƀhc),this}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgi}set mirror(t){this.ƀgi=t,this.ƀkh();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdd}set flip(t){this.ƀdd=t,this.ƀkh();}setScale(t){return this.scale=t,this}get scale(){return this.ƀij}set scale(t){this.ƀij=t,this.ƀkh();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀkh();}ƀkh(){this.pixiContainer.scale.set(this.ƀij,this.ƀij),this.ƀw<1?this.pixiContainer.scale.x*=this.ƀw:this.ƀw>1&&(this.pixiContainer.scale.y/=this.ƀw),this.ƀgi&&(this.pixiContainer.scale.x*=-1),this.ƀdd&&(this.pixiContainer.scale.y*=-1);}};var O=2;exports.BlendMode=void 0;(function(o){o[o.Normal=0]="Normal",o[o.Add=1]="Add",o[o.Screen=3]="Screen",o[o.Luminosity=16]="Luminosity",o[o.ColorDodge=7]="ColorDodge";})(exports.BlendMode||(exports.BlendMode={}));var fe=class{static{h(this,"GaussianValuesHelper");}static ƀdi(t,e){let i=e*e,r=1/(helpersLib.PI_360*i),s=-(t*t)/(2*i);return r*Math.exp(s)}static getValuesForLinearSamplingPascal(t){let e=t*2,i=Math.pow(2,e),r=.005*i,s=helpersLib.NumberHelper.pascalTriangleRow(e).slice(t).filter(l=>{if(l<r)i-=l*2;else return true}),n=1/i,a=s.map(l=>l*n);return this.ƀbs(a)}static getValuesForLinearSamplingGauss(t){if(t===0)return [{offset:0,multiplier:1}];if(t===1)return [{offset:0,multiplier:.5},{offset:1,multiplier:.25}];{let e=helpersLib.ArrayHelper.createIntegerArray(Math.ceil(t*.75)).map(r=>this.ƀdi(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbs(e)}}static ƀbs(t){let e=[{offset:0,multiplier:t[0]}];for(let i=1;i<t.length-1;i+=2){let r=t[i]+t[i+1],s=i+t[i+1]/r;e.push({offset:s,multiplier:r});}if(t.length%2===0){let i=t[t.length-1],r=t.length-1;e.push({offset:r,multiplier:i});}return e}};var Di=class ti extends V__namespace.Filter{static{h(this,"BlurFilterPass");}static ƀei(){return `
2
2
  attribute vec2 aVertexPosition;
3
3
  attribute vec2 aTextureCoord;
4
4
 
@@ -29,7 +29,7 @@
29
29
  iterate(${s}, ${helpersLib.NumberHelper.toFloatString(t[r].multiplier)}, gl_FragColor);
30
30
  iterate(${s} * -1.0, ${helpersLib.NumberHelper.toFloatString(t[r].multiplier)}, gl_FragColor);`;}return i+=`
31
31
  }
32
- `,i}constructor(t,e){super(ti.ƀei(),ti.ƀdr(fe.getValuesForLinearSamplingGauss(t),e)),this.ƀew=e,this.resolution=O;}apply(t,e,i,r){this.uniforms.pixelSize=this.ƀew?1/(e.width*O):1/(e.height*O),t.applyFilter(this,e,i,r);}},Rt=class extends V__namespace.Filter{static{h(this,"BlurFilter");}constructor(t=new helpersLib.Vector(2,2)){if(super(),this.ƀjn=t,this.resolution=O,this.ƀjn=t.multiplyNumber(O).floor(),this.ƀjn.x<0||this.ƀjn.y<0)throw new Error("BlurFilterLinearSampling: Strength * Resolution must be greater than 0");if(this.ƀjn.x>100||this.ƀjn.y>100)throw new Error("BlurFilterLinearSampling: Strength * Resolution cannot be higher than 100");this.ƀey=new Di(this.ƀjn.x,true),this.ƀkl=new Di(this.ƀjn.y,false),this.padding=Math.max(this.ƀjn.x,this.ƀjn.y);}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀkl.apply(t,e,s,V__namespace.CLEAR_MODES.CLEAR),this.ƀey.apply(t,s,i,r),t.returnFilterTexture(s);}get blendMode(){return this.ƀey.blendMode}set blendMode(t){this.ƀey.blendMode=t,this.ƀkl.blendMode=t;}};var ge=class{static{h(this,"Filters");}get red(){return this.ƀia}set red(t){this.ƀia=t,this.ƀib();}get green(){return this.ƀem}set green(t){this.ƀem=t,this.ƀib();}get blue(){return this.ƀag}set blue(t){this.ƀag=t,this.ƀib();}get brightness(){return this.ƀam}set brightness(t){this.ƀam=t,this.ƀib();}get contrast(){return this.ƀbm}set contrast(t){this.ƀbm=t,this.ƀib();}get blur(){return this.ƀah}set blur(t){let e=helpersLib.Comparator.isNumber(t)?new helpersLib.Vector(t,t):t;(this.ƀah&&e&&!this.ƀah.isEqual(e)||this.ƀah&&!e||!this.ƀah&&e)&&(this.ƀah=e,this.ƀai&&(this.ƀai.destroy(),this.ƀai=void 0),e&&(this.ƀai=new Rt(e),this.ƀgs()));}constructor(t){this.ƀbi=t,this.ƀia=1,this.ƀem=1,this.ƀag=1,this.ƀam=1,this.ƀbm=1,this.ƀgs();}removeColorFilter(){this.ƀbb?.destroy(),this.ƀbb=void 0,this.ƀgs();}ƀib(){this.ƀia===1&&this.ƀem===1&&this.ƀag===1&&this.ƀam===1&&this.ƀbm===1?this.ƀbb&&(this.ƀbb.destroy(),this.ƀbb=void 0,this.ƀgs()):(this.ƀbb||(this.ƀbb=new V__namespace.ColorMatrixFilter,this.ƀbb.resolution=O,this.ƀgs()),this.ƀbb.matrix=[this.ƀia*this.ƀbm,0,0,0,this.ƀam-1,0,this.ƀem*this.ƀbm,0,0,this.ƀam-1,0,0,this.ƀag*this.ƀbm,0,this.ƀam-1,0,0,0,1,0]);}ƀgs(){let t=[];this.ƀai&&t.push(this.ƀai),this.ƀbb&&t.push(this.ƀbb),this.ƀbi.filters=t;}};var u=class o extends ue{static{h(this,"Container");}static{this.allContainers=new Map;}constructor(){super(),this.addChildTo=this,this.defaultChildOptions={addUnder:false,cropOverflowingParts:false},o.allContainers.set(this.id,this),this.filters=new ge(this.pixiContainer);}destroy(){this.destroyed||(super.destroy(),o.allContainers.delete(this.id),!this.pixiContainer.destroyed&&this.pixiContainer.destroy());}getBoundingMask(){if(this.addChildTo!==this)return this.addChildTo.getBoundingMask();throw new Error(`Container: bounding mask cannot be used without bounding shapes. Display Object: "${this.id}"!`)}displayParent(t,e){let i;if(helpersLib.Comparator.isNumber(t)){if(i=o.allContainers.get(t),!i)throw new Error(`Container: parent not found! id: ${t}`)}else i=t;let r={addUnder:i.defaultChildOptions.addUnder,cropOverflowingParts:i.defaultChildOptions.cropOverflowingParts,...e};if(r.addUnder?i.addChildTo.pixiContainer.addChildAt(this.pixiContainer,0):i.addChildTo.pixiContainer.addChild(this.pixiContainer),r.cropOverflowingParts)if(i)this.pixiContainer.mask=i.getBoundingMask().pixiSprite;else throw new Error("Container: cropOverflowingParts can only be used with Container parent!");return this}};var M=class{static{h(this,"GameAssets");}static{this.ƀig=new Map;}static{this.ƀp=0;}static getAsset(t){let e=this.ƀig.get(t);if(e)return e;throw new Error(`Game Assets: Resource not found! Key: "${t}"`)}static insertAsset(t,e){return e||(e=`a-${this.ƀp++}`),this.ƀig.set(e,t),e}static destroyAsset(t){let e=this.ƀig.get(t);e&&(e.destroy(true),this.ƀig.delete(t));}static async loadGameAssets(t){let e=new Map,i=[];t.forEach(s=>{if(!helpersLib.Comparator.isString(s.url))throw new Error(`GameAssets: source url should be a string: ${s.url}`);let n=e.get(s.url);n?n.push(s.id):(e.set(s.url,[s.id]),i.push({url:s.url,callback:h(a=>{if(a instanceof V__namespace.Texture&&(a.id=s.id),n=e.get(s.url),n)n.forEach(l=>{this.ƀig.set(l,a);});else throw new Error(`GameAssets: unexpected error, nameGroup is not found! "./"! ${s}`)},"callback")}));});let r=performance.now();return Promise.all(i.map(s=>V__namespace.Assets.load(s.url))).then(s=>{let n=performance.now();console.info("Asset load completed in: ",Math.round(n-r)/1e3," seconds"),s.forEach((a,l)=>{i[l].callback(a);});}).catch(s=>{throw new Error(`GameAssets: during asset loading, an error occured: ${s}`)})}};var kt=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}static normalizePolygonByAnchor(t,e,i){let r=new helpersLib.Vector(e.x*i.x,e.y*i.y);return t.map(s=>s.map(n=>r.to(helpersLib.Vector.fromVec2(n))))}},we=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀja=t.map(r=>new V__namespace.Polygon(r.map(s=>new V__namespace.Point(s.x,s.y))));}contains(t,e){return this.ƀja.some(i=>i.contains(t,e))}};var kr=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},mt=new U;exports.CameraGateway=class It{static{h(this,"CameraGateway");}createCamera(){return mt.trigger("createCamera")}update(t,e){return mt.trigger("update",t,e)}setPosition(t){return mt.trigger("setPosition",t)}setTransition(t){return mt.trigger("setTransition",t)}getCameraPosition(){return mt.trigger("getCameraPosition")}};exports.CameraGateway=kr([d()],exports.CameraGateway);var Jr=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},ve=new U,Jt=class{static{h(this,"CameraViewGateway");}getLayers(){return ve.trigger("getLayers")}appear(t,e){return ve.trigger("appear",t,e)}};Jt=Jr([d()],Jt);var Gi;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Gi||(Gi={}));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 Yr=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},L=class extends ut{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);}};L=Yr([dt()],L);var Xr=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},Kr=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},At=class extends Wt{static{h(this,"CameraView");}constructor(t){super(),this.ƀcx=t,this.ƀij=new u().setAlpha(0).displayParent(w.instance.stage).attach(this),this.ƀae=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(w.instance.stage).attach(this),this.ƀac=new u().displayParent(this.ƀij).attach(this),this.ƀar=new u().displayParent(this.ƀij).attach(this),this.ƀdh=new u().setSortableChildren(true).displayParent(this.ƀij).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdg=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgb=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 A(this.ƀij,"alpha",{duration:500,animation:S.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaf=new A(this.ƀae,"alpha",{duration:500,animation:S.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),w.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),w.instance.setScreenPositionToStagePositionFunction(e=>new helpersLib.Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)),this.ƀcx.position.subscribe(e=>{this.ƀaq.position=this.ƀbr(e);}).attach(this),this.ƀcx.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.appear(true,"alpha");}destroy(){this.destroyed||(super.destroy(),w.instance.resetScreenPositionToStagePositionFunction());}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgb.id,foreground:this.ƀdg.id,foregroundScreen:this.ƀdh.id}}appear(t,e){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),this.ƀh.animate({alpha:t?1:0}).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),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('Switch ended with value "never".')}}}ƀbr(t){return helpersLib.Vector.fromTo(t,w.instance.getScreenSizeCenter())}};At=Xr([Ye({entity:L}),Kr("design:paramtypes",[L])],At);var qr=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},ts=1500,Pe=class{static{h(this,"CameraService");}createCamera(){return new L().attachToRoot()}getCameraPosition(){let t=L.getInstanceOrFail();return helpersLib.Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=L.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=L.getInstanceOrFail();e.focusingNewTargetInfo.value={time:w.time,duration:t?.duration??ts,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??exports.FocusingAnimation.Instant};}update(t,e){let i=L.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀfn(i,r,t):i.position.value=r);}ƀfn(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===exports.FocusingAnimation.Instant)this.ƀbd(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbd(t,e);else {let n;r.focusingAnimation===exports.FocusingAnimation.EaseInOut?n=Y.easeInOut(s):r.focusingAnimation===exports.FocusingAnimation.EaseOut?n=Y.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;}}}ƀbd(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};Pe=qr([d()],Pe);var es=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},is=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ri=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()}};ri=es([q({controllerLink:mt}),is("design:paramtypes",[Pe])],ri);var rs=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},si=class{static{h(this,"CameraViewController");}getLayers(){let t=L.getInstanceOrFail().id;return At.getInstanceOrFail(t).getLayers()}appear(t,e){let i=L.getInstanceOrFail().id;return At.getInstanceOrFail(i).appear(t,e)}};si=rs([q({controllerLink:ve})],si);var Xt=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=P.get(exports.CameraGateway),this.ƀat=P.get(Jt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha"){return this.ƀat.appear(t,e)}};var w=class o{static{h(this,"Game");}static get instance(){return this.ƀfj}static{this.pause=actionsLib.Reducer.createOr();}static get camera(){return this.ƀao}static get time(){return y.ƀjx}static get setupOptions(){return this.ƀiy}getScreenSize(){return this.ƀio.value}getScreenSizeCenter(){return this.ƀip.value}constructor(t){if(this.ƀio=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSize=this.ƀio.notifier,this.ƀip=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSizeCenter=this.ƀip.notifier,this.devMode=false,this.resetScreenPositionToStagePositionFunction(),o.ƀfj)throw new Error("There can be only one Game instance!");this.ƀbh={screenResolution:void 0,devMode:false,backgroundColor:helpersLib.ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbh.devMode||false,this.ƀhr=new V__namespace.Application({backgroundColor:this.ƀbh.backgroundColor,autoStart:false,antialias:this.ƀbh.antialias,resolution:this.ƀbh.resolution,width:this.ƀbh.screenResolution?.width,height:this.ƀbh.screenResolution?.height,resizeTo:this.ƀbh.screenResolution===void 0?window:void 0});}async setup(t){o.ƀiy=t,document.body.appendChild(this.ƀhr.view),await Promise.all([M.loadGameAssets(t.assetDefinitions)]),o.ƀfj=this,this.stage=new u().attachToRoot(),this.stage.pixiContainer=this.ƀhr.stage,this.renderer=this.ƀhr.renderer,this.ƀix(),this.stage.sortableChildren=true,globalThis.ƀa=this.ƀhr,window.addEventListener("resize",e=>{setTimeout(()=>this.ƀix());}),o.ƀao=new Xt,this.ƀhr.start(),this.ƀhr.ticker.add(()=>{y.triggerUpdateTick(this.ƀhr.ticker.deltaMS);});}setResolution(t){this.ƀhr.renderer.resolution!==t&&(this.ƀhr.renderer.resolution=t,this.ƀhr.renderer.resize(this.ƀhr.screen.width,this.ƀhr.screen.height));}screenPositonToStagePosition(t){let e=kt.includeScaleInScreenPosition(t,o.instance.stage.scale,o.instance.getScreenSizeCenter());return this.ƀin(e)}setScreenPositionToStagePositionFunction(t){this.ƀin=t;}resetScreenPositionToStagePositionFunction(){this.ƀin=t=>t;}destroyAsset(t){M.destroyAsset(t);}ƀix(){let t=new helpersLib.Vector(this.ƀhr.screen.width,this.ƀhr.screen.height);this.ƀio.value=t,this.ƀip.value=t.multiplyNumber(.5).round();}};var Ce=class o extends V__namespace.Filter{static{h(this,"ExpandWithColorFilter");}static ƀei(){return `
32
+ `,i}constructor(t,e){super(ti.ƀei(),ti.ƀdr(fe.getValuesForLinearSamplingGauss(t),e)),this.ƀew=e,this.resolution=O;}apply(t,e,i,r){this.uniforms.pixelSize=this.ƀew?1/(e.width*O):1/(e.height*O),t.applyFilter(this,e,i,r);}},Rt=class extends V__namespace.Filter{static{h(this,"BlurFilter");}constructor(t=new helpersLib.Vector(2,2)){if(super(),this.ƀjo=t,this.resolution=O,this.ƀjo=t.multiplyNumber(O).floor(),this.ƀjo.x<0||this.ƀjo.y<0)throw new Error("BlurFilterLinearSampling: Strength * Resolution must be greater than 0");if(this.ƀjo.x>100||this.ƀjo.y>100)throw new Error("BlurFilterLinearSampling: Strength * Resolution cannot be higher than 100");this.ƀey=new Di(this.ƀjo.x,true),this.ƀkm=new Di(this.ƀjo.y,false),this.padding=Math.max(this.ƀjo.x,this.ƀjo.y);}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀkm.apply(t,e,s,V__namespace.CLEAR_MODES.CLEAR),this.ƀey.apply(t,s,i,r),t.returnFilterTexture(s);}get blendMode(){return this.ƀey.blendMode}set blendMode(t){this.ƀey.blendMode=t,this.ƀkm.blendMode=t;}};var ge=class{static{h(this,"Filters");}get red(){return this.ƀia}set red(t){this.ƀia=t,this.ƀib();}get green(){return this.ƀem}set green(t){this.ƀem=t,this.ƀib();}get blue(){return this.ƀag}set blue(t){this.ƀag=t,this.ƀib();}get brightness(){return this.ƀam}set brightness(t){this.ƀam=t,this.ƀib();}get contrast(){return this.ƀbm}set contrast(t){this.ƀbm=t,this.ƀib();}get blur(){return this.ƀah}set blur(t){let e=helpersLib.Comparator.isNumber(t)?new helpersLib.Vector(t,t):t;(this.ƀah&&e&&!this.ƀah.isEqual(e)||this.ƀah&&!e||!this.ƀah&&e)&&(this.ƀah=e,this.ƀai&&(this.ƀai.destroy(),this.ƀai=void 0),e&&(this.ƀai=new Rt(e),this.ƀgs()));}constructor(t){this.ƀbi=t,this.ƀia=1,this.ƀem=1,this.ƀag=1,this.ƀam=1,this.ƀbm=1,this.ƀgs();}removeColorFilter(){this.ƀbb?.destroy(),this.ƀbb=void 0,this.ƀgs();}ƀib(){this.ƀia===1&&this.ƀem===1&&this.ƀag===1&&this.ƀam===1&&this.ƀbm===1?this.ƀbb&&(this.ƀbb.destroy(),this.ƀbb=void 0,this.ƀgs()):(this.ƀbb||(this.ƀbb=new V__namespace.ColorMatrixFilter,this.ƀbb.resolution=O,this.ƀgs()),this.ƀbb.matrix=[this.ƀia*this.ƀbm,0,0,0,this.ƀam-1,0,this.ƀem*this.ƀbm,0,0,this.ƀam-1,0,0,this.ƀag*this.ƀbm,0,this.ƀam-1,0,0,0,1,0]);}ƀgs(){let t=[];this.ƀai&&t.push(this.ƀai),this.ƀbb&&t.push(this.ƀbb),this.ƀbi.filters=t;}};var u=class o extends ue{static{h(this,"Container");}static{this.allContainers=new Map;}constructor(){super(),this.addChildTo=this,this.defaultChildOptions={addUnder:false,cropOverflowingParts:false},o.allContainers.set(this.id,this),this.filters=new ge(this.pixiContainer);}destroy(){this.destroyed||(super.destroy(),o.allContainers.delete(this.id),!this.pixiContainer.destroyed&&this.pixiContainer.destroy());}getBoundingMask(){if(this.addChildTo!==this)return this.addChildTo.getBoundingMask();throw new Error(`Container: bounding mask cannot be used without bounding shapes. Display Object: "${this.id}"!`)}displayParent(t,e){let i;if(helpersLib.Comparator.isNumber(t)){if(i=o.allContainers.get(t),!i)throw new Error(`Container: parent not found! id: ${t}`)}else i=t;let r={addUnder:i.defaultChildOptions.addUnder,cropOverflowingParts:i.defaultChildOptions.cropOverflowingParts,...e};if(r.addUnder?i.addChildTo.pixiContainer.addChildAt(this.pixiContainer,0):i.addChildTo.pixiContainer.addChild(this.pixiContainer),r.cropOverflowingParts)if(i)this.pixiContainer.mask=i.getBoundingMask().pixiSprite;else throw new Error("Container: cropOverflowingParts can only be used with Container parent!");return this}};var M=class{static{h(this,"GameAssets");}static{this.ƀih=new Map;}static{this.ƀp=0;}static getAsset(t){let e=this.ƀih.get(t);if(e)return e;throw new Error(`Game Assets: Resource not found! Key: "${t}"`)}static insertAsset(t,e){return e||(e=`a-${this.ƀp++}`),this.ƀih.set(e,t),e}static destroyAsset(t){let e=this.ƀih.get(t);e&&(e.destroy(true),this.ƀih.delete(t));}static async loadGameAssets(t){let e=new Map,i=[];t.forEach(s=>{if(!helpersLib.Comparator.isString(s.url))throw new Error(`GameAssets: source url should be a string: ${s.url}`);let n=e.get(s.url);n?n.push(s.id):(e.set(s.url,[s.id]),i.push({url:s.url,callback:h(a=>{if(a instanceof V__namespace.Texture&&(a.id=s.id),n=e.get(s.url),n)n.forEach(l=>{this.ƀih.set(l,a);});else throw new Error(`GameAssets: unexpected error, nameGroup is not found! "./"! ${s}`)},"callback")}));});let r=performance.now();return Promise.all(i.map(s=>V__namespace.Assets.load(s.url))).then(s=>{let n=performance.now();console.info("Asset load completed in: ",Math.round(n-r)/1e3," seconds"),s.forEach((a,l)=>{i[l].callback(a);});}).catch(s=>{throw new Error(`GameAssets: during asset loading, an error occured: ${s}`)})}};var kt=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}static normalizePolygonByAnchor(t,e,i){let r=new helpersLib.Vector(e.x*i.x,e.y*i.y);return t.map(s=>s.map(n=>r.to(helpersLib.Vector.fromVec2(n))))}},we=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀjb=t.map(r=>new V__namespace.Polygon(r.map(s=>new V__namespace.Point(s.x,s.y))));}contains(t,e){return this.ƀjb.some(i=>i.contains(t,e))}};var zr=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},mt=new $;exports.CameraGateway=class It{static{h(this,"CameraGateway");}createCamera(){return mt.trigger("createCamera")}update(t,e){return mt.trigger("update",t,e)}setPosition(t){return mt.trigger("setPosition",t)}setTransition(t){return mt.trigger("setTransition",t)}getCameraPosition(){return mt.trigger("getCameraPosition")}};exports.CameraGateway=zr([d()],exports.CameraGateway);var kr=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},ve=new $,Jt=class{static{h(this,"CameraViewGateway");}getLayers(){return ve.trigger("getLayers")}appear(t,e){return ve.trigger("appear",t,e)}};Jt=kr([d()],Jt);var Gi;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Gi||(Gi={}));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 Jr=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},L=class extends ut{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);}};L=Jr([dt()],L);var Yr=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},Xr=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},At=class extends Wt{static{h(this,"CameraView");}constructor(t){super(),this.ƀcx=t,this.ƀik=new u().setAlpha(0).displayParent(w.instance.stage).attach(this),this.ƀae=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(w.instance.stage).attach(this),this.ƀac=new u().displayParent(this.ƀik).attach(this),this.ƀar=new u().displayParent(this.ƀik).attach(this),this.ƀdh=new u().setSortableChildren(true).displayParent(this.ƀik).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdg=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgb=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 A(this.ƀik,"alpha",{duration:500,animation:S.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaf=new A(this.ƀae,"alpha",{duration:500,animation:S.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),w.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),w.instance.setScreenPositionToStagePositionFunction(e=>new helpersLib.Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)),this.ƀcx.position.subscribe(e=>{this.ƀaq.position=this.ƀbr(e);}).attach(this),this.ƀcx.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.appear(true,"alpha");}destroy(){this.destroyed||(super.destroy(),w.instance.resetScreenPositionToStagePositionFunction());}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgb.id,foreground:this.ƀdg.id,foregroundScreen:this.ƀdh.id}}appear(t,e){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),this.ƀh.animate({alpha:t?1:0}).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),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('Switch ended with value "never".')}}}ƀbr(t){return helpersLib.Vector.fromTo(t,w.instance.getScreenSizeCenter())}};At=Yr([Ye({entity:L}),Xr("design:paramtypes",[L])],At);var Qr=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},qr=1500,Pe=class{static{h(this,"CameraService");}createCamera(){return new L().attachToRoot()}getCameraPosition(){let t=L.getInstanceOrFail();return helpersLib.Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=L.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=L.getInstanceOrFail();e.focusingNewTargetInfo.value={time:w.time,duration:t?.duration??qr,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??exports.FocusingAnimation.Instant};}update(t,e){let i=L.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀfn(i,r,t):i.position.value=r);}ƀfn(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===exports.FocusingAnimation.Instant)this.ƀbd(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbd(t,e);else {let n;r.focusingAnimation===exports.FocusingAnimation.EaseInOut?n=Y.easeInOut(s):r.focusingAnimation===exports.FocusingAnimation.EaseOut?n=Y.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;}}}ƀbd(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};Pe=Qr([d()],Pe);var ts=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},es=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ri=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()}};ri=ts([q({controllerLink:mt}),es("design:paramtypes",[Pe])],ri);var is=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},si=class{static{h(this,"CameraViewController");}getLayers(){let t=L.getInstanceOrFail().id;return At.getInstanceOrFail(t).getLayers()}appear(t,e){let i=L.getInstanceOrFail().id;return At.getInstanceOrFail(i).appear(t,e)}};si=is([q({controllerLink:ve})],si);var Xt=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=P.get(exports.CameraGateway),this.ƀat=P.get(Jt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha"){return this.ƀat.appear(t,e)}};var w=class o{static{h(this,"Game");}static get instance(){return this.ƀfj}static{this.pause=actionsLib.Reducer.createOr();}static get camera(){return this.ƀao}static get time(){return y.ƀjy}static get setupOptions(){return this.ƀiz}getScreenSize(){return this.ƀip.value}getScreenSizeCenter(){return this.ƀiq.value}constructor(t){if(this.ƀip=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSize=this.ƀip.notifier,this.ƀiq=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSizeCenter=this.ƀiq.notifier,this.devMode=false,this.resetScreenPositionToStagePositionFunction(),o.ƀfj)throw new Error("There can be only one Game instance!");this.ƀbh={screenResolution:void 0,devMode:false,backgroundColor:helpersLib.ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbh.devMode||false,this.ƀhr=new V__namespace.Application({backgroundColor:this.ƀbh.backgroundColor,autoStart:false,antialias:this.ƀbh.antialias,resolution:this.ƀbh.resolution,width:this.ƀbh.screenResolution?.width,height:this.ƀbh.screenResolution?.height,resizeTo:this.ƀbh.screenResolution===void 0?window:void 0});}async setup(t){o.ƀiz=t,document.body.appendChild(this.ƀhr.view),await Promise.all([M.loadGameAssets(t.assetDefinitions)]),o.ƀfj=this,this.stage=new u().attachToRoot(),this.stage.pixiContainer=this.ƀhr.stage,this.renderer=this.ƀhr.renderer,this.ƀiy(),this.stage.sortableChildren=true,globalThis.ƀa=this.ƀhr,window.addEventListener("resize",e=>{setTimeout(()=>this.ƀiy());}),o.ƀao=new Xt,this.ƀhr.start(),this.ƀhr.ticker.add(()=>{y.triggerUpdateTick(this.ƀhr.ticker.deltaMS);});}setResolution(t){this.ƀhr.renderer.resolution!==t&&(this.ƀhr.renderer.resolution=t,this.ƀhr.renderer.resize(this.ƀhr.screen.width,this.ƀhr.screen.height));}screenPositonToStagePosition(t){let e=kt.includeScaleInScreenPosition(t,o.instance.stage.scale,o.instance.getScreenSizeCenter());return this.ƀio(e)}setScreenPositionToStagePositionFunction(t){this.ƀio=t;}resetScreenPositionToStagePositionFunction(){this.ƀio=t=>t;}destroyAsset(t){M.destroyAsset(t);}ƀiy(){let t=new helpersLib.Vector(this.ƀhr.screen.width,this.ƀhr.screen.height);this.ƀip.value=t,this.ƀiq.value=t.multiplyNumber(.5).round();}};var Ce=class o extends V__namespace.Filter{static{h(this,"ExpandWithColorFilter");}static ƀei(){return `
33
33
  attribute vec2 aVertexPosition;
34
34
  attribute vec2 aTextureCoord;
35
35
 
@@ -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.ƀei(),o.ƀdr(t*O)),this.ƀcz=t,this.resolution=O,this.ƀcz=t*O,this.ƀcz<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcz>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀcz)||(this.ƀcz=Math.floor(this.ƀcz));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcz*this.ƀcz,this.padding=this.ƀcz;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*O),1/(e.height*O)]),t.applyFilter(this,e,i,r);}};var Te=class extends V__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=O;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀda=new Ce(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Rt(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=V__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀda.apply(t,e,s,V__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀel=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbe(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀdt(t.texture,s,r.expand,r.color,i),a=new V__namespace.Sprite(n);return this.ƀiw(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀdt(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.ƀel.has(n))return o.ƀel.get(n);{let a=this.ƀdu(t,e,i,r);return o.ƀel.set(n,a),a}}else return this.ƀdu(t,e,i,r)}static ƀdu(t,e,i,r){let s=new V__namespace.Sprite(t);this.ƀdc(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀiw(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 ƀdc(t,e){if(t.isSprite){let s=new V__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 ƀbe(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};G.onHardReset.subscribe(()=>{Zt.ƀel.clear();}).attachToRoot();var X=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=w.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.pixiContainer,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:V__namespace.SCALE_MODES.LINEAR,multisample:V__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,boundingShapes:void 0,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀjw=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjf=t,this.pixiSprite=new V__namespace.Sprite(M.getAsset(t.id)),this.pixiContainer.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.ƀgd?.destroy(),this.ƀak?.destroy(),this.ƀjf.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjf.id),this.ƀhs&&M.destroyAsset(this.ƀhs.texture.id)),this.ƀhs&&!this.ƀhs.destroyed&&this.ƀhs.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀjw}set textureScale(t){this.ƀjw=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.ƀjf.boundingShapes&&!this.pixiContainer.hitArea&&(this.pixiContainer.hitArea=new we(this.ƀjf.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀjf.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===V__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=V__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=V__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 V__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.ƀhs)return this.ƀhs.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhs)this.ƀhs.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀjf.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhs&&(this.ƀhs.destroy(),this.ƀhs=void 0),t&&(this.ƀhs=Zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjf.destroyAssetOnDestroy),this.ƀhs.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhs.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.pixiContainer.addChild(this.ƀhs)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbu().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgd){if(!this.ƀjf.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgd=this.ƀbu(),this.ƀgd.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgd.pixiSprite.renderable=false,this.ƀgd.displayParent(this);}return this.ƀgd}ƀbu(){if(!this.ƀjf.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀjf.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.pixiContainer);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}};var Ee=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,m=Math.floor(c/p),g=c-p*m;m>=1&&g<i.dashLength&&(g+=p,m--);let E=s.normalize(g/2),bt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(E)}),l=l.add(E),m>0){let ne=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(bt),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(bt),a.push({from:l,to:l.add(E)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcs=new Map;}static createArrow(t,e){let i=new V__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 V__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 V__namespace.Graphics;return s.lineStyle(r.width,r.color),Ee.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 V__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 V__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 V__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 V__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 V__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 V__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new V__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new V__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.pixiContainer.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.ƀef(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},boundingShapes:void 0,destroyAssetOnDestroy:!e.cache},s=new X(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀef(t,e){if(e){let i=o.ƀcs.get(t);return i||(i=this.ƀcg(),o.ƀcs.set(t,i)),i}else return this.ƀcg()}ƀcg(){let t=w.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {assetID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var ai=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀht=new V__namespace.Graphics,this.ƀht.beginFill(0,1e-9),this.ƀht.drawRect(0,0,t.x,t.y),this.ƀht.endFill(),this.pixiContainer.addChild(this.ƀht);}destroy(){this.destroyed||(super.destroy(),this.ƀht.destroy());}};var Mt=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 {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 Ie=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.ƀff(r,e),n=this.ƀs(s);return this.ƀjd(n)}static ƀff(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Mt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdp(a.tags,e,i),p=s(l,c),m=V__namespace.TextMetrics.measureText(" ",new V__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdp(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbc(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbc(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 ƀjd(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.ƀje(s.text).map(a=>{let l=new V__namespace.TextStyle(s.pixiStyle),c=V__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 ƀje(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 Ae=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.ƀkt(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀkt(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀkt(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 Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcj.length===0}get remainingWidth(){return this.ƀks-this.ƀcl}constructor(t,e){if(this.ƀks=t,this.ƀfv=[],this.ƀcj=[],this.ƀcl=0,this.ƀfu=new helpersLib.Vector(0,0),this.ƀck=0,this.ƀex=e?.horizontalAlignment??"left",this.ƀkk=e?.verticalAlignment??"bottom",e?.rectangleCutOption){if(e.rectangleCutOption.position.x<0||e.rectangleCutOption.position.x>=this.ƀks||e.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcm={direction:e.rectangleCutOption.direction,rectangle:this.ƀbq(e.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀck,t.y),i=this.ƀdx(this.ƀfu.y,this.ƀfu.y+e);return this.ƀcl+t.x<=i}insertWord(t){let e=Math.max(this.ƀck,t.style.height);if(this.ƀcj.length===0){let i=this.ƀdy(this.ƀfu.y,this.ƀfu.y+e);this.ƀfu=new helpersLib.Vector(i,this.ƀfu.y),this.ƀcl=this.ƀfu.x;}this.ƀcj.push({chunk:t,position:new helpersLib.Vector(this.ƀcl,this.ƀfu.y)}),this.ƀck=e,this.ƀcl+=t.style.width;}newLine(){let t=this.ƀfu.y+this.ƀck,e=this.ƀdy(t,t);this.ƀde(),this.ƀfu=new helpersLib.Vector(e,t),this.ƀcl=this.ƀfu.x,this.ƀck=0;}print(){return this.ƀde(),this.ƀfv}ƀde(){this.ƀcj.length>0&&(this.ƀfv.push(this.ƀg(this.ƀcj)),this.ƀcj=[]);}ƀg(t){return t=this.ƀkm(t),t=this.ƀez(t),t}ƀez(t){if(this.ƀex==="left")return t;let e=this.ƀfu.y+this.ƀck,i=this.ƀdy(this.ƀfu.y,e),s=this.ƀdx(this.ƀfu.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀex==="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))}ƀkm(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.ƀkk){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.ƀkk;throw new Error(`Unexpected case! "${this.ƀkk}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀdy(t,e){return this.ƀcm&&(this.ƀcm.direction==="topLeft"||this.ƀcm.direction==="bottomLeft")&&(this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀcm.rectangle.bottomRight.x:0}ƀdx(t,e){return this.ƀcm&&(this.ƀcm.direction==="topRight"||this.ƀcm.direction==="bottomRight")&&(this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(this.ƀks,t),{includeEdges:false})||this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(this.ƀks,e),{includeEdges:false}))?this.ƀcm.rectangle.topLeft.x:this.ƀks}ƀbq(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 Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgh(t),t=this.ƀkc(t),this.ƀaw(t)}static ƀgh(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 ƀkc(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=Ie.process(t,e),r=new Oe(e.default.wordWrapWidth??1/0,{rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=Ae.wrapText(i,r);return Me.process(s)}};var Ss=1,Ui=1/Ss,te=class extends u{static{h(this,"Text");}get ƀju(){if(!this.ƀjv){let t=new V__namespace.TextStyle(this.ƀhv);this.ƀjv=V__namespace.TextMetrics.measureText(this.ƀjt,t);}return this.ƀjv}get ascent(){return this.ƀju.fontProperties.ascent}constructor(t,e){super(),this.ƀhv=Mt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhu.destroyed&&this.ƀhu.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀhu.anchor.x,this.ƀhu.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhu.anchor.set(t.x,t.y);}setPosition(t,e){if(e?.holdFrom){let i=this.ƀhv.dropShadowDistance??0,r=new helpersLib.Vector(e.holdFrom.x*i,e.holdFrom.y*i);t=t.add(r);}return super.setPosition(t,e),this}setText(t){return this.ƀjt!==t&&(this.ƀjt=t,this.ƀic()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀhv.fill!==e&&(this.ƀhv.fill=e,this.ƀic()),this}ƀic(){this.ƀhu?.destroy(),this.ƀjo?.destroy(),this.ƀjo=void 0,this.ƀjv=void 0;let t=new V__namespace.TextStyle(this.ƀhv);this.ƀhu=new V__namespace.Text(this.ƀjt,t),this.ƀi&&this.ƀhu.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhu.scale.set(Ui,Ui),this.pixiContainer.addChild(this.ƀhu),this.ƀhv.lineThrough&&(this.ƀjo=this.ƀe(this.ƀhu,this.ƀhv.fill),this.pixiContainer.addChild(this.ƀjo));}ƀe(t,e){let i=V__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new V__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=V__namespace.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,g=0;t.style.align==="center"?g=0+(t.width-p.width)*.5:t.style.align==="right"&&(g=0+t.width-p.width),g=Math.floor(g),n.moveTo(Math.floor(g),m),n.lineTo(Math.floor(g+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var hi=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new te(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var li=class extends u{static{h(this,"UpdatableContainer");}},ci=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbw=t,this.ƀcp=new Map,this.ƀhb={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcp.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhb.trackBy(r,s),a;this.ƀcp.has(n)?(a=this.ƀcp.get(n),e.delete(n),a.update(r)):(a=this.ƀbw(r).displayParent(this).attach(this),this.ƀcp.set(n,a)),this.ƀhb.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhb.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhb.positioning.spacing);}),e.forEach(r=>{this.ƀcp.get(r).destroy(),this.ƀcp.delete(r);});}};var Bt=class o extends u{static{h(this,"Menu");}static{this.ƀka=false;}static closeAll(){return o.ƀha?o.ƀha.close():actionsLib.SingleEvent.instant()}constructor(t,e){super(),this.ƀgt=new actionsLib.SingleAction,this.onOpen=this.ƀgt.notifier,this.ƀgo=new actionsLib.SingleAction,this.onClose=this.ƀgo.notifier;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,darkeningAlpha:.3,...e};this.setZIndex(100).setAlpha(0),this.ƀo=new A(this,"alpha",{animation:S.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaa=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.darkeningAlpha).setInteractive(true).displayParent(this).attach(this),this.ƀgg=X.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(r=>{this.ƀaa.aspectRatio=r.x/r.y,this.ƀaa.scale=Math.max(r.x,r.y),this.ƀaa.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(r.multiplyNumber(.5));}).attach(this),o.ƀha=this,this.onDestroy().tap(()=>{o.ƀha=void 0;}).attachToRoot(),i.closeOnBackgroundClick&&this.ƀaa.on(exports.ContainerEventType.Click).filter(()=>!o.ƀka).tap(()=>this.ƀq(false)).take(1).attach(this),this.ƀq(true);}getBoundingMask(){return this.ƀgg.getBoundingMask()}close(){return this.ƀq(false)}ƀq(t){if(o.ƀka)throw new Error("WindowUI: cannot iterate while in transition");return o.ƀka=true,this.ƀo.animate({alpha:t?1:0}).chain(this).tap(()=>{o.ƀka=false,t?this.ƀgt.resolve():(this.ƀgo.resolve(),this.destroy());}).chainToRoot()}};var di=class extends ut{static{h(this,"MenuEntity");}constructor(t,e){super(),this.ƀgr=new actionsLib.SingleAction,this.onCreate=this.ƀgr.notifier,this.ƀgt=new actionsLib.SingleAction,this.onOpen=this.ƀgt.notifier,this.ƀgo=new actionsLib.SingleAction,this.onClose=this.ƀgo.notifier,Bt.closeAll().tap(()=>{if(!St.getActiveScene())throw new Error("WindowEntity: constructor is called when there is no active scene!");w.pause.effect(true).attach(this),this.ƀgg=new Bt(t,e).displayParent(w.camera.layers.foregroundScreen).attach(this),this.ƀgr.resolve(this.ƀgg),this.ƀgg.onOpen.subscribe(()=>this.ƀgt.resolve()).attach(this),this.ƀgg.onClose.subscribe(()=>{this.destroy(),this.ƀgo.resolve();}).attach(this);}).attach(this);}getMenuEvents(){return {onOpen:this.onOpen.toSingleEvent().destroyIfNotAttached(),onClose:this.onClose.toSingleEvent().destroyIfNotAttached()}}close(){if(this.ƀgg){let t=this.onClose.toSingleEvent().destroyIfNotAttached();return this.ƀgg.close(),t}else return this.onCreate.asyncMapQueue(()=>this.close()).singleChain(this)}};var Es=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},Rs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class gt{static{h(this,"MouseService");}get initialMouseMoveHappened(){return this.ƀfh.value}getStagePosition(){return this.ƀjg.value}getScreenPosition(){return this.ƀim.value}getMainButtonState(){return this.ƀga.value}getSecondaryButtonState(){return this.ƀis.value}constructor(){this.ƀfh=new actionsLib.Variable(false),this.onInitialMouseMove=this.ƀfh.notifier,this.ƀjg=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀjg.notifier,this.ƀim=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀim.notifier,this.ƀga=new actionsLib.Variable(false),this.mainButtonState=this.ƀga.notifier,this.ƀis=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀis.notifier,this.ƀjh(),window.addEventListener("mousedown",t=>{t.button===0?this.ƀga.value=true:t.button===2&&(this.ƀis.value=true);}),window.addEventListener("mouseup",t=>{t.button===0?this.ƀga.value=false:t.button===2&&(this.ƀis.value=false);}),window.addEventListener("blur",()=>{this.ƀga.value=false,this.ƀis.value=false;});}ƀjh(){let t=helpersLib.Vector.zero;window.addEventListener("mousemove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfh.value=true;}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀim.value=t;}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀim.value);e.isEqual(this.ƀjg.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:this.ƀim.value.x,clientY:this.ƀim.value.y,pointerType:"mouse"})):this.ƀjg.value=e;}).attachToRoot();}};exports.MouseService=Es([d(),Rs("design:paramtypes",[])],exports.MouseService);var ie=class extends u{static{h(this,"MouseWheelListenerUI");}constructor(t){super(),this.ƀgx=new actionsLib.Action,this.onWheel=this.ƀgx.notifier,this.ƀes=(e=>{let i=P.get(exports.MouseService).getScreenPosition(),r=this.ƀkr.getBounds();i.x>=r.x&&i.x<=r.x+r.width&&i.y>=r.y&&i.y<=r.y+r.height&&this.ƀgx.trigger(e.deltaY);}).bind(this),this.ƀkr=new V__namespace.Graphics,this.ƀkr.beginFill(0,1e-9),this.ƀkr.drawRect(0,0,t.x,t.y),this.ƀkr.endFill(),this.pixiContainer.addChild(this.ƀkr),window.addEventListener("wheel",this.ƀes);}destroy(){this.destroyed||(super.destroy(),this.ƀkr.destroy(),window.removeEventListener("wheel",this.ƀes));}};var Os=.65,Ms=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀiq}get contentSize(){return this.ƀbj.size.ceil()}constructor(t,e,i,r){this.ƀbj=t,this.ƀv=e,this.ƀhe=i,this.ƀjc=r,this.ƀfi=false,this.ƀiq=e-i*2,this.ƀbj.y=i,this.ƀjp=i;}onWheel(t){this.setTarget(this.ƀjp-t*Os);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjp=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀhe-this.contentSize.y,this.ƀhe);}jumpToTarget(){this.ƀbj.y=this.ƀjp;}update(t){let e=this.contentSize;if(e.y<=this.ƀiq){switch(this.ƀjc){case "start":this.ƀjp=this.ƀhe;break;case "center":this.ƀjp=(this.ƀv-e.y)*.5;break;case "end":this.ƀjp=this.ƀv-e.y-this.ƀhe;break;default:{this.ƀjc;throw new Error(`Unexpected case! "${this.ƀjc}"`)}}this.ƀfi||(this.ƀbj.y=this.ƀjp);}this.ƀfi=true;let i=this.ƀjp-this.ƀbj.y;this.ƀbj.y=this.ƀbj.y+i*Ms*t;}};var fi=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},yt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcs=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.ƀca(e,i,s):this.ƀch(e,i,s),this.ƀgd=X.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgd);}ƀch(t,e,i){e>0&&this.ƀbx(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.ƀbx(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀca(t,e,i){e>0&&this.ƀbx(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.ƀbx(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbx(t){let i={id:this.ƀby(t.y),scale:1,size:t,anchor:{x:0,y:0},boundingShapes:void 0};return new X(i,{textureSize:t,ignoreAnchor:true})}ƀby(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcs.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 fi;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=V__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcs.set(e,i);}else throw new Error("Canvas context is null")}return i}};var Gs=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbk}get contentSize(){return this.ƀir.contentSize}constructor(t,e={}){super();let i={padding:Gs,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 yt(r,t,i.padding).attach(this);let s=new u().displayParent(r).attach(this);this.ƀir=new Ge(s,t.y,i.padding,i.smallContentAlign),this.ƀbk=new helpersLib.Vector(t.x,this.ƀir.scrollHeight),new ie(t).displayParent(r).attach(this).onWheel.subscribe(a=>this.ƀir.onWheel(a)).attach(this),y.afterSceneUpdateAction.subscribe(a=>this.ƀir.update(a.delta)).attach(this),this.addChildTo=s;}scrollToTop(t){this.ƀir.scrollToTop(),t?.instant&&this.ƀir.jumpToTarget();}scrollToBottom(t){this.ƀir.scrollToBottom(),t?.instant&&this.ƀir.jumpToTarget();}};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},Fs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class gi{static{h(this,"KeyboardService");}constructor(){this.ƀfq=new actionsLib.Action,this.keyPressed=this.ƀfq.notifier,this.ƀfr=new actionsLib.Action,this.keyReleased=this.ƀfr.notifier,this.ƀfx=new Set,this.ƀfw=new Set,window.addEventListener("keydown",t=>{this.ƀfx.add(t.key),this.ƀfw.add(t.key),!t.repeat&&this.ƀfq.trigger(t.key);}),window.addEventListener("keyup",t=>{this.ƀfx.delete(t.key),this.ƀfr.trigger(t.key);}),window.addEventListener("blur",()=>{this.ƀfx.clear();}),y.afterSceneUpdateAction.subscribe(()=>{this.ƀfw.clear();}).attachToRoot();}isKeyDown(t){return this.ƀfx.has(t)}isKeyJustPressed(t){return this.ƀfw.has(t)}};exports.KeyboardService=_s([d(),Fs("design:paramtypes",[])],exports.KeyboardService);var Ls=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},Vs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class yi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdf}get lastFocusedPosition(){return this.ƀft}constructor(t){this.ƀgj=t,this.ƀgv=new actionsLib.Action,this.onTargetFocus=this.ƀgv.notifier,this.ƀjz=0,this.ƀkb=false,this.ƀdf=false,this.ƀft=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀkd(e.delta)).attachToRoot();}ƀkd(t){if(this.ƀgk){let e=this.ƀee(this.ƀgj.getStagePosition(),this.ƀgk);this.ƀhg===void 0?this.ƀhg=e:this.ƀav(e,t);}this.ƀgk=this.ƀgj.getStagePosition();}ƀav(t,e){this.ƀhg-t>10?(this.ƀjz=Math.max(250,this.ƀjz),this.ƀkb=true):this.ƀjz>1e3&&(this.ƀkb=true);let i=this.ƀjz>=300&&this.ƀkb;this.ƀfo(i,t,e);}ƀfo(t,e,i){(t||e>this.ƀhg)&&(this.ƀhg=e),t?(this.ƀkb=false,this.ƀjz=0,this.ƀdf=true,this.ƀft=this.ƀgj.getStagePosition(),this.ƀgv.trigger(this.ƀft)):(this.ƀjz+=i,this.ƀdf=false);}ƀee(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=Ls([d(),Vs("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var x;(function(o){o[o.Hidden=1]="Hidden",o[o.Visible=2]="Visible",o[o.Appearing=3]="Appearing",o[o.Disappearing=4]="Disappearing",o[o.DisappearToChange=5]="DisappearToChange";})(x||(x={}));var _e=class extends actionsLib.Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀjk,queuedState:this.ƀhx,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgu=new actionsLib.Action,this.ƀgw=new actionsLib.Action,this.ƀhb={duration:500,animation:S.lineer,...t},this.ƀj.value=0,this.ƀo=new A(this.ƀj,"value",{duration:this.ƀhb.duration,animation:this.ƀhb.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgw.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀo.completeAnimation(),this.ƀn=t!==void 0?x.Visible:x.Hidden,this.ƀhx=void 0;let i=t!==void 0?1:0,r=this.ƀjk!==t;r&&(this.ƀjk=t,this.ƀgu.trigger(this.ƀjk)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀgw.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀhx=void 0,this.ƀjk=t,this.ƀgu.trigger(this.ƀjk),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀhx=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgq()).attach(this)):t!==this.ƀjk&&(this.ƀn=x.DisappearToChange,this.ƀhx=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgq()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀhx=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):t!==this.ƀjk&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀhx=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):(this.ƀhx=void 0,this.ƀjk=t,this.ƀgu.trigger(this.ƀjk)));break;case x.Disappearing:t===this.ƀjk?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀhx=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀhx=void 0):t===this.ƀjk?(this.ƀn=x.Appearing,this.ƀhx=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):t!==this.ƀhx&&(this.ƀhx=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgq(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀgw.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀhx!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀjk=void 0,this.ƀgu.trigger(this.ƀjk),this.ƀgw.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀhx===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀjk=this.ƀhx,this.ƀhx=void 0,this.ƀgu.trigger(this.ƀjk),this.ƀgw.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgu.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀgw.subscribe(e=>t(e)).attach(this),this}};var Ki=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbw=t;let i={duration:200,animation:S.easeInOut,...e};this.alpha=0,this.ƀjl=new _e(i).onStateChange(r=>{this.ƀbj?.destroy(),this.ƀbj=void 0,r!==void 0&&(this.ƀbj=new u().displayParent(this).attach(this),this.ƀbw({state:r,container:this.ƀbj}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjl.setState(t,e),this}};var I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var Fe=class extends actionsLib.Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀjk,nextState:this.ƀgm,queuedState:this.ƀhx,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgu=new actionsLib.Action,this.ƀgw=new actionsLib.Action,this.ƀhb={duration:500,animation:S.lineer,...t},this.ƀo=new A(this.ƀj,"value",{duration:this.ƀhb.duration,animation:this.ƀhb.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgw.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀjk===void 0)this.ƀjk=t,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm}),this.ƀgw.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀjk=t,this.ƀgm=void 0,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm}),this.ƀgw.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀjk&&(this.ƀn=I.Transitioning,this.ƀgm=t,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm}),this.ƀgw.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this));break;case I.Transitioning:t!==this.ƀgm&&(t===this.ƀjk?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):this.ƀhx=t);break;case I.Reverting:t!==this.ƀjk&&(t===this.ƀgm?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):this.ƀhx=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgq(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀhx!==void 0?(this.ƀn=I.Transitioning,this.ƀjk=this.ƀgm,this.ƀgm=this.ƀhx,this.ƀhx=void 0,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm}),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this)):(this.ƀn=I.Idle,this.ƀjk=this.ƀgm,this.ƀgm=void 0,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm})),this.ƀgw.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀjk===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀhx!==void 0?(this.ƀn=I.Transitioning,this.ƀgm=this.ƀhx,this.ƀhx=void 0,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm}),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this)):(this.ƀn=I.Idle,this.ƀgm=void 0,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjk,nextState:this.ƀgm})),this.ƀgw.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgu.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀgw.subscribe(e=>t(e)).attach(this),this}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var C;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(C||(C={}));var Le=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=C.Idle,this.ƀgu=new actionsLib.Action,this.ƀgw=new actionsLib.Action,this.ƀhb={duration:500,animation:S.easeInOutCubic,...t},this.ƀjl=new Fe({duration:this.ƀhb.duration,animation:this.ƀhb.animation}).onStateChange((e,i)=>this.ƀeq(e,i)).onValueChange(e=>this.ƀer(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfg===void 0?(this.ƀfg=t,this.ƀgu.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀjl.setState(t,e)):this.ƀfg!==t?this.ƀgl!==t?this.ƀn===C.Idle?(this.ƀn=t>this.ƀfg?C.TransitionForward:C.TransitionBackward,this.ƀgl=t,this.ƀgu.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀgl}),this.ƀjl.setState(t,e)):this.ƀjl.setState(t,e):this.ƀn===C.Reverting&&this.ƀgl===t&&(this.ƀn=t>this.ƀfg?C.TransitionForward:C.TransitionBackward,this.ƀjl.setState(t,e)):(this.ƀn===C.TransitionForward||this.ƀn===C.TransitionBackward)&&(this.ƀn=C.Reverting,this.ƀjl.setState(t,e));}ƀeq(t,e){switch(this.ƀfg!==void 0&&this.ƀfg!==t&&this.ƀfg!==e&&this.ƀgu.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀfg}),this.ƀgl!==void 0&&this.ƀgl!==t&&this.ƀgl!==e&&this.ƀgu.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀgl}),e!==void 0&&e!==this.ƀfg&&e!==this.ƀgl&&this.ƀgu.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀn){case C.Idle:break;case C.TransitionForward:case C.TransitionBackward:e===void 0?(this.ƀn=C.Idle,this.ƀfg=this.ƀgl,this.ƀgl=void 0):this.ƀfg!==t&&this.ƀeo(t,e);break;case C.Reverting:e===void 0?(this.ƀn=C.Idle,this.ƀgl=void 0):this.ƀfg!==e&&this.ƀeo(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀer(t){let e=1;(this.ƀn===C.TransitionBackward||this.ƀn===C.Reverting&&this.ƀfg!==void 0&&this.ƀgl!==void 0&&this.ƀfg>this.ƀgl)&&(e=-1),(this.ƀn===C.Idle||t!==0)&&this.ƀgw.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfg}),this.ƀgl!==void 0&&this.ƀgw.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgl});}ƀeo(t,e){this.ƀfg=t,this.ƀgl=e,this.ƀgw.trigger({value:0,index:this.ƀfg}),this.ƀn=this.ƀfg<this.ƀgl?C.TransitionForward:C.TransitionBackward;}onStateChange(t){return this.ƀgu.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀgw.subscribe(e=>t(e.value,e.index)).attach(this),this}};exports.ScrollDirection=void 0;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(exports.ScrollDirection||(exports.ScrollDirection={}));var wi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbw=t,this.ƀcn="x",this.ƀbl=new Map,this.ƀhb={duration:300,animation:S.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀhb.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀhb.size.x+this.ƀhb.margin*2,this.ƀhb.size.y):new helpersLib.Vector(this.ƀhb.size.x,this.ƀhb.size.y+this.ƀhb.margin*2),r=new u().setPosition(this.ƀhb.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀhb.margin,0):new helpersLib.Vector(0,-this.ƀhb.margin),{round:false}).displayParent(this).attach(this);this.ƀcb(i,this.ƀhb.margin,this.ƀhb.direction,r),this.ƀcn=this.ƀhb.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀjl=new Le({duration:this.ƀhb.duration,animation:this.ƀhb.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbl.set(n,a),this.ƀbw({index:n,container:a});}else {let a=this.ƀbl.get(n);a&&(a.destroy(),this.ƀbl.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbl.get(n);if(a){let l={x:0,y:0};l[this.ƀcn]=i[this.ƀcn]*s+this.ƀhb.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjl.setIndex(t,e),this}ƀcb(t,e,i,r){new yt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},tr=class extends wi{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 xt=class{static{h(this,"VectorSet");}constructor(){this.ƀki=new Map;}add(t){let e=this.ƀki.get(t.x);e||(e=new Set,this.ƀki.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀki.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀki.get(t.x);return e?e.delete(t.y):false}};var xi=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var B=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 re=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=B.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 xt,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 er=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)}},qs=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀen=t,this.ƀji=e,this.ƀgz=new helpersLib.BinaryHeap("min"),this.ƀay=[],this.ƀgn=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new er(this.ƀji,0,Number.MAX_SAFE_INTEGER);this.ƀgz.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀgz.size>0}getNeighbors(t,e){return this.ƀen.getNeighborPositions(t.position,e).filter(i=>this.ƀen.get(i)).map(i=>this.ƀgn.get(i)||this.ƀcc(i))}popLowestPathCostNode(){let t=this.ƀgz.pop();return this.ƀgz.delete(t),t.closed=true,this.ƀay.push(t),t}changeNodeCost(t,e,i,r){this.ƀgz.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀgz.add(t.pathLength,t);}getBestClosedNode(){return this.ƀay.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcc(t){let e=new er(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgn.set(t,e),this.ƀgz.add(e.pathLength,e),e}},se=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new qs(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 oe=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjq=t,this.ƀx=e,this.ƀeu=this.ƀdw(this.ƀx.size),this.ƀkq=new helpersLib.Grid({size:this.ƀx.size,defaultValue:this.ƀeu}),this.ƀco=new helpersLib.Grid({size:this.ƀx.size,defaultValue:void 0});let i=new xt,r=new helpersLib.Queue;for(this.ƀdl(this.ƀx.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀkq.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀkq.getOrFail(n);this.ƀeb(n,this.ƀx).forEach(l=>{if(!i.has(l.position)){let c=this.ƀkq.getOrFail(l.position),p=a+l.distance;this.ƀx.getOrFail(l.position)&&p<c&&(this.ƀkq.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjq)){if(t=this.ƀkq.movePositionInsideGrid(t),this.ƀco.has(t))return this.ƀco.get(t);{let e=this.ƀeb(t,this.ƀx),i;return this.ƀkq.getOrFail(t)>=this.ƀeu?e.some(s=>this.ƀx.get(s.position))&&(e.some(n=>!this.ƀx.get(n.position))?i=this.ƀdq(e):i=this.ƀdm(t,e)):i=this.ƀdm(t,e),this.ƀco.set(t,i),i}}}ƀdq(t){let e=t.filter(i=>this.ƀx.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdm(t,e){let i=e.filter(r=>this.ƀkq.getOrFail(r.position)<this.ƀeu).reduce((r,s)=>{let n=this.ƀkq.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.ƀeu}).bestDirections;return this.ƀeg(i,t)}ƀeg(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀfl(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfl(t,e){let i=t.add(this.ƀkj(e));return this.ƀx.isPointWithinBounds(i)&&this.ƀx.getOrFail(i)}ƀeb(t,e){return this.ƀkq.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdl(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}ƀkj(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀdw(t){return (t.x+t.y)*20}};var so=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},oo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends ${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=so([dt(),oo("design:paramtypes",[helpersLib.Vector,Boolean,W__default.default.World,Map,Map,Map,Map])],v);var lo=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},K=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}};K=lo([d()],K);var co=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},po=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ve=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhj=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhj.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();}};Ve=co([d(),po("design:paramtypes",[K])],Ve);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},fo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},nt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhj=t,this.ƀy=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀy.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Gt){return e.aabbNeedsUpdate=true,e.updateAABB(),re.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀy.get(t,e,i);return r||(r=this.ƀbz(t,e,i),this.ƀy.set(t,e,i,r)),r}ƀbz(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.ƀhj.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdv(s,e);r.setArea(a,false);}}),r}ƀdv(t,e){let i=f.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=uo([d(),fo("design:paramtypes",[K,Ve])],nt);var yo=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},wo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Gt=50,_t=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhi=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Gt);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=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhi.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let E=f.aabbToBoundingBox(l.aabb),bt=B.areaToGridArea(E,s.gridCellSize);m.setArea(bt,true);}let g=se.findPath(m,c,p,s.neighborType);return g.path=g.path.map(E=>B.gridPositionToPosition(E,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Gt){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(g.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=B.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let g=this.ƀhi.getAvilabilityGrid(n,s,r);p=new oe(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};_t=yo([d(),wo("design:paramtypes",[nt])],_t);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},j=new U;exports.PhysicsGateway=class bi{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return j.trigger("createPhysicsWorld",t)}getMapSize(t){return j.trigger("getMapSize",t)}setPaused(t,e){return j.trigger("setPaused",t,e)}hitTest(t,e){return j.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return j.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return j.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return j.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return j.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return j.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Gt){return j.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};exports.PhysicsGateway=bo([d()],exports.PhysicsGateway);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},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Q=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀz=t,this.ƀhf=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀz.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhf.findPathDirection(t,c.position,i,r),m;p===void 0?m=T.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=T.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new A(m,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}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 A(a,"alpha",{duration:n,animation:S.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 m=p.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new A(l,"alpha",{duration:a,animation:S.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.ƀcr(c,n).displayParent(a).attachToRoot();}),new A(a,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcr(t,e){switch(t.type){case W__default.default.Shape.PARTICLE:throw new Error("Not implemented");case W__default.default.Shape.LINE:throw new Error("Not implemented");case W__default.default.Shape.PLANE:throw new Error("Not implemented");case W__default.default.Shape.CIRCLE:throw new Error("Not implemented");case W__default.default.Shape.CAPSULE:throw new Error("Not implemented");case W__default.default.Shape.BOX:throw new Error("Not implemented");case W__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case W__default.default.Shape.CONVEX:return this.ƀcq(t,e);default:throw new Error("Not implemented")}}ƀcq(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Q=Po([d(),So("design:paramtypes",[nt,_t])],Q);var Eo=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)},Ne=class{static{h(this,"HitTestService");}constructor(t){this.ƀjs=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.ƀdj(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 W__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.ƀjs.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);}ƀdj(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Eo([d(),Ro("design:paramtypes",[Q])],Ne);var Ao=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},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀid(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀaz=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀid(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀep(r.p2Body),r.entity.ƀiu(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀep(t){let e=f.arrayToVector(t.velocity);e.length>10.8&&(e=e.normalize(10.8),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-10.01),10.01);}ƀid(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.ƀdo(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);}ƀdo(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.ƀec(i);return {collisionDetailsA:this.ƀdn(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdn(s,i.bodyB.mass,a,c,e.area)}}ƀdn(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}}ƀec(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=Ao([d()],je);var Oo=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},Mo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends Ut{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Oo([dt(),Mo("design:paramtypes",[Number,Object])],He);var Do=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},H=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbt(t,new helpersLib.Vector(e.x/2,-H/2),new helpersLib.Vector(e.x+H*2,H),i),this.ƀbt(t,new helpersLib.Vector(e.x/2,e.y+H/2),new helpersLib.Vector(e.x+H*2,H),i),this.ƀbt(t,new helpersLib.Vector(-H/2,e.y/2),new helpersLib.Vector(H,e.y+H*2),i),this.ƀbt(t,new helpersLib.Vector(e.x+H/2,e.y/2),new helpersLib.Vector(H,e.y+H*2),i);}ƀbt(t,e,i,r){return new He(t,{shapeDefinition:{materialName:st,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Do([d()],We);var Go=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},nr=new W__default.default.Material,_o={id:st,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Ft=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 W__default.default.Material),n.set(a.id,a);}),s.has(st))throw new Error(`Material with name ${st} cannot be defined, pick another name for the material.`);return s.set(st,nr),n.set(st,_o),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀea(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdz(e,i.materialDefinitions)}ƀea(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀdz(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.ƀds(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀea(n.materialA,s),l=this.ƀea(n.materialB,s);t.addContactMaterial(new W__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀds(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.ƀea(s.id,r);t.addContactMaterial(new W__default.default.ContactMaterial(n,nr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Ft=Go([d()],Ft);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},Lo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Lt=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgf=t,this.ƀaj=e,this.ƀz=i,this.ƀba=r,this.ƀhj=s;}createPhysicsWorld(t){let e=new W__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgf.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhj.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&&y.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀba.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjm(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjm(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀz.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjm(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.ƀba.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);}};Lt=Fo([d(),Lo("design:paramtypes",[Ft,We,nt,je,K])],Lt);var No=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},Nt=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new W__default.default.RaycastResult,s=new W__default.default.Ray({mode:W__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.ƀbo(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new W__default.default.Ray({mode:W__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.ƀbo(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbo(n,e));},"callback")});return t.p2World.raycast(new W__default.default.RaycastResult,s),Array.from(r.values())}ƀbo(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}}};Nt=No([d()],Nt);var jo=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},lt=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);}};lt=jo([d()],lt);var Ho=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},jt=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.ƀbp(r,t.length))}ƀbp(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")}}}};jt=Ho([d()],jt);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},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Jo=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀhz=t,this.ƀjs=e,this.ƀhy=i,this.ƀfe=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀce(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀhy.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀjs.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...E}=m;return E})}ƀce(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 m=l.normalize(i.y);a.push(new helpersLib.Line(t,t.add(m))),a.push(new helpersLib.Line(t,t.add(m.multiplyNumber(-1))));let g=Math.round(i.y/Jo),E=i.y/(g*2+1)*2,bt=l.normalize(E),ne=i.x,hr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(g).forEach(pt=>{let Pt=E*(pt+1),Ci=bt.multiplyNumber(pt+1),ae=c.normalize(this.ƀek(ne,hr,Pt)),he=t.add(Ci);a.push(new helpersLib.Line(he,he.add(ae))),a.push(new helpersLib.Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ci.multiplyNumber(-1));a.push(new helpersLib.Line(le,le.add(ae))),a.push(new helpersLib.Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(pt=>{if(s){let Pt=this.ƀhz.castClosest(n,pt,r);return {line:pt,hits:Pt?[Pt]:[]}}else {let Pt=this.ƀhz.castAllFirstContacts(n,pt,r);return {line:pt,hits:Pt}}})}ƀek(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.ƀfe.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=Uo([d(),$o("design:paramtypes",[Nt,Q,jt,lt])],$e);var Yo=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},Xo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ze=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀhz=t,this.ƀjs=e,this.ƀhy=i,this.ƀfe=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeh(i),c=this.ƀce(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀhy.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀjs.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀce(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 m=this.ƀhz.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀhz.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfe.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.ƀfe.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeh(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ze=Yo([d(),Xo("design:paramtypes",[Nt,Q,jt,lt])],ze);var tn=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},Ht=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)}};Ht=tn([d()],Ht);var en=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},rn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀhq=t,this.ƀhf=e,this.ƀjs=i,this.ƀdb=r,this.ƀcv=s,this.ƀev=n,this.ƀhp=a,this.ƀfe=l;}createPhysicsWorld(t){return this.ƀhq.createPhysicsWorld(t)}getMapSize(t){return this.ƀhp.getMapSize(t)}setPaused(t,e){this.ƀhq.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀev.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhf.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhf.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfe.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdb.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcv.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n){this.ƀjs.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=en([q({controllerLink:j}),rn("design:paramtypes",[Lt,_t,Q,ze,$e,Ne,Ht,lt])],Pi);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},ke=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.ƀbv(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbv(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcd(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀcf(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbv(t,e,i,r,s,n){let a=new W__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcd(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new W__default.default.Convex({vertices:g.map(E=>[E.x,E.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,E)=>g+E.area,0),m=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(g=>m.addShape(g)),m.setDensity(r.density),m}ƀcf(t,e,i,r,s,n){let a=new W__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 W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ke=sn([d()],ke);var on=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},nn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀhq=t,this.ƀho=e,this.ƀiz=i,this.ƀhp=r,this.ƀhj=s;}createBody(t,e,i,r,s){return this.ƀiz.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀho.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀho.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhj.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhj.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀhq.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀhq.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhp.subscribeToPhysicsStep(t,e)}};Si=on([q({controllerLink:J}),nn("design:paramtypes",[Lt,Ft,ke,Ht,K])],Si);exports.AnimationFlicker=Ai;exports.AnimationInterpolationFunctions=Y;exports.Animations=S;exports.Animator=A;exports.BORDER_MATERIAL_NAME=st;exports.BardLegendsHardReset=G;exports.Camera=Xt;exports.ClosestAvailableSpaceHelper=re;exports.Container=u;exports.ControllerDecorator=q;exports.ControllerLink=U;exports.DEFAULT_SHADER_RESOLUTION=O;exports.DeltaTime=xi;exports.DisplayObjectArray=ci;exports.Entity=$;exports.EntityDecorator=dt;exports.FadeInContent=Ki;exports.FadeInStateAnimation=_e;exports.Game=w;exports.Graphics=T;exports.ImmovablePhysicsEntity=Ut;exports.Menu=Bt;exports.MenuEntity=di;exports.MouseWheelListenerUI=ie;exports.MovableEntity=Xe;exports.MovablePhysicsEntity=Ke;exports.PathFinder=se;exports.PhysicsEntity=b;exports.Placeholder=ai;exports.PositionConversionHelper=kt;exports.ROTATIONAL_SPEED_LIMIT=Qe;exports.RichText=hi;exports.SPEED_LIMIT=Ze;exports.Scene=St;exports.SceneDecorator=yr;exports.ScrollAreaUI=mi;exports.ScrollMaskUI=yt;exports.Service=P;exports.ServiceDecorator=d;exports.SingletonEntity=ut;exports.SlideInContent=tr;exports.SlideInContentByIndex=wi;exports.SlideStateAnimation=Le;exports.Sprite=X;exports.StateAnimation=Fe;exports.Text=te;exports.UpdatableContainer=li;exports.UpdateCycle=y;exports.VectorFieldPathFinder=oe;exports.VectorSet=xt;exports.View=Wt;exports.ViewDecorator=Ye;
67
+ }`,e}constructor(t,e){if(super(o.ƀei(),o.ƀdr(t*O)),this.ƀcz=t,this.resolution=O,this.ƀcz=t*O,this.ƀcz<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcz>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀcz)||(this.ƀcz=Math.floor(this.ƀcz));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcz*this.ƀcz,this.padding=this.ƀcz;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*O),1/(e.height*O)]),t.applyFilter(this,e,i,r);}};var Te=class extends V__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=O;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀda=new Ce(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Rt(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=V__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀda.apply(t,e,s,V__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀel=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbe(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀdt(t.texture,s,r.expand,r.color,i),a=new V__namespace.Sprite(n);return this.ƀix(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀdt(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.ƀel.has(n))return o.ƀel.get(n);{let a=this.ƀdu(t,e,i,r);return o.ƀel.set(n,a),a}}else return this.ƀdu(t,e,i,r)}static ƀdu(t,e,i,r){let s=new V__namespace.Sprite(t);this.ƀdc(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀix(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 ƀdc(t,e){if(t.isSprite){let s=new V__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 ƀbe(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};G.onHardReset.subscribe(()=>{Zt.ƀel.clear();}).attachToRoot();var X=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=w.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.pixiContainer,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:V__namespace.SCALE_MODES.LINEAR,multisample:V__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,boundingShapes:void 0,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀjx=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjg=t,this.pixiSprite=new V__namespace.Sprite(M.getAsset(t.id)),this.pixiContainer.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.ƀgd?.destroy(),this.ƀak?.destroy(),this.ƀjg.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjg.id),this.ƀhs&&M.destroyAsset(this.ƀhs.texture.id)),this.ƀhs&&!this.ƀhs.destroyed&&this.ƀhs.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀjx}set textureScale(t){this.ƀjx=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.ƀjg.boundingShapes&&!this.pixiContainer.hitArea&&(this.pixiContainer.hitArea=new we(this.ƀjg.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀjg.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===V__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=V__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=V__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 V__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.ƀhs)return this.ƀhs.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhs)this.ƀhs.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀjg.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhs&&(this.ƀhs.destroy(),this.ƀhs=void 0),t&&(this.ƀhs=Zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjg.destroyAssetOnDestroy),this.ƀhs.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhs.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.pixiContainer.addChild(this.ƀhs)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbu().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgd){if(!this.ƀjg.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgd=this.ƀbu(),this.ƀgd.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgd.pixiSprite.renderable=false,this.ƀgd.displayParent(this);}return this.ƀgd}ƀbu(){if(!this.ƀjg.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀjg.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.pixiContainer);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}};var Ee=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,m=Math.floor(c/p),g=c-p*m;m>=1&&g<i.dashLength&&(g+=p,m--);let E=s.normalize(g/2),bt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(E)}),l=l.add(E),m>0){let ne=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(bt),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(bt),a.push({from:l,to:l.add(E)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcs=new Map;}static createArrow(t,e){let i=new V__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 V__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 V__namespace.Graphics;return s.lineStyle(r.width,r.color),Ee.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 V__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 V__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 V__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 V__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 V__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 V__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new V__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new V__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.pixiContainer.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.ƀef(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},boundingShapes:void 0,destroyAssetOnDestroy:!e.cache},s=new X(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀef(t,e){if(e){let i=o.ƀcs.get(t);return i||(i=this.ƀcg(),o.ƀcs.set(t,i)),i}else return this.ƀcg()}ƀcg(){let t=w.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {assetID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var ai=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀht=new V__namespace.Graphics,this.ƀht.beginFill(0,1e-9),this.ƀht.drawRect(0,0,t.x,t.y),this.ƀht.endFill(),this.pixiContainer.addChild(this.ƀht);}destroy(){this.destroyed||(super.destroy(),this.ƀht.destroy());}};var Mt=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 {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 Ie=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.ƀff(r,e),n=this.ƀs(s);return this.ƀje(n)}static ƀff(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Mt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdp(a.tags,e,i),p=s(l,c),m=V__namespace.TextMetrics.measureText(" ",new V__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdp(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbc(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbc(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 ƀje(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.ƀjf(s.text).map(a=>{let l=new V__namespace.TextStyle(s.pixiStyle),c=V__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 ƀjf(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 Ae=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.ƀku(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀku(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀku(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 Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcj.length===0}get remainingWidth(){return this.ƀkt-this.ƀcl}constructor(t,e){if(this.ƀkt=t,this.ƀfv=[],this.ƀcj=[],this.ƀcl=0,this.ƀfu=new helpersLib.Vector(0,0),this.ƀck=0,this.ƀex=e?.horizontalAlignment??"left",this.ƀkl=e?.verticalAlignment??"bottom",e?.rectangleCutOption){if(e.rectangleCutOption.position.x<0||e.rectangleCutOption.position.x>=this.ƀkt||e.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcm={direction:e.rectangleCutOption.direction,rectangle:this.ƀbq(e.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀck,t.y),i=this.ƀdx(this.ƀfu.y,this.ƀfu.y+e);return this.ƀcl+t.x<=i}insertWord(t){let e=Math.max(this.ƀck,t.style.height);if(this.ƀcj.length===0){let i=this.ƀdy(this.ƀfu.y,this.ƀfu.y+e);this.ƀfu=new helpersLib.Vector(i,this.ƀfu.y),this.ƀcl=this.ƀfu.x;}this.ƀcj.push({chunk:t,position:new helpersLib.Vector(this.ƀcl,this.ƀfu.y)}),this.ƀck=e,this.ƀcl+=t.style.width;}newLine(){let t=this.ƀfu.y+this.ƀck,e=this.ƀdy(t,t);this.ƀde(),this.ƀfu=new helpersLib.Vector(e,t),this.ƀcl=this.ƀfu.x,this.ƀck=0;}print(){return this.ƀde(),this.ƀfv}ƀde(){this.ƀcj.length>0&&(this.ƀfv.push(this.ƀg(this.ƀcj)),this.ƀcj=[]);}ƀg(t){return t=this.ƀkn(t),t=this.ƀez(t),t}ƀez(t){if(this.ƀex==="left")return t;let e=this.ƀfu.y+this.ƀck,i=this.ƀdy(this.ƀfu.y,e),s=this.ƀdx(this.ƀfu.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀex==="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))}ƀkn(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.ƀkl){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.ƀkl;throw new Error(`Unexpected case! "${this.ƀkl}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀdy(t,e){return this.ƀcm&&(this.ƀcm.direction==="topLeft"||this.ƀcm.direction==="bottomLeft")&&(this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀcm.rectangle.bottomRight.x:0}ƀdx(t,e){return this.ƀcm&&(this.ƀcm.direction==="topRight"||this.ƀcm.direction==="bottomRight")&&(this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(this.ƀkt,t),{includeEdges:false})||this.ƀcm.rectangle.isPointInside(new helpersLib.Vector(this.ƀkt,e),{includeEdges:false}))?this.ƀcm.rectangle.topLeft.x:this.ƀkt}ƀbq(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 Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgh(t),t=this.ƀkd(t),this.ƀaw(t)}static ƀgh(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 ƀkd(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=Ie.process(t,e),r=new Oe(e.default.wordWrapWidth??1/0,{rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=Ae.wrapText(i,r);return Me.process(s)}};var Ss=1,Wi=1/Ss,te=class extends u{static{h(this,"Text");}get ƀjv(){if(!this.ƀjw){let t=new V__namespace.TextStyle(this.ƀhv);this.ƀjw=V__namespace.TextMetrics.measureText(this.ƀju,t);}return this.ƀjw}get ascent(){return this.ƀjv.fontProperties.ascent}constructor(t,e){super(),this.ƀhv=Mt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhu.destroyed&&this.ƀhu.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀhu.anchor.x,this.ƀhu.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhu.anchor.set(t.x,t.y);}setText(t){return this.ƀju!==t&&(this.ƀju=t,this.ƀic()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀhv.fill!==e&&(this.ƀhv.fill=e,this.ƀic()),this}ƀic(){this.ƀhu?.destroy(),this.ƀjp?.destroy(),this.ƀjp=void 0,this.ƀjw=void 0;let t=new V__namespace.TextStyle(this.ƀhv);this.ƀhu=new V__namespace.Text(this.ƀju,t),this.ƀif(),this.ƀi&&this.ƀhu.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhu.scale.set(Wi,Wi),this.pixiContainer.addChild(this.ƀhu),this.ƀhv.lineThrough&&(this.ƀjp=this.ƀe(this.ƀhu,this.ƀhv.fill),this.pixiContainer.addChild(this.ƀjp));}ƀif(){let t=V__namespace.TextMetrics.measureText(this.ƀju,new V__namespace.TextStyle({...this.ƀhv,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀhu.calculateBounds=function(){this.updateText(true),this.ƀal.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this.ƀal.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=V__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new V__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=V__namespace.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,g=0;t.style.align==="center"?g=0+(t.width-p.width)*.5:t.style.align==="right"&&(g=0+t.width-p.width),g=Math.floor(g),n.moveTo(Math.floor(g),m),n.lineTo(Math.floor(g+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var hi=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new te(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var li=class extends u{static{h(this,"UpdatableContainer");}},ci=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbw=t,this.ƀcp=new Map,this.ƀhb={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcp.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhb.trackBy(r,s),a;this.ƀcp.has(n)?(a=this.ƀcp.get(n),e.delete(n),a.update(r)):(a=this.ƀbw(r).displayParent(this).attach(this),this.ƀcp.set(n,a)),this.ƀhb.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhb.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhb.positioning.spacing);}),e.forEach(r=>{this.ƀcp.get(r).destroy(),this.ƀcp.delete(r);});}};var Bt=class o extends u{static{h(this,"Menu");}static{this.ƀkb=false;}static closeAll(){return o.ƀha?o.ƀha.close():actionsLib.SingleEvent.instant()}constructor(t,e){super(),this.ƀgt=new actionsLib.SingleAction,this.onOpen=this.ƀgt.notifier,this.ƀgo=new actionsLib.SingleAction,this.onClose=this.ƀgo.notifier;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,darkeningAlpha:.3,...e};this.setZIndex(100).setAlpha(0),this.ƀo=new A(this,"alpha",{animation:S.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaa=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.darkeningAlpha).setInteractive(true).displayParent(this).attach(this),this.ƀgg=X.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(r=>{this.ƀaa.aspectRatio=r.x/r.y,this.ƀaa.scale=Math.max(r.x,r.y),this.ƀaa.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(r.multiplyNumber(.5));}).attach(this),o.ƀha=this,this.onDestroy().tap(()=>{o.ƀha=void 0;}).attachToRoot(),i.closeOnBackgroundClick&&this.ƀaa.on(exports.ContainerEventType.Click).filter(()=>!o.ƀkb).tap(()=>this.ƀq(false)).take(1).attach(this),this.ƀq(true);}getBoundingMask(){return this.ƀgg.getBoundingMask()}close(){return this.ƀq(false)}ƀq(t){if(o.ƀkb)throw new Error("WindowUI: cannot iterate while in transition");return o.ƀkb=true,this.ƀo.animate({alpha:t?1:0}).chain(this).tap(()=>{o.ƀkb=false,t?this.ƀgt.resolve():(this.ƀgo.resolve(),this.destroy());}).chainToRoot()}};var di=class extends ut{static{h(this,"MenuEntity");}constructor(t,e){super(),this.ƀgr=new actionsLib.SingleAction,this.onCreate=this.ƀgr.notifier,this.ƀgt=new actionsLib.SingleAction,this.onOpen=this.ƀgt.notifier,this.ƀgo=new actionsLib.SingleAction,this.onClose=this.ƀgo.notifier,Bt.closeAll().tap(()=>{if(!St.getActiveScene())throw new Error("WindowEntity: constructor is called when there is no active scene!");w.pause.effect(true).attach(this),this.ƀgg=new Bt(t,e).displayParent(w.camera.layers.foregroundScreen).attach(this),this.ƀgr.resolve(this.ƀgg),this.ƀgg.onOpen.subscribe(()=>this.ƀgt.resolve()).attach(this),this.ƀgg.onClose.subscribe(()=>{this.destroy(),this.ƀgo.resolve();}).attach(this);}).attach(this);}getMenuEvents(){return {onOpen:this.onOpen.toSingleEvent().destroyIfNotAttached(),onClose:this.onClose.toSingleEvent().destroyIfNotAttached()}}close(){if(this.ƀgg){let t=this.onClose.toSingleEvent().destroyIfNotAttached();return this.ƀgg.close(),t}else return this.onCreate.asyncMapQueue(()=>this.close()).singleChain(this)}};var Es=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},Rs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class gt{static{h(this,"MouseService");}get initialMouseMoveHappened(){return this.ƀfh.value}getStagePosition(){return this.ƀjh.value}getScreenPosition(){return this.ƀin.value}getMainButtonState(){return this.ƀga.value}getSecondaryButtonState(){return this.ƀit.value}constructor(){this.ƀfh=new actionsLib.Variable(false),this.onInitialMouseMove=this.ƀfh.notifier,this.ƀjh=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀjh.notifier,this.ƀin=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀin.notifier,this.ƀga=new actionsLib.Variable(false),this.mainButtonState=this.ƀga.notifier,this.ƀit=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀit.notifier,this.ƀji(),window.addEventListener("mousedown",t=>{t.button===0?this.ƀga.value=true:t.button===2&&(this.ƀit.value=true);}),window.addEventListener("mouseup",t=>{t.button===0?this.ƀga.value=false:t.button===2&&(this.ƀit.value=false);}),window.addEventListener("blur",()=>{this.ƀga.value=false,this.ƀit.value=false;});}ƀji(){let t=helpersLib.Vector.zero;window.addEventListener("mousemove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfh.value=true;}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀin.value=t;}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀin.value);e.isEqual(this.ƀjh.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:this.ƀin.value.x,clientY:this.ƀin.value.y,pointerType:"mouse"})):this.ƀjh.value=e;}).attachToRoot();}};exports.MouseService=Es([d(),Rs("design:paramtypes",[])],exports.MouseService);var ie=class extends u{static{h(this,"MouseWheelListenerUI");}constructor(t){super(),this.ƀgx=new actionsLib.Action,this.onWheel=this.ƀgx.notifier,this.ƀes=(e=>{let i=P.get(exports.MouseService).getScreenPosition(),r=this.ƀks.getBounds();i.x>=r.x&&i.x<=r.x+r.width&&i.y>=r.y&&i.y<=r.y+r.height&&this.ƀgx.trigger(e.deltaY);}).bind(this),this.ƀks=new V__namespace.Graphics,this.ƀks.beginFill(0,1e-9),this.ƀks.drawRect(0,0,t.x,t.y),this.ƀks.endFill(),this.pixiContainer.addChild(this.ƀks),window.addEventListener("wheel",this.ƀes);}destroy(){this.destroyed||(super.destroy(),this.ƀks.destroy(),window.removeEventListener("wheel",this.ƀes));}};var Os=.65,Ms=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀir}get contentSize(){return this.ƀbj.size.ceil()}constructor(t,e,i,r){this.ƀbj=t,this.ƀv=e,this.ƀhe=i,this.ƀjd=r,this.ƀfi=false,this.ƀir=e-i*2,this.ƀbj.y=i,this.ƀjq=i;}onWheel(t){this.setTarget(this.ƀjq-t*Os);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjq=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀhe-this.contentSize.y,this.ƀhe);}jumpToTarget(){this.ƀbj.y=this.ƀjq;}update(t){let e=this.contentSize;if(e.y<=this.ƀir){switch(this.ƀjd){case "start":this.ƀjq=this.ƀhe;break;case "center":this.ƀjq=(this.ƀv-e.y)*.5;break;case "end":this.ƀjq=this.ƀv-e.y-this.ƀhe;break;default:{this.ƀjd;throw new Error(`Unexpected case! "${this.ƀjd}"`)}}this.ƀfi||(this.ƀbj.y=this.ƀjq);}this.ƀfi=true;let i=this.ƀjq-this.ƀbj.y;this.ƀbj.y=this.ƀbj.y+i*Ms*t;}};var fi=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},yt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcs=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.ƀca(e,i,s):this.ƀch(e,i,s),this.ƀgd=X.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgd);}ƀch(t,e,i){e>0&&this.ƀbx(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.ƀbx(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀca(t,e,i){e>0&&this.ƀbx(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.ƀbx(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbx(t){let i={id:this.ƀby(t.y),scale:1,size:t,anchor:{x:0,y:0},boundingShapes:void 0};return new X(i,{textureSize:t,ignoreAnchor:true})}ƀby(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcs.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 fi;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=V__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcs.set(e,i);}else throw new Error("Canvas context is null")}return i}};var Gs=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbk}get contentSize(){return this.ƀis.contentSize}constructor(t,e={}){super();let i={padding:Gs,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 yt(r,t,i.padding).attach(this);let s=new u().displayParent(r).attach(this);this.ƀis=new Ge(s,t.y,i.padding,i.smallContentAlign),this.ƀbk=new helpersLib.Vector(t.x,this.ƀis.scrollHeight),new ie(t).displayParent(r).attach(this).onWheel.subscribe(a=>this.ƀis.onWheel(a)).attach(this),y.afterSceneUpdateAction.subscribe(a=>this.ƀis.update(a.delta)).attach(this),this.addChildTo=s;}scrollToTop(t){this.ƀis.scrollToTop(),t?.instant&&this.ƀis.jumpToTarget();}scrollToBottom(t){this.ƀis.scrollToBottom(),t?.instant&&this.ƀis.jumpToTarget();}};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},Fs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class gi{static{h(this,"KeyboardService");}constructor(){this.ƀfq=new actionsLib.Action,this.keyPressed=this.ƀfq.notifier,this.ƀfr=new actionsLib.Action,this.keyReleased=this.ƀfr.notifier,this.ƀfx=new Set,this.ƀfw=new Set,window.addEventListener("keydown",t=>{this.ƀfx.add(t.key),this.ƀfw.add(t.key),!t.repeat&&this.ƀfq.trigger(t.key);}),window.addEventListener("keyup",t=>{this.ƀfx.delete(t.key),this.ƀfr.trigger(t.key);}),window.addEventListener("blur",()=>{this.ƀfx.clear();}),y.afterSceneUpdateAction.subscribe(()=>{this.ƀfw.clear();}).attachToRoot();}isKeyDown(t){return this.ƀfx.has(t)}isKeyJustPressed(t){return this.ƀfw.has(t)}};exports.KeyboardService=_s([d(),Fs("design:paramtypes",[])],exports.KeyboardService);var Ls=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},Vs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class yi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdf}get lastFocusedPosition(){return this.ƀft}constructor(t){this.ƀgj=t,this.ƀgv=new actionsLib.Action,this.onTargetFocus=this.ƀgv.notifier,this.ƀka=0,this.ƀkc=false,this.ƀdf=false,this.ƀft=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀke(e.delta)).attachToRoot();}ƀke(t){if(this.ƀgk){let e=this.ƀee(this.ƀgj.getStagePosition(),this.ƀgk);this.ƀhg===void 0?this.ƀhg=e:this.ƀav(e,t);}this.ƀgk=this.ƀgj.getStagePosition();}ƀav(t,e){this.ƀhg-t>10?(this.ƀka=Math.max(250,this.ƀka),this.ƀkc=true):this.ƀka>1e3&&(this.ƀkc=true);let i=this.ƀka>=300&&this.ƀkc;this.ƀfo(i,t,e);}ƀfo(t,e,i){(t||e>this.ƀhg)&&(this.ƀhg=e),t?(this.ƀkc=false,this.ƀka=0,this.ƀdf=true,this.ƀft=this.ƀgj.getStagePosition(),this.ƀgv.trigger(this.ƀft)):(this.ƀka+=i,this.ƀdf=false);}ƀee(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=Ls([d(),Vs("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var x;(function(o){o[o.Hidden=1]="Hidden",o[o.Visible=2]="Visible",o[o.Appearing=3]="Appearing",o[o.Disappearing=4]="Disappearing",o[o.DisappearToChange=5]="DisappearToChange";})(x||(x={}));var _e=class extends actionsLib.Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀjl,queuedState:this.ƀhx,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgu=new actionsLib.Action,this.ƀgw=new actionsLib.Action,this.ƀhb={duration:500,animation:S.lineer,...t},this.ƀj.value=0,this.ƀo=new A(this.ƀj,"value",{duration:this.ƀhb.duration,animation:this.ƀhb.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgw.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀo.completeAnimation(),this.ƀn=t!==void 0?x.Visible:x.Hidden,this.ƀhx=void 0;let i=t!==void 0?1:0,r=this.ƀjl!==t;r&&(this.ƀjl=t,this.ƀgu.trigger(this.ƀjl)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀgw.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀhx=void 0,this.ƀjl=t,this.ƀgu.trigger(this.ƀjl),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀhx=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgq()).attach(this)):t!==this.ƀjl&&(this.ƀn=x.DisappearToChange,this.ƀhx=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgq()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀhx=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):t!==this.ƀjl&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀhx=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):(this.ƀhx=void 0,this.ƀjl=t,this.ƀgu.trigger(this.ƀjl)));break;case x.Disappearing:t===this.ƀjl?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀhx=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀhx=void 0):t===this.ƀjl?(this.ƀn=x.Appearing,this.ƀhx=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):t!==this.ƀhx&&(this.ƀhx=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgq(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀgw.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀhx!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀjl=void 0,this.ƀgu.trigger(this.ƀjl),this.ƀgw.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀhx===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀjl=this.ƀhx,this.ƀhx=void 0,this.ƀgu.trigger(this.ƀjl),this.ƀgw.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgu.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀgw.subscribe(e=>t(e)).attach(this),this}};var Xi=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbw=t;let i={duration:200,animation:S.easeInOut,...e};this.alpha=0,this.ƀjm=new _e(i).onStateChange(r=>{this.ƀbj?.destroy(),this.ƀbj=void 0,r!==void 0&&(this.ƀbj=new u().displayParent(this).attach(this),this.ƀbw({state:r,container:this.ƀbj}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjm.setState(t,e),this}};var I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var Fe=class extends actionsLib.Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀjl,nextState:this.ƀgm,queuedState:this.ƀhx,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgu=new actionsLib.Action,this.ƀgw=new actionsLib.Action,this.ƀhb={duration:500,animation:S.lineer,...t},this.ƀo=new A(this.ƀj,"value",{duration:this.ƀhb.duration,animation:this.ƀhb.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgw.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀjl===void 0)this.ƀjl=t,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm}),this.ƀgw.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀjl=t,this.ƀgm=void 0,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm}),this.ƀgw.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀjl&&(this.ƀn=I.Transitioning,this.ƀgm=t,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm}),this.ƀgw.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this));break;case I.Transitioning:t!==this.ƀgm&&(t===this.ƀjl?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):this.ƀhx=t);break;case I.Reverting:t!==this.ƀjl&&(t===this.ƀgm?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhb.duration}).tap(()=>this.ƀgq()).attach(this)):this.ƀhx=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgq(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀhx!==void 0?(this.ƀn=I.Transitioning,this.ƀjl=this.ƀgm,this.ƀgm=this.ƀhx,this.ƀhx=void 0,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm}),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this)):(this.ƀn=I.Idle,this.ƀjl=this.ƀgm,this.ƀgm=void 0,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm})),this.ƀgw.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀjl===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀhx!==void 0?(this.ƀn=I.Transitioning,this.ƀgm=this.ƀhx,this.ƀhx=void 0,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm}),this.ƀo.animate({value:1}).tap(()=>this.ƀgq()).attach(this)):(this.ƀn=I.Idle,this.ƀgm=void 0,this.ƀj.value=0,this.ƀgu.trigger({state:this.ƀjl,nextState:this.ƀgm})),this.ƀgw.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgu.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀgw.subscribe(e=>t(e)).attach(this),this}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var C;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(C||(C={}));var Le=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=C.Idle,this.ƀgu=new actionsLib.Action,this.ƀgw=new actionsLib.Action,this.ƀhb={duration:500,animation:S.easeInOutCubic,...t},this.ƀjm=new Fe({duration:this.ƀhb.duration,animation:this.ƀhb.animation}).onStateChange((e,i)=>this.ƀeq(e,i)).onValueChange(e=>this.ƀer(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfg===void 0?(this.ƀfg=t,this.ƀgu.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀjm.setState(t,e)):this.ƀfg!==t?this.ƀgl!==t?this.ƀn===C.Idle?(this.ƀn=t>this.ƀfg?C.TransitionForward:C.TransitionBackward,this.ƀgl=t,this.ƀgu.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀgl}),this.ƀjm.setState(t,e)):this.ƀjm.setState(t,e):this.ƀn===C.Reverting&&this.ƀgl===t&&(this.ƀn=t>this.ƀfg?C.TransitionForward:C.TransitionBackward,this.ƀjm.setState(t,e)):(this.ƀn===C.TransitionForward||this.ƀn===C.TransitionBackward)&&(this.ƀn=C.Reverting,this.ƀjm.setState(t,e));}ƀeq(t,e){switch(this.ƀfg!==void 0&&this.ƀfg!==t&&this.ƀfg!==e&&this.ƀgu.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀfg}),this.ƀgl!==void 0&&this.ƀgl!==t&&this.ƀgl!==e&&this.ƀgu.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀgl}),e!==void 0&&e!==this.ƀfg&&e!==this.ƀgl&&this.ƀgu.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀn){case C.Idle:break;case C.TransitionForward:case C.TransitionBackward:e===void 0?(this.ƀn=C.Idle,this.ƀfg=this.ƀgl,this.ƀgl=void 0):this.ƀfg!==t&&this.ƀeo(t,e);break;case C.Reverting:e===void 0?(this.ƀn=C.Idle,this.ƀgl=void 0):this.ƀfg!==e&&this.ƀeo(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀer(t){let e=1;(this.ƀn===C.TransitionBackward||this.ƀn===C.Reverting&&this.ƀfg!==void 0&&this.ƀgl!==void 0&&this.ƀfg>this.ƀgl)&&(e=-1),(this.ƀn===C.Idle||t!==0)&&this.ƀgw.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfg}),this.ƀgl!==void 0&&this.ƀgw.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgl});}ƀeo(t,e){this.ƀfg=t,this.ƀgl=e,this.ƀgw.trigger({value:0,index:this.ƀfg}),this.ƀn=this.ƀfg<this.ƀgl?C.TransitionForward:C.TransitionBackward;}onStateChange(t){return this.ƀgu.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀgw.subscribe(e=>t(e.value,e.index)).attach(this),this}};exports.ScrollDirection=void 0;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(exports.ScrollDirection||(exports.ScrollDirection={}));var wi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbw=t,this.ƀcn="x",this.ƀbl=new Map,this.ƀhb={duration:300,animation:S.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀhb.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀhb.size.x+this.ƀhb.margin*2,this.ƀhb.size.y):new helpersLib.Vector(this.ƀhb.size.x,this.ƀhb.size.y+this.ƀhb.margin*2),r=new u().setPosition(this.ƀhb.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀhb.margin,0):new helpersLib.Vector(0,-this.ƀhb.margin),{round:false}).displayParent(this).attach(this);this.ƀcb(i,this.ƀhb.margin,this.ƀhb.direction,r),this.ƀcn=this.ƀhb.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀjm=new Le({duration:this.ƀhb.duration,animation:this.ƀhb.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbl.set(n,a),this.ƀbw({index:n,container:a});}else {let a=this.ƀbl.get(n);a&&(a.destroy(),this.ƀbl.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbl.get(n);if(a){let l={x:0,y:0};l[this.ƀcn]=i[this.ƀcn]*s+this.ƀhb.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjm.setIndex(t,e),this}ƀcb(t,e,i,r){new yt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},qi=class extends wi{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 xt=class{static{h(this,"VectorSet");}constructor(){this.ƀkj=new Map;}add(t){let e=this.ƀkj.get(t.x);e||(e=new Set,this.ƀkj.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀkj.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀkj.get(t.x);return e?e.delete(t.y):false}};var xi=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var B=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 re=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=B.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 xt,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 tr=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)}},qs=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀen=t,this.ƀjj=e,this.ƀgz=new helpersLib.BinaryHeap("min"),this.ƀay=[],this.ƀgn=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new tr(this.ƀjj,0,Number.MAX_SAFE_INTEGER);this.ƀgz.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀgz.size>0}getNeighbors(t,e){return this.ƀen.getNeighborPositions(t.position,e).filter(i=>this.ƀen.get(i)).map(i=>this.ƀgn.get(i)||this.ƀcc(i))}popLowestPathCostNode(){let t=this.ƀgz.pop();return this.ƀgz.delete(t),t.closed=true,this.ƀay.push(t),t}changeNodeCost(t,e,i,r){this.ƀgz.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀgz.add(t.pathLength,t);}getBestClosedNode(){return this.ƀay.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcc(t){let e=new tr(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgn.set(t,e),this.ƀgz.add(e.pathLength,e),e}},se=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new qs(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 oe=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjr=t,this.ƀx=e,this.ƀeu=this.ƀdw(this.ƀx.size),this.ƀkr=new helpersLib.Grid({size:this.ƀx.size,defaultValue:this.ƀeu}),this.ƀco=new helpersLib.Grid({size:this.ƀx.size,defaultValue:void 0});let i=new xt,r=new helpersLib.Queue;for(this.ƀdl(this.ƀx.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀkr.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀkr.getOrFail(n);this.ƀeb(n,this.ƀx).forEach(l=>{if(!i.has(l.position)){let c=this.ƀkr.getOrFail(l.position),p=a+l.distance;this.ƀx.getOrFail(l.position)&&p<c&&(this.ƀkr.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjr)){if(t=this.ƀkr.movePositionInsideGrid(t),this.ƀco.has(t))return this.ƀco.get(t);{let e=this.ƀeb(t,this.ƀx),i;return this.ƀkr.getOrFail(t)>=this.ƀeu?e.some(s=>this.ƀx.get(s.position))&&(e.some(n=>!this.ƀx.get(n.position))?i=this.ƀdq(e):i=this.ƀdm(t,e)):i=this.ƀdm(t,e),this.ƀco.set(t,i),i}}}ƀdq(t){let e=t.filter(i=>this.ƀx.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdm(t,e){let i=e.filter(r=>this.ƀkr.getOrFail(r.position)<this.ƀeu).reduce((r,s)=>{let n=this.ƀkr.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.ƀeu}).bestDirections;return this.ƀeg(i,t)}ƀeg(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀfl(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfl(t,e){let i=t.add(this.ƀkk(e));return this.ƀx.isPointWithinBounds(i)&&this.ƀx.getOrFail(i)}ƀeb(t,e){return this.ƀkr.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdl(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}ƀkk(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀdw(t){return (t.x+t.y)*20}};var so=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},oo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends z{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=so([dt(),oo("design:paramtypes",[helpersLib.Vector,Boolean,U__default.default.World,Map,Map,Map,Map])],v);var lo=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},K=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}};K=lo([d()],K);var co=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},po=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ve=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhj=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhj.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();}};Ve=co([d(),po("design:paramtypes",[K])],Ve);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},fo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},nt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhj=t,this.ƀy=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀy.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Gt){return e.aabbNeedsUpdate=true,e.updateAABB(),re.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀy.get(t,e,i);return r||(r=this.ƀbz(t,e,i),this.ƀy.set(t,e,i,r)),r}ƀbz(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.ƀhj.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdv(s,e);r.setArea(a,false);}}),r}ƀdv(t,e){let i=f.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=uo([d(),fo("design:paramtypes",[K,Ve])],nt);var yo=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},wo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Gt=50,_t=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhi=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Gt);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=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhi.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let E=f.aabbToBoundingBox(l.aabb),bt=B.areaToGridArea(E,s.gridCellSize);m.setArea(bt,true);}let g=se.findPath(m,c,p,s.neighborType);return g.path=g.path.map(E=>B.gridPositionToPosition(E,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Gt){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(g.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=B.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let g=this.ƀhi.getAvilabilityGrid(n,s,r);p=new oe(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};_t=yo([d(),wo("design:paramtypes",[nt])],_t);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},H=new $;exports.PhysicsGateway=class bi{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return H.trigger("createPhysicsWorld",t)}getMapSize(t){return H.trigger("getMapSize",t)}setPaused(t,e){return H.trigger("setPaused",t,e)}hitTest(t,e){return H.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return H.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return H.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return H.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return H.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return H.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Gt){return H.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};exports.PhysicsGateway=bo([d()],exports.PhysicsGateway);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},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Q=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀz=t,this.ƀhf=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀz.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhf.findPathDirection(t,c.position,i,r),m;p===void 0?m=T.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=T.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new A(m,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}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 A(a,"alpha",{duration:n,animation:S.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 m=p.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new A(l,"alpha",{duration:a,animation:S.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.ƀcr(c,n).displayParent(a).attachToRoot();}),new A(a,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcr(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.ƀcq(t,e);default:throw new Error("Not implemented")}}ƀcq(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Q=Po([d(),So("design:paramtypes",[nt,_t])],Q);var Eo=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)},Ne=class{static{h(this,"HitTestService");}constructor(t){this.ƀjt=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.ƀdj(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.ƀjt.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);}ƀdj(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Eo([d(),Ro("design:paramtypes",[Q])],Ne);var Ao=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},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀid(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀaz=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀid(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀep(r.p2Body),r.entity.ƀiv(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀep(t){let e=f.arrayToVector(t.velocity);e.length>10.8&&(e=e.normalize(10.8),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-10.01),10.01);}ƀid(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.ƀdo(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);}ƀdo(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.ƀec(i);return {collisionDetailsA:this.ƀdn(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdn(s,i.bodyB.mass,a,c,e.area)}}ƀdn(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}}ƀec(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=Ao([d()],je);var Oo=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},Mo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends Ut{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Oo([dt(),Mo("design:paramtypes",[Number,Object])],He);var Do=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},W=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbt(t,new helpersLib.Vector(e.x/2,-W/2),new helpersLib.Vector(e.x+W*2,W),i),this.ƀbt(t,new helpersLib.Vector(e.x/2,e.y+W/2),new helpersLib.Vector(e.x+W*2,W),i),this.ƀbt(t,new helpersLib.Vector(-W/2,e.y/2),new helpersLib.Vector(W,e.y+W*2),i),this.ƀbt(t,new helpersLib.Vector(e.x+W/2,e.y/2),new helpersLib.Vector(W,e.y+W*2),i);}ƀbt(t,e,i,r){return new He(t,{shapeDefinition:{materialName:st,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Do([d()],We);var Go=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},or=new U__default.default.Material,_o={id:st,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Ft=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(st))throw new Error(`Material with name ${st} cannot be defined, pick another name for the material.`);return s.set(st,or),n.set(st,_o),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀea(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdz(e,i.materialDefinitions)}ƀea(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀdz(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.ƀds(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀea(n.materialA,s),l=this.ƀea(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);}ƀds(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.ƀea(s.id,r);t.addContactMaterial(new U__default.default.ContactMaterial(n,or,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Ft=Go([d()],Ft);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},Lo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Lt=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgf=t,this.ƀaj=e,this.ƀz=i,this.ƀba=r,this.ƀhj=s;}createPhysicsWorld(t){let e=new U__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgf.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhj.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&&y.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀba.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjn(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjn(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀz.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjn(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.ƀba.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);}};Lt=Fo([d(),Lo("design:paramtypes",[Ft,We,nt,je,K])],Lt);var No=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},Nt=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.ƀbo(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.ƀbo(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbo(n,e));},"callback")});return t.p2World.raycast(new U__default.default.RaycastResult,s),Array.from(r.values())}ƀbo(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}}};Nt=No([d()],Nt);var jo=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},lt=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);}};lt=jo([d()],lt);var Ho=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},jt=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.ƀbp(r,t.length))}ƀbp(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")}}}};jt=Ho([d()],jt);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},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Jo=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀhz=t,this.ƀjt=e,this.ƀhy=i,this.ƀfe=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀce(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀhy.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀjt.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...E}=m;return E})}ƀce(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 m=l.normalize(i.y);a.push(new helpersLib.Line(t,t.add(m))),a.push(new helpersLib.Line(t,t.add(m.multiplyNumber(-1))));let g=Math.round(i.y/Jo),E=i.y/(g*2+1)*2,bt=l.normalize(E),ne=i.x,ar=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(g).forEach(pt=>{let Pt=E*(pt+1),Ci=bt.multiplyNumber(pt+1),ae=c.normalize(this.ƀek(ne,ar,Pt)),he=t.add(Ci);a.push(new helpersLib.Line(he,he.add(ae))),a.push(new helpersLib.Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ci.multiplyNumber(-1));a.push(new helpersLib.Line(le,le.add(ae))),a.push(new helpersLib.Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(pt=>{if(s){let Pt=this.ƀhz.castClosest(n,pt,r);return {line:pt,hits:Pt?[Pt]:[]}}else {let Pt=this.ƀhz.castAllFirstContacts(n,pt,r);return {line:pt,hits:Pt}}})}ƀek(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.ƀfe.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=Uo([d(),$o("design:paramtypes",[Nt,Q,jt,lt])],$e);var Yo=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},Xo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ze=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀhz=t,this.ƀjt=e,this.ƀhy=i,this.ƀfe=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeh(i),c=this.ƀce(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀhy.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀjt.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀce(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 m=this.ƀhz.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀhz.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfe.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.ƀfe.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeh(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ze=Yo([d(),Xo("design:paramtypes",[Nt,Q,jt,lt])],ze);var tn=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},Ht=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)}};Ht=tn([d()],Ht);var en=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},rn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀhq=t,this.ƀhf=e,this.ƀjt=i,this.ƀdb=r,this.ƀcv=s,this.ƀev=n,this.ƀhp=a,this.ƀfe=l;}createPhysicsWorld(t){return this.ƀhq.createPhysicsWorld(t)}getMapSize(t){return this.ƀhp.getMapSize(t)}setPaused(t,e){this.ƀhq.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀev.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhf.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhf.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfe.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdb.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcv.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n){this.ƀjt.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=en([q({controllerLink:H}),rn("design:paramtypes",[Lt,_t,Q,ze,$e,Ne,Ht,lt])],Pi);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},ke=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.ƀbv(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbv(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcd(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀcf(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbv(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}ƀcd(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new U__default.default.Convex({vertices:g.map(E=>[E.x,E.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,E)=>g+E.area,0),m=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(g=>m.addShape(g)),m.setDensity(r.density),m}ƀcf(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}};ke=sn([d()],ke);var on=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},nn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀhq=t,this.ƀho=e,this.ƀja=i,this.ƀhp=r,this.ƀhj=s;}createBody(t,e,i,r,s){return this.ƀja.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀho.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀho.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhj.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhj.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀhq.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀhq.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhp.subscribeToPhysicsStep(t,e)}};Si=on([q({controllerLink:J}),nn("design:paramtypes",[Lt,Ft,ke,Ht,K])],Si);exports.AnimationFlicker=Ai;exports.AnimationInterpolationFunctions=Y;exports.Animations=S;exports.Animator=A;exports.BORDER_MATERIAL_NAME=st;exports.BardLegendsHardReset=G;exports.Camera=Xt;exports.ClosestAvailableSpaceHelper=re;exports.Container=u;exports.ControllerDecorator=q;exports.ControllerLink=$;exports.DEFAULT_SHADER_RESOLUTION=O;exports.DeltaTime=xi;exports.DisplayObjectArray=ci;exports.Entity=z;exports.EntityDecorator=dt;exports.FadeInContent=Xi;exports.FadeInStateAnimation=_e;exports.Game=w;exports.Graphics=T;exports.ImmovablePhysicsEntity=Ut;exports.Menu=Bt;exports.MenuEntity=di;exports.MouseWheelListenerUI=ie;exports.MovableEntity=Xe;exports.MovablePhysicsEntity=Ke;exports.PathFinder=se;exports.PhysicsEntity=b;exports.Placeholder=ai;exports.PositionConversionHelper=kt;exports.ROTATIONAL_SPEED_LIMIT=Qe;exports.RichText=hi;exports.SPEED_LIMIT=Ze;exports.Scene=St;exports.SceneDecorator=gr;exports.ScrollAreaUI=mi;exports.ScrollMaskUI=yt;exports.Service=P;exports.ServiceDecorator=d;exports.SingletonEntity=ut;exports.SlideInContent=qi;exports.SlideInContentByIndex=wi;exports.SlideStateAnimation=Le;exports.Sprite=X;exports.StateAnimation=Fe;exports.Text=te;exports.UpdatableContainer=li;exports.UpdateCycle=y;exports.VectorFieldPathFinder=oe;exports.VectorSet=xt;exports.View=Wt;exports.ViewDecorator=Ye;