UNPKG

grid-engine

Version:

Phaser3 plugin for grid based movement on a 2D game board.

3 lines 220 kB
(()=>{var Sb=Object.create;var No=Object.defineProperty,Ob=Object.defineProperties,Eb=Object.getOwnPropertyDescriptor,Db=Object.getOwnPropertyDescriptors,Ib=Object.getOwnPropertyNames,bc=Object.getOwnPropertySymbols,Mb=Object.getPrototypeOf,Tc=Object.prototype.hasOwnProperty,Ab=Object.prototype.propertyIsEnumerable;var Pc=(s,e,r)=>e in s?No(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r,K=(s,e)=>{for(var r in e||(e={}))Tc.call(e,r)&&Pc(s,r,e[r]);if(bc)for(var r of bc(e))Ab.call(e,r)&&Pc(s,r,e[r]);return s},Bt=(s,e)=>Ob(s,Db(e));var de=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Rb=(s,e)=>{for(var r in e)No(s,r,{get:e[r],enumerable:!0})},Fb=(s,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ib(e))!Tc.call(s,a)&&a!==r&&No(s,a,{get:()=>e[a],enumerable:!(o=Eb(e,a))||o.enumerable});return s};var jo=(s,e,r)=>(r=s!=null?Sb(Mb(s)):{},Fb(e||!s||!s.__esModule?No(r,"default",{value:s,enumerable:!0}):r,s));var ba=de(Mi=>{var tP=function(s,e){return s<e?-1:s>e?1:0},eP=function(s,e){return s<e?1:s>e?-1:0};function rP(s){return function(e,r){return s(r,e)}}function iP(s){return s===2?function(e,r){return e[0]<r[0]?-1:e[0]>r[0]?1:e[1]<r[1]?-1:e[1]>r[1]?1:0}:function(e,r){for(var o=0;o<s;){if(e[o]<r[o])return-1;if(e[o]>r[o])return 1;o++}return 0}}Mi.DEFAULT_COMPARATOR=tP;Mi.DEFAULT_REVERSE_COMPARATOR=eP;Mi.reverseComparator=rP;Mi.createTupleComparator=iP});var $c=de(Pa=>{Pa.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer!="undefined";Pa.SYMBOL_SUPPORT=typeof Symbol!="undefined"});var Ai=de((AC,Yc)=>{var qc=$c(),oP=qc.ARRAY_BUFFER_SUPPORT,nP=qc.SYMBOL_SUPPORT;Yc.exports=function(e,r){var o,a,u,h,p;if(!e)throw new Error("obliterator/forEach: invalid iterable.");if(typeof r!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(e)||oP&&ArrayBuffer.isView(e)||typeof e=="string"||e.toString()==="[object Arguments]"){for(u=0,h=e.length;u<h;u++)r(e[u],u);return}if(typeof e.forEach=="function"){e.forEach(r);return}if(nP&&Symbol.iterator in e&&typeof e.next!="function"&&(e=e[Symbol.iterator]()),typeof e.next=="function"){for(o=e,u=0;p=o.next(),p.done!==!0;)r(p.value,u),u++;return}for(a in e)e.hasOwnProperty(a)&&r(e[a],a)}});var rh=de((RC,eh)=>{var Xc=ba(),Qc=Ai(),Kc=Xc.DEFAULT_COMPARATOR,sP=Xc.reverseComparator;function Et(s){if(this.clear(),this.comparator=s||Kc,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.")}Et.prototype.clear=function(){this.root=null,this.min=null,this.size=0};function aP(s){return{item:s,degree:0}}function Jc(s,e){s.root?(e.right=s.root.right,e.left=s.root,s.root.right.left=e,s.root.right=e):s.root=e}Et.prototype.push=function(s){var e=aP(s);return e.left=e,e.right=e,Jc(this,e),(!this.min||this.comparator(e.item,this.min.item)<=0)&&(this.min=e),++this.size};Et.prototype.peek=function(){return this.min?this.min.item:void 0};function Zc(s){for(var e=[],r=s,o=!1;!(r===s&&o);)r===s&&(o=!0),e.push(r),r=r.right;return e}function th(s,e){s.root===e&&(s.root=e.right),e.left.right=e.right,e.right.left=e.left}function uP(s,e){s.child?(e.right=s.child.right,e.left=s.child,s.child.right.left=e,s.child.right=e):s.child=e}function lP(s,e,r){th(s,e),e.left=e,e.right=e,uP(r,e),r.degree++,e.parent=r}function cP(s){var e=new Array(s.size),r=Zc(s.root),o,a,u,h,p,g;for(o=0,a=r.length;o<a;o++){for(u=r[o],p=u.degree;e[p];)h=e[p],s.comparator(u.item,h.item)>0&&(g=u,u=h,h=g),lP(s,h,u),e[p]=null,p++;e[p]=u}for(o=0;o<s.size;o++)e[o]&&s.comparator(e[o].item,s.min.item)<=0&&(s.min=e[o])}Et.prototype.pop=function(){if(this.size){var s=this.min;if(s.child){var e=Zc(s.child),r,o,a;for(o=0,a=e.length;o<a;o++)r=e[o],Jc(this,r),delete r.parent}return th(this,s),s===s.right?(this.min=null,this.root=null):(this.min=s.right,cP(this)),this.size--,s.item}};Et.prototype.inspect=function(){var s={size:this.size};return this.min&&"item"in this.min&&(s.top=this.min.item),Object.defineProperty(s,"constructor",{value:Et,enumerable:!1}),s};typeof Symbol!="undefined"&&(Et.prototype[Symbol.for("nodejs.util.inspect.custom")]=Et.prototype.inspect);function vn(s){if(this.clear(),this.comparator=s||Kc,typeof this.comparator!="function")throw new Error("mnemonist/FibonacciHeap.constructor: given comparator should be a function.");this.comparator=sP(this.comparator)}vn.prototype=Et.prototype;Et.from=function(s,e){var r=new Et(e);return Qc(s,function(o){r.push(o)}),r};vn.from=function(s,e){var r=new vn(e);return Qc(s,function(o){r.push(o)}),r};Et.MinFibonacciHeap=Et;Et.MaxFibonacciHeap=vn;eh.exports=Et});var Ta=de(Te=>{var hP=Math.pow(2,8)-1,fP=Math.pow(2,16)-1,pP=Math.pow(2,32)-1,mP=Math.pow(2,7)-1,gP=Math.pow(2,15)-1,dP=Math.pow(2,31)-1;Te.getPointerArray=function(s){var e=s-1;if(e<=hP)return Uint8Array;if(e<=fP)return Uint16Array;if(e<=pP)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")};Te.getSignedPointerArray=function(s){var e=s-1;return e<=mP?Int8Array:e<=gP?Int16Array:e<=dP?Int32Array:Float64Array};Te.getNumberType=function(s){return s===(s|0)?Math.sign(s)===-1?s<=127&&s>=-128?Int8Array:s<=32767&&s>=-32768?Int16Array:Int32Array:s<=255?Uint8Array:s<=65535?Uint16Array:Uint32Array:Float64Array};var yP={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};Te.getMinimalRepresentation=function(s,e){var r=null,o=0,a,u,h,p,g;for(p=0,g=s.length;p<g;p++)h=e?e(s[p]):s[p],u=Te.getNumberType(h),a=yP[u.name],a>o&&(o=a,r=u);return r};Te.isTypedArray=function(s){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView(s)};Te.concat=function(){var s=0,e,r,o;for(e=0,o=arguments.length;e<o;e++)s+=arguments[e].length;var a=new arguments[0].constructor(s);for(e=0,r=0;e<o;e++)a.set(arguments[e],r),r+=arguments[e].length;return a};Te.indices=function(s){for(var e=Te.getPointerArray(s),r=new e(s),o=0;o<s;o++)r[o]=o;return r}});var wa=de(Ri=>{var ih=Ai(),oh=Ta();function vP(s){return Array.isArray(s)||oh.isTypedArray(s)}function xa(s){if(typeof s.length=="number")return s.length;if(typeof s.size=="number")return s.size}function bP(s){var e=xa(s),r=typeof e=="number"?new Array(e):[],o=0;return ih(s,function(a){r[o++]=a}),r}function PP(s){var e=xa(s),r=typeof e=="number"?oh.getPointerArray(e):Array,o=typeof e=="number"?new Array(e):[],a=typeof e=="number"?new r(e):[],u=0;return ih(s,function(h){o[u]=h,a[u]=u++}),[o,a]}Ri.isArrayLike=vP;Ri.guessLength=xa;Ri.toArray=bP;Ri.toArrayWithIndices=PP});var lh=de((VC,uh)=>{var bn=Ai(),nh=ba(),xe=wa(),Tn=nh.DEFAULT_COMPARATOR,Ca=nh.reverseComparator;function _a(s,e,r,o){for(var a=e[o],u,h;o>r;){if(u=o-1>>1,h=e[u],s(a,h)<0){e[o]=h,o=u;continue}break}e[o]=a}function Fi(s,e,r){for(var o=e.length,a=r,u=e[r],h=2*r+1,p;h<o;)p=h+1,p<o&&s(e[h],e[p])>=0&&(h=p),e[r]=e[h],r=h,h=2*r+1;e[r]=u,_a(s,e,a,r)}function sh(s,e,r){e.push(r),_a(s,e,0,e.length-1)}function La(s,e){var r=e.pop();if(e.length!==0){var o=e[0];return e[0]=r,Fi(s,e,0),o}return r}function zr(s,e,r){if(e.length===0)throw new Error("mnemonist/heap.replace: cannot pop an empty heap.");var o=e[0];return e[0]=r,Fi(s,e,0),o}function ah(s,e,r){var o;return e.length!==0&&s(e[0],r)<0&&(o=e[0],e[0]=r,r=o,Fi(s,e,0)),r}function Tr(s,e){for(var r=e.length,o=r>>1,a=o;--a>=0;)Fi(s,e,a)}function Sa(s,e){for(var r=e.length,o=0,a=new Array(r);o<r;)a[o++]=La(s,e);return a}function TP(s,e,r){arguments.length===2&&(r=e,e=s,s=Tn);var o=Ca(s),a,u,h,p=1/0,g;if(e===1){if(xe.isArrayLike(r)){for(a=0,u=r.length;a<u;a++)h=r[a],(p===1/0||s(h,p)<0)&&(p=h);return g=new r.constructor(1),g[0]=p,g}return bn(r,function(L){(p===1/0||s(L,p)<0)&&(p=L)}),[p]}if(xe.isArrayLike(r)){if(e>=r.length)return r.slice().sort(s);for(g=r.slice(0,e),Tr(o,g),a=e,u=r.length;a<u;a++)o(r[a],g[0])>0&&zr(o,g,r[a]);return g.sort(s)}var T=xe.guessLength(r);return T!==null&&T<e&&(e=T),g=new Array(e),a=0,bn(r,function(L){a<e?g[a]=L:(a===e&&Tr(o,g),o(L,g[0])>0&&zr(o,g,L)),a++}),g.length>a&&(g.length=a),g.sort(s)}function xP(s,e,r){arguments.length===2&&(r=e,e=s,s=Tn);var o=Ca(s),a,u,h,p=-1/0,g;if(e===1){if(xe.isArrayLike(r)){for(a=0,u=r.length;a<u;a++)h=r[a],(p===-1/0||s(h,p)>0)&&(p=h);return g=new r.constructor(1),g[0]=p,g}return bn(r,function(L){(p===-1/0||s(L,p)>0)&&(p=L)}),[p]}if(xe.isArrayLike(r)){if(e>=r.length)return r.slice().sort(o);for(g=r.slice(0,e),Tr(s,g),a=e,u=r.length;a<u;a++)s(r[a],g[0])>0&&zr(s,g,r[a]);return g.sort(o)}var T=xe.guessLength(r);return T!==null&&T<e&&(e=T),g=new Array(e),a=0,bn(r,function(L){a<e?g[a]=L:(a===e&&Tr(s,g),s(L,g[0])>0&&zr(s,g,L)),a++}),g.length>a&&(g.length=a),g.sort(o)}function et(s){if(this.clear(),this.comparator=s||Tn,typeof this.comparator!="function")throw new Error("mnemonist/Heap.constructor: given comparator should be a function.")}et.prototype.clear=function(){this.items=[],this.size=0};et.prototype.push=function(s){return sh(this.comparator,this.items,s),++this.size};et.prototype.peek=function(){return this.items[0]};et.prototype.pop=function(){return this.size!==0&&this.size--,La(this.comparator,this.items)};et.prototype.replace=function(s){return zr(this.comparator,this.items,s)};et.prototype.pushpop=function(s){return ah(this.comparator,this.items,s)};et.prototype.consume=function(){return this.size=0,Sa(this.comparator,this.items)};et.prototype.toArray=function(){return Sa(this.comparator,this.items.slice())};et.prototype.inspect=function(){var s=this.toArray();return Object.defineProperty(s,"constructor",{value:et,enumerable:!1}),s};typeof Symbol!="undefined"&&(et.prototype[Symbol.for("nodejs.util.inspect.custom")]=et.prototype.inspect);function Pn(s){if(this.clear(),this.comparator=s||Tn,typeof this.comparator!="function")throw new Error("mnemonist/MaxHeap.constructor: given comparator should be a function.");this.comparator=Ca(this.comparator)}Pn.prototype=et.prototype;et.from=function(s,e){var r=new et(e),o;return xe.isArrayLike(s)?o=s.slice():o=xe.toArray(s),Tr(r.comparator,o),r.items=o,r.size=o.length,r};Pn.from=function(s,e){var r=new Pn(e),o;return xe.isArrayLike(s)?o=s.slice():o=xe.toArray(s),Tr(r.comparator,o),r.items=o,r.size=o.length,r};et.siftUp=Fi;et.siftDown=_a;et.push=sh;et.pop=La;et.replace=zr;et.pushpop=ah;et.heapify=Tr;et.consume=Sa;et.nsmallest=TP;et.nlargest=xP;et.MinHeap=et;et.MaxHeap=Pn;uh.exports=et});var mh=de((GC,ph)=>{var ch="";function hh(s,e,r){for(var o=e.length,a=[],u=o,h=-1,p,g=0,T;u--;)h=Math.max(s[e[u]+r],h);for(T=h>>24&&32||h>>16&&24||h>>8&&16||8;g<T;g+=4){for(u=16;u--;)a[u]=[];for(u=o;u--;)a[s[e[u]+r]>>g&15].push(e[u]);for(p=0;p<16;p++)for(h=a[p].length;h--;)e[++u]=a[p][h]}}function wP(s,e,r,o){return s[r]-s[o]||(r%3===2?s[r+1]-s[o+1]||e[r+2]-e[o+2]:e[r+1]-e[o+1])}function Oa(s,e){var r=[],o=[],a=2*e/3|0,u=e-a,h=a+1>>1,p=a,g=0,T,L=[],D=[];if(e===1)return[0];for(;p--;)r[p]=(p*3>>1)+1;for(p=3;p--;)hh(s,r,p);for(g=o[(r[0]/3|0)+(r[0]%3===1?0:h)]=1,p=1;p<a;p++)(s[r[p]]!==s[r[p-1]]||s[r[p]+1]!==s[r[p-1]+1]||s[r[p]+2]!==s[r[p-1]+2])&&g++,o[(r[p]/3|0)+(r[p]%3===1?0:h)]=g;if(g<a)for(o=Oa(o,a),p=a;p--;)r[p]=o[p]<h?o[p]*3+1:(o[p]-h)*3+2;for(p=a;p--;)L[r[p]]=p;for(L[e]=-1,L[e+1]=-2,o=e%3===1?[e-1]:[],p=0;p<a;p++)r[p]%3===1&&o.push(r[p]-1);for(hh(s,o,0),p=0,g=0,T=0;p<a&&g<u;)D[T++]=wP(s,L,r[p],o[g])<0?r[p++]:o[g++];for(;p<a;)D[T++]=r[p++];for(;g<u;)D[T++]=o[g++];return D}function fh(s){var e=s.length,r=e%3,o=new Array(e+r),a,u;if(typeof s!="string"){var h=Object.create(null);for(u=0;u<e;u++)h[s[u]]||(h[s[u]]=!0);var p=Object.create(null),g=Object.keys(h).sort();for(u=0,a=g.length;u<a;u++)p[g[u]]=u+1;for(u=0;u<e;u++)o[u]=p[s[u]]}else for(u=0;u<e;u++)o[u]=s.charCodeAt(u);for(u=e;u<e+r;u++)o[u]=0;return o}function Je(s){this.hasArbitrarySequence=typeof s!="string",this.string=s,this.length=s.length,this.array=Oa(fh(s),this.length)}Je.prototype.toString=function(){return this.array.join(",")};Je.prototype.toJSON=function(){return this.array};Je.prototype.inspect=function(){for(var s=new Array(this.length),e=0;e<this.length;e++)s[e]=this.string.slice(this.array[e]);return Object.defineProperty(s,"constructor",{value:Je,enumerable:!1}),s};typeof Symbol!="undefined"&&(Je.prototype[Symbol.for("nodejs.util.inspect.custom")]=Je.prototype.inspect);function Ze(s){if(this.hasArbitrarySequence=typeof s[0]!="string",this.size=s.length,this.hasArbitrarySequence){this.text=[];for(var e=0,r=this.size;e<r;e++)this.text.push.apply(this.text,s[e]),e<r-1&&this.text.push(ch)}else this.text=s.join(ch);this.firstLength=s[0].length,this.length=this.text.length,this.array=Oa(fh(this.text),this.length)}Ze.prototype.longestCommonSubsequence=function(){var s=this.hasArbitrarySequence?[]:"",e,r,o,a,u;for(r=1;r<this.length;r++)if(a=this.array[r],u=this.array[r-1],!(a<this.firstLength&&u<this.firstLength)&&!(a>this.firstLength&&u>this.firstLength)){for(e=Math.min(this.length-a,this.length-u),o=0;o<e;o++)if(this.text[a+o]!==this.text[u+o]){e=o;break}e>s.length&&(s=this.text.slice(a,a+e))}return s};Ze.prototype.toString=function(){return this.array.join(",")};Ze.prototype.toJSON=function(){return this.array};Ze.prototype.inspect=function(){for(var s=new Array(this.length),e=0;e<this.length;e++)s[e]=this.text.slice(this.array[e]);return Object.defineProperty(s,"constructor",{value:Ze,enumerable:!1}),s};typeof Symbol!="undefined"&&(Ze.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ze.prototype.inspect);Je.GeneralizedSuffixArray=Ze;ph.exports=Je});var dh=de((NC,gh)=>{function we(s){if(typeof s!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=s}typeof Symbol!="undefined"&&(we.prototype[Symbol.iterator]=function(){return this});we.of=function(){var s=arguments,e=s.length,r=0;return new we(function(){return r>=e?{done:!0}:{done:!1,value:s[r++]}})};we.empty=function(){var s=new we(function(){return{done:!0}});return s};we.fromSequence=function(s){var e=0,r=s.length;return new we(function(){return e>=r?{done:!0}:{done:!1,value:s[e++]}})};we.is=function(s){return s instanceof we?!0:typeof s=="object"&&s!==null&&typeof s.next=="function"};gh.exports=we});var Ph=de((jC,bh)=>{var yh=dh(),CP=Ai(),_P=wa(),vh=Ta(),LP=function(s){return Math.max(1,Math.ceil(s*1.5))},SP=function(s){var e=vh.getPointerArray(s);return new e(s)};function q(s,e){if(arguments.length<1)throw new Error("mnemonist/vector: expecting at least a byte array constructor.");var r=e||0,o=LP,a=0,u=!1;typeof e=="object"&&(r=e.initialCapacity||0,a=e.initialLength||0,o=e.policy||o,u=e.factory===!0),this.factory=u?s:null,this.ArrayClass=s,this.length=a,this.capacity=Math.max(a,r),this.policy=o,this.array=new s(this.capacity)}q.prototype.set=function(s,e){if(this.length<s)throw new Error("Vector("+this.ArrayClass.name+").set: index out of bounds.");return this.array[s]=e,this};q.prototype.get=function(s){if(!(this.length<s))return this.array[s]};q.prototype.applyPolicy=function(s){var e=this.policy(s||this.capacity);if(typeof e!="number"||e<0)throw new Error("mnemonist/vector.applyPolicy: policy returned an invalid value (expecting a positive integer).");if(e<=this.capacity)throw new Error("mnemonist/vector.applyPolicy: policy returned a less or equal capacity to allocate.");return e};q.prototype.reallocate=function(s){if(s===this.capacity)return this;var e=this.array;if(s<this.length&&(this.length=s),s>this.capacity)if(this.factory===null?this.array=new this.ArrayClass(s):this.array=this.factory(s),vh.isTypedArray(this.array))this.array.set(e,0);else for(var r=0,o=this.length;r<o;r++)this.array[r]=e[r];else this.array=e.slice(0,s);return this.capacity=s,this};q.prototype.grow=function(s){var e;if(typeof s=="number"){if(this.capacity>=s)return this;for(e=this.capacity;e<s;)e=this.applyPolicy(e);return this.reallocate(e),this}return e=this.applyPolicy(),this.reallocate(e),this};q.prototype.resize=function(s){return s===this.length?this:s<this.length?(this.length=s,this):(this.length=s,this.reallocate(s),this)};q.prototype.push=function(s){return this.capacity===this.length&&this.grow(),this.array[this.length++]=s,this.length};q.prototype.pop=function(){if(this.length!==0)return this.array[--this.length]};q.prototype.values=function(){var s=this.array,e=this.length,r=0;return new yh(function(){if(r>=e)return{done:!0};var o=s[r];return r++,{value:o,done:!1}})};q.prototype.entries=function(){var s=this.array,e=this.length,r=0;return new yh(function(){if(r>=e)return{done:!0};var o=s[r];return{value:[r++,o],done:!1}})};typeof Symbol!="undefined"&&(q.prototype[Symbol.iterator]=q.prototype.values);q.prototype.inspect=function(){var s=this.array.slice(0,this.length);return s.type=this.array.constructor.name,s.items=this.length,s.capacity=this.capacity,Object.defineProperty(s,"constructor",{value:q,enumerable:!1}),s};typeof Symbol!="undefined"&&(q.prototype[Symbol.for("nodejs.util.inspect.custom")]=q.prototype.inspect);q.from=function(s,e,r){if(arguments.length<3&&(r=_P.guessLength(s),typeof r!="number"))throw new Error("mnemonist/vector.from: could not guess iterable length. Please provide desired capacity as last argument.");var o=new q(e,r);return CP(s,function(a){o.push(a)}),o};function Ce(s){var e=function(o){q.call(this,s,o)};for(var r in q.prototype)q.prototype.hasOwnProperty(r)&&(e.prototype[r]=q.prototype[r]);return e.from=function(o,a){return q.from(o,s,a)},typeof Symbol!="undefined"&&(e.prototype[Symbol.iterator]=e.prototype.values),e}q.Int8Vector=Ce(Int8Array);q.Uint8Vector=Ce(Uint8Array);q.Uint8ClampedVector=Ce(Uint8ClampedArray);q.Int16Vector=Ce(Int16Array);q.Uint16Vector=Ce(Uint16Array);q.Int32Vector=Ce(Int32Array);q.Uint32Vector=Ce(Uint32Array);q.Float32Vector=Ce(Float32Array);q.Float64Vector=Ce(Float64Array);q.PointerVector=Ce(SP);bh.exports=q});var ja={};Rb(ja,{ArrayTilemap:()=>Nn,CharacterShiftAction:()=>Rn,CollisionStrategy:()=>Di,Direction:()=>Ot,GridEngine:()=>Wi,GridEngineHeadless:()=>ji,MoveToResult:()=>kn,NoPathFoundStrategy:()=>Pr,NumberOfDirections:()=>mr,PathBlockedStrategy:()=>Wr,PhaserTile:()=>er,PhaserTileLayer:()=>Kr,PhaserTilemap:()=>Bi,QueuedPathBlockedStrategy:()=>Ra,TiledLayer:()=>Zr,TiledTile:()=>Jr,TiledTilemap:()=>jn,directionFromPos:()=>vt});var P=class s{static get ZERO(){return new s(0,0)}static get ONE(){return new s(1,1)}static get UP(){return new s(0,-1)}static get DOWN(){return new s(0,1)}static get LEFT(){return new s(-1,0)}static get RIGHT(){return new s(1,0)}static get UP_LEFT(){return new s(-1,-1)}static get UP_RIGHT(){return new s(1,-1)}static get DOWN_RIGHT(){return new s(1,1)}static get DOWN_LEFT(){return new s(-1,1)}constructor(e,r){typeof e=="number"?(this.x=e,this.y=r||0):(this.x=e.x,this.y=e.y)}clone(){return new s(this.x,this.y)}add(e){return new s(this.x+e.x,this.y+e.y)}multiply(e){return new s(this.x*e.x,this.y*e.y)}divide(e){return new s(this.x/e.x,this.y/e.y)}subtract(e){return new s(this.x-e.x,this.y-e.y)}equals(e){return this.x===e.x&&this.y===e.y}abs(){return new s(Math.abs(this.x),Math.abs(this.y))}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}modulo(e){return new s(this.x%e.x,this.y%e.y)}scalarModulo(e){return new s(this.x%e,this.y%e)}scalarMult(e){return new s(this.x*e,this.y*e)}toPosition(){return{x:this.x,y:this.y}}toString(){return`${this.x}#${this.y}`}};var A=class{static equal(e,r){return e.position.x===r.position.x&&e.position.y===r.position.y&&e.layer===r.layer}static copyOver(e,r){r.position.x=e.position.x,r.position.y=e.position.y,r.layer=e.layer}static clone(e){return{position:e.position.clone(),layer:e.layer}}static toString(e){return`${e.position.toString()}#${e.layer}`}static toInternal(e){return{position:new P(e.position.x,e.position.y),layer:e.charLayer}}static fromInternal(e){return{position:e.position.toPosition(),charLayer:e.layer}}};var Ot=(T=>(T.NONE="none",T.LEFT="left",T.UP_LEFT="up-left",T.UP="up",T.UP_RIGHT="up-right",T.RIGHT="right",T.DOWN_RIGHT="down-right",T.DOWN="down",T.DOWN_LEFT="down-left",T))(Ot||{}),kb={up:"down",down:"up",left:"right",right:"left",none:"none","up-left":"down-right","up-right":"down-left","down-right":"up-left","down-left":"up-right"},Vb={up:P.UP,down:P.DOWN,left:P.LEFT,right:P.RIGHT,none:P.ZERO,"up-left":P.UP_LEFT,"up-right":P.UP_RIGHT,"down-right":P.DOWN_RIGHT,"down-left":P.DOWN_LEFT},wi={up:0,"up-right":1,right:2,"down-right":3,down:4,"down-left":5,left:6,"up-left":7,none:NaN},xc=["up","up-right","right","down-right","down","down-left","left","up-left"],Gb=["down-left","down-right","up-right","up-left"];function Ci(){return["up","down","left","right","none","up-left","up-right","down-right","down-left"]}function pr(s){return Gb.includes(s)}function wc(s,e=1){return s==="none"?"none":xc[(wi[s]+8-Math.abs(e)%8)%8]}function Uo(s,e=1){return s==="none"?"none":xc[(wi[s]+e)%8]}function Ht(s){return Vb[s]}function _i(s){return kb[s]}function vt(s,e){if(s.x===e.x){if(s.y>e.y)return"up";if(s.y<e.y)return"down"}else if(s.y===e.y){if(s.x>e.x)return"left";if(s.x<e.x)return"right"}else if(s.x>e.x){if(s.y<e.y)return"down-left";if(s.y>e.y)return"up-left"}else if(s.x<e.x){if(s.y<e.y)return"down-right";if(s.y>e.y)return"up-right"}return"none"}var mr=(r=>(r[r.FOUR=4]="FOUR",r[r.EIGHT=8]="EIGHT",r))(mr||{});function Qe(s){return typeof s=="string"&&Ci().includes(s)}var la=function(s,e){return la=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])},la(s,e)};function Ke(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");la(s,e);function r(){this.constructor=s}s.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Cc(s,e,r,o){function a(u){return u instanceof r?u:new r(function(h){h(u)})}return new(r||(r=Promise))(function(u,h){function p(L){try{T(o.next(L))}catch(D){h(D)}}function g(L){try{T(o.throw(L))}catch(D){h(D)}}function T(L){L.done?u(L.value):a(L.value).then(p,g)}T((o=o.apply(s,e||[])).next())})}function Bo(s,e){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},o,a,u,h=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return h.next=p(0),h.throw=p(1),h.return=p(2),typeof Symbol=="function"&&(h[Symbol.iterator]=function(){return this}),h;function p(T){return function(L){return g([T,L])}}function g(T){if(o)throw new TypeError("Generator is already executing.");for(;h&&(h=0,T[0]&&(r=0)),r;)try{if(o=1,a&&(u=T[0]&2?a.return:T[0]?a.throw||((u=a.return)&&u.call(a),0):a.next)&&!(u=u.call(a,T[1])).done)return u;switch(a=0,u&&(T=[T[0]&2,u.value]),T[0]){case 0:case 1:u=T;break;case 4:return r.label++,{value:T[1],done:!1};case 5:r.label++,a=T[1],T=[0];continue;case 7:T=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(T[0]===6||T[0]===2)){r=0;continue}if(T[0]===3&&(!u||T[1]>u[0]&&T[1]<u[3])){r.label=T[1];break}if(T[0]===6&&r.label<u[1]){r.label=u[1],u=T;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(T);break}u[2]&&r.ops.pop(),r.trys.pop();continue}T=e.call(s,r)}catch(L){T=[6,L],a=0}finally{o=u=0}if(T[0]&5)throw T[1];return{value:T[0]?T[1]:void 0,done:!0}}}function ke(s){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&s[e],o=0;if(r)return r.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&o>=s.length&&(s=void 0),{value:s&&s[o++],done:!s}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(s,e){var r=typeof Symbol=="function"&&s[Symbol.iterator];if(!r)return s;var o=r.call(s),a,u=[],h;try{for(;(e===void 0||e-- >0)&&!(a=o.next()).done;)u.push(a.value)}catch(p){h={error:p}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(h)throw h.error}}return u}function ve(s,e,r){if(r||arguments.length===2)for(var o=0,a=e.length,u;o<a;o++)(u||!(o in e))&&(u||(u=Array.prototype.slice.call(e,0,o)),u[o]=e[o]);return s.concat(u||Array.prototype.slice.call(e))}function gr(s){return this instanceof gr?(this.v=s,this):new gr(s)}function _c(s,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=r.apply(s,e||[]),a,u=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),p("next"),p("throw"),p("return",h),a[Symbol.asyncIterator]=function(){return this},a;function h(M){return function(H){return Promise.resolve(H).then(M,D)}}function p(M,H){o[M]&&(a[M]=function(B){return new Promise(function(st,ft){u.push([M,B,st,ft])>1||g(M,B)})},H&&(a[M]=H(a[M])))}function g(M,H){try{T(o[M](H))}catch(B){Y(u[0][3],B)}}function T(M){M.value instanceof gr?Promise.resolve(M.value.v).then(L,D):Y(u[0][2],M)}function L(M){g("next",M)}function D(M){g("throw",M)}function Y(M,H){M(H),u.shift(),u.length&&g(u[0][0],u[0][1])}}function Lc(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],r;return e?e.call(s):(s=typeof ke=="function"?ke(s):s[Symbol.iterator](),r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r);function o(u){r[u]=s[u]&&function(h){return new Promise(function(p,g){h=s[u](h),a(p,g,h.done,h.value)})}}function a(u,h,p,g){Promise.resolve(g).then(function(T){u({value:T,done:p})},h)}}function X(s){return typeof s=="function"}function Ho(s){var e=function(o){Error.call(o),o.stack=new Error().stack},r=s(e);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Wo=Ho(function(s){return function(r){s(this),this.message=r?r.length+` errors occurred during unsubscription: `+r.map(function(o,a){return a+1+") "+o.toString()}).join(` `):"",this.name="UnsubscriptionError",this.errors=r}});function Li(s,e){if(s){var r=s.indexOf(e);0<=r&&s.splice(r,1)}}var jr=(function(){function s(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return s.prototype.unsubscribe=function(){var e,r,o,a,u;if(!this.closed){this.closed=!0;var h=this._parentage;if(h)if(this._parentage=null,Array.isArray(h))try{for(var p=ke(h),g=p.next();!g.done;g=p.next()){var T=g.value;T.remove(this)}}catch(B){e={error:B}}finally{try{g&&!g.done&&(r=p.return)&&r.call(p)}finally{if(e)throw e.error}}else h.remove(this);var L=this.initialTeardown;if(X(L))try{L()}catch(B){u=B instanceof Wo?B.errors:[B]}var D=this._finalizers;if(D){this._finalizers=null;try{for(var Y=ke(D),M=Y.next();!M.done;M=Y.next()){var H=M.value;try{Sc(H)}catch(B){u=u!=null?u:[],B instanceof Wo?u=ve(ve([],ye(u)),ye(B.errors)):u.push(B)}}}catch(B){o={error:B}}finally{try{M&&!M.done&&(a=Y.return)&&a.call(Y)}finally{if(o)throw o.error}}}if(u)throw new Wo(u)}},s.prototype.add=function(e){var r;if(e&&e!==this)if(this.closed)Sc(e);else{if(e instanceof s){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(e)}},s.prototype._hasParent=function(e){var r=this._parentage;return r===e||Array.isArray(r)&&r.includes(e)},s.prototype._addParent=function(e){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(e),r):r?[r,e]:e},s.prototype._removeParent=function(e){var r=this._parentage;r===e?this._parentage=null:Array.isArray(r)&&Li(r,e)},s.prototype.remove=function(e){var r=this._finalizers;r&&Li(r,e),e instanceof s&&e._removeParent(this)},s.EMPTY=(function(){var e=new s;return e.closed=!0,e})(),s})();var ca=jr.EMPTY;function zo(s){return s instanceof jr||s&&"closed"in s&&X(s.remove)&&X(s.add)&&X(s.unsubscribe)}function Sc(s){X(s)?s():s.unsubscribe()}var ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Ur={setTimeout:function(s,e){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];var a=Ur.delegate;return a!=null&&a.setTimeout?a.setTimeout.apply(a,ve([s,e],ye(r))):setTimeout.apply(void 0,ve([s,e],ye(r)))},clearTimeout:function(s){var e=Ur.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(s)},delegate:void 0};function $o(s){Ur.setTimeout(function(){var e=ae.onUnhandledError;if(e)e(s);else throw s})}function Si(){}var Oc=(function(){return ha("C",void 0,void 0)})();function Ec(s){return ha("E",void 0,s)}function Dc(s){return ha("N",s,void 0)}function ha(s,e,r){return{kind:s,value:e,error:r}}var dr=null;function Br(s){if(ae.useDeprecatedSynchronousErrorHandling){var e=!dr;if(e&&(dr={errorThrown:!1,error:null}),s(),e){var r=dr,o=r.errorThrown,a=r.error;if(dr=null,o)throw a}}else s()}function Ic(s){ae.useDeprecatedSynchronousErrorHandling&&dr&&(dr.errorThrown=!0,dr.error=s)}var Oi=(function(s){Ke(e,s);function e(r){var o=s.call(this)||this;return o.isStopped=!1,r?(o.destination=r,zo(r)&&r.add(o)):o.destination=Bb,o}return e.create=function(r,o,a){return new Yo(r,o,a)},e.prototype.next=function(r){this.isStopped?pa(Dc(r),this):this._next(r)},e.prototype.error=function(r){this.isStopped?pa(Ec(r),this):(this.isStopped=!0,this._error(r))},e.prototype.complete=function(){this.isStopped?pa(Oc,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,s.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(r){this.destination.next(r)},e.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(jr);var Nb=Function.prototype.bind;function fa(s,e){return Nb.call(s,e)}var jb=(function(){function s(e){this.partialObserver=e}return s.prototype.next=function(e){var r=this.partialObserver;if(r.next)try{r.next(e)}catch(o){qo(o)}},s.prototype.error=function(e){var r=this.partialObserver;if(r.error)try{r.error(e)}catch(o){qo(o)}else qo(e)},s.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(r){qo(r)}},s})(),Yo=(function(s){Ke(e,s);function e(r,o,a){var u=s.call(this)||this,h;if(X(r)||!r)h={next:r!=null?r:void 0,error:o!=null?o:void 0,complete:a!=null?a:void 0};else{var p;u&&ae.useDeprecatedNextContext?(p=Object.create(r),p.unsubscribe=function(){return u.unsubscribe()},h={next:r.next&&fa(r.next,p),error:r.error&&fa(r.error,p),complete:r.complete&&fa(r.complete,p)}):h=r}return u.destination=new jb(h),u}return e})(Oi);function qo(s){ae.useDeprecatedSynchronousErrorHandling?Ic(s):$o(s)}function Ub(s){throw s}function pa(s,e){var r=ae.onStoppedNotification;r&&Ur.setTimeout(function(){return r(s,e)})}var Bb={closed:!0,next:Si,error:Ub,complete:Si};var Hr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Xo(s){return s}function ma(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];return ga(s)}function ga(s){return s.length===0?Xo:s.length===1?s[0]:function(r){return s.reduce(function(o,a){return a(o)},r)}}var bt=(function(){function s(e){e&&(this._subscribe=e)}return s.prototype.lift=function(e){var r=new s;return r.source=this,r.operator=e,r},s.prototype.subscribe=function(e,r,o){var a=this,u=Wb(e)?e:new Yo(e,r,o);return Br(function(){var h=a,p=h.operator,g=h.source;u.add(p?p.call(u,g):g?a._subscribe(u):a._trySubscribe(u))}),u},s.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(r){e.error(r)}},s.prototype.forEach=function(e,r){var o=this;return r=Mc(r),new r(function(a,u){var h=new Yo({next:function(p){try{e(p)}catch(g){u(g),h.unsubscribe()}},error:u,complete:a});o.subscribe(h)})},s.prototype._subscribe=function(e){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(e)},s.prototype[Hr]=function(){return this},s.prototype.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return ga(e)(this)},s.prototype.toPromise=function(e){var r=this;return e=Mc(e),new e(function(o,a){var u;r.subscribe(function(h){return u=h},function(h){return a(h)},function(){return o(u)})})},s.create=function(e){return new s(e)},s})();function Mc(s){var e;return(e=s!=null?s:ae.Promise)!==null&&e!==void 0?e:Promise}function Hb(s){return s&&X(s.next)&&X(s.error)&&X(s.complete)}function Wb(s){return s&&s instanceof Oi||Hb(s)&&zo(s)}function zb(s){return X(s==null?void 0:s.lift)}function Ct(s){return function(e){if(zb(e))return e.lift(function(r){try{return s(r,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function Wt(s,e,r,o,a){return new $b(s,e,r,o,a)}var $b=(function(s){Ke(e,s);function e(r,o,a,u,h,p){var g=s.call(this,r)||this;return g.onFinalize=h,g.shouldUnsubscribe=p,g._next=o?function(T){try{o(T)}catch(L){r.error(L)}}:s.prototype._next,g._error=u?function(T){try{u(T)}catch(L){r.error(L)}finally{this.unsubscribe()}}:s.prototype._error,g._complete=a?function(){try{a()}catch(T){r.error(T)}finally{this.unsubscribe()}}:s.prototype._complete,g}return e.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;s.prototype.unsubscribe.call(this),!o&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},e})(Oi);var Ac=Ho(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var J=(function(s){Ke(e,s);function e(){var r=s.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return e.prototype.lift=function(r){var o=new Rc(this,this);return o.operator=r,o},e.prototype._throwIfClosed=function(){if(this.closed)throw new Ac},e.prototype.next=function(r){var o=this;Br(function(){var a,u;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var h=ke(o.currentObservers),p=h.next();!p.done;p=h.next()){var g=p.value;g.next(r)}}catch(T){a={error:T}}finally{try{p&&!p.done&&(u=h.return)&&u.call(h)}finally{if(a)throw a.error}}}})},e.prototype.error=function(r){var o=this;Br(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=r;for(var a=o.observers;a.length;)a.shift().error(r)}})},e.prototype.complete=function(){var r=this;Br(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var o=r.observers;o.length;)o.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(r){return this._throwIfClosed(),s.prototype._trySubscribe.call(this,r)},e.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},e.prototype._innerSubscribe=function(r){var o=this,a=this,u=a.hasError,h=a.isStopped,p=a.observers;return u||h?ca:(this.currentObservers=null,p.push(r),new jr(function(){o.currentObservers=null,Li(p,r)}))},e.prototype._checkFinalizedStatuses=function(r){var o=this,a=o.hasError,u=o.thrownError,h=o.isStopped;a?r.error(u):h&&r.complete()},e.prototype.asObservable=function(){var r=new bt;return r.source=this,r},e.create=function(r,o){return new Rc(r,o)},e})(bt);var Rc=(function(s){Ke(e,s);function e(r,o){var a=s.call(this)||this;return a.destination=r,a.source=o,a}return e.prototype.next=function(r){var o,a;(a=(o=this.destination)===null||o===void 0?void 0:o.next)===null||a===void 0||a.call(o,r)},e.prototype.error=function(r){var o,a;(a=(o=this.destination)===null||o===void 0?void 0:o.error)===null||a===void 0||a.call(o,r)},e.prototype.complete=function(){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||o===void 0||o.call(r)},e.prototype._subscribe=function(r){var o,a;return(a=(o=this.source)===null||o===void 0?void 0:o.subscribe(r))!==null&&a!==void 0?a:ca},e})(J);var Qo=new bt(function(s){return s.complete()});function Fc(s){return s&&X(s.schedule)}function kc(s){return s[s.length-1]}function Ko(s){return Fc(kc(s))?s.pop():void 0}function Jo(s,e){return typeof kc(s)=="number"?s.pop():e}var Zo=(function(s){return s&&typeof s.length=="number"&&typeof s!="function"});function tn(s){return X(s==null?void 0:s.then)}function en(s){return X(s[Hr])}function rn(s){return Symbol.asyncIterator&&X(s==null?void 0:s[Symbol.asyncIterator])}function on(s){return new TypeError("You provided "+(s!==null&&typeof s=="object"?"an invalid object":"'"+s+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function qb(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var nn=qb();function sn(s){return X(s==null?void 0:s[nn])}function an(s){return _c(this,arguments,function(){var r,o,a,u;return Bo(this,function(h){switch(h.label){case 0:r=s.getReader(),h.label=1;case 1:h.trys.push([1,,9,10]),h.label=2;case 2:return[4,gr(r.read())];case 3:return o=h.sent(),a=o.value,u=o.done,u?[4,gr(void 0)]:[3,5];case 4:return[2,h.sent()];case 5:return[4,gr(a)];case 6:return[4,h.sent()];case 7:return h.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function un(s){return X(s==null?void 0:s.getReader)}function Rt(s){if(s instanceof bt)return s;if(s!=null){if(en(s))return Yb(s);if(Zo(s))return Xb(s);if(tn(s))return Qb(s);if(rn(s))return Vc(s);if(sn(s))return Kb(s);if(un(s))return Jb(s)}throw on(s)}function Yb(s){return new bt(function(e){var r=s[Hr]();if(X(r.subscribe))return r.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Xb(s){return new bt(function(e){for(var r=0;r<s.length&&!e.closed;r++)e.next(s[r]);e.complete()})}function Qb(s){return new bt(function(e){s.then(function(r){e.closed||(e.next(r),e.complete())},function(r){return e.error(r)}).then(null,$o)})}function Kb(s){return new bt(function(e){var r,o;try{for(var a=ke(s),u=a.next();!u.done;u=a.next()){var h=u.value;if(e.next(h),e.closed)return}}catch(p){r={error:p}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}e.complete()})}function Vc(s){return new bt(function(e){Zb(s,e).catch(function(r){return e.error(r)})})}function Jb(s){return Vc(an(s))}function Zb(s,e){var r,o,a,u;return Cc(this,void 0,void 0,function(){var h,p;return Bo(this,function(g){switch(g.label){case 0:g.trys.push([0,5,6,11]),r=Lc(s),g.label=1;case 1:return[4,r.next()];case 2:if(o=g.sent(),!!o.done)return[3,4];if(h=o.value,e.next(h),e.closed)return[2];g.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return p=g.sent(),a={error:p},[3,11];case 6:return g.trys.push([6,,9,10]),o&&!o.done&&(u=r.return)?[4,u.call(r)]:[3,8];case 7:g.sent(),g.label=8;case 8:return[3,10];case 9:if(a)throw a.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Zt(s,e,r,o,a){o===void 0&&(o=0),a===void 0&&(a=!1);var u=e.schedule(function(){r(),a?s.add(this.schedule(null,o)):this.unsubscribe()},o);if(s.add(u),!a)return u}function ln(s,e){return e===void 0&&(e=0),Ct(function(r,o){r.subscribe(Wt(o,function(a){return Zt(o,s,function(){return o.next(a)},e)},function(){return Zt(o,s,function(){return o.complete()},e)},function(a){return Zt(o,s,function(){return o.error(a)},e)}))})}function cn(s,e){return e===void 0&&(e=0),Ct(function(r,o){o.add(s.schedule(function(){return r.subscribe(o)},e))})}function Gc(s,e){return Rt(s).pipe(cn(e),ln(e))}function Nc(s,e){return Rt(s).pipe(cn(e),ln(e))}function jc(s,e){return new bt(function(r){var o=0;return e.schedule(function(){o===s.length?r.complete():(r.next(s[o++]),r.closed||this.schedule())})})}function Uc(s,e){return new bt(function(r){var o;return Zt(r,e,function(){o=s[nn](),Zt(r,e,function(){var a,u,h;try{a=o.next(),u=a.value,h=a.done}catch(p){r.error(p);return}h?r.complete():r.next(u)},0,!0)}),function(){return X(o==null?void 0:o.return)&&o.return()}})}function hn(s,e){if(!s)throw new Error("Iterable cannot be null");return new bt(function(r){Zt(r,e,function(){var o=s[Symbol.asyncIterator]();Zt(r,e,function(){o.next().then(function(a){a.done?r.complete():r.next(a.value)})},0,!0)})})}function Bc(s,e){return hn(an(s),e)}function Hc(s,e){if(s!=null){if(en(s))return Gc(s,e);if(Zo(s))return jc(s,e);if(tn(s))return Nc(s,e);if(rn(s))return hn(s,e);if(sn(s))return Uc(s,e);if(un(s))return Bc(s,e)}throw on(s)}function fn(s,e){return e?Hc(s,e):Rt(s)}function be(s,e){return Ct(function(r,o){var a=0;r.subscribe(Wt(o,function(u){o.next(s.call(e,u,a++))}))})}function Wc(s,e,r,o,a,u,h,p){var g=[],T=0,L=0,D=!1,Y=function(){D&&!g.length&&!T&&e.complete()},M=function(B){return T<o?H(B):g.push(B)},H=function(B){u&&e.next(B),T++;var st=!1;Rt(r(B,L++)).subscribe(Wt(e,function(ft){a==null||a(ft),u?M(ft):e.next(ft)},function(){st=!0},void 0,function(){if(st)try{T--;for(var ft=function(){var rr=g.shift();h?Zt(e,h,function(){return H(rr)}):H(rr)};g.length&&T<o;)ft();Y()}catch(rr){e.error(rr)}}))};return s.subscribe(Wt(e,M,function(){D=!0,Y()})),function(){p==null||p()}}function da(s,e,r){return r===void 0&&(r=1/0),X(e)?da(function(o,a){return be(function(u,h){return e(o,u,a,h)})(Rt(s(o,a)))},r):(typeof e=="number"&&(r=e),Ct(function(o,a){return Wc(o,a,s,r)}))}function pn(s){return s===void 0&&(s=1/0),da(Xo,s)}function ya(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var r=Ko(s),o=Jo(s,1/0),a=s;return a.length?a.length===1?Rt(a[0]):pn(o)(fn(a,r)):Qo}function Tt(s,e){return Ct(function(r,o){var a=0;r.subscribe(Wt(o,function(u){return s.call(e,u,a++)&&o.next(u)}))})}function Ft(s){return s<=0?function(){return Qo}:Ct(function(e,r){var o=0;e.subscribe(Wt(r,function(a){++o<=s&&(r.next(a),s<=o&&r.complete())}))})}function zc(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var r=Ko(s),o=Jo(s,1/0);return Ct(function(a,u){pn(o)(fn(ve([a],ye(s)),r)).subscribe(u)})}function va(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];return zc.apply(void 0,ve([],ye(s)))}function gt(s){return Ct(function(e,r){Rt(s).subscribe(Wt(r,function(){return r.complete()},Si)),!r.closed&&e.subscribe(r)})}var Ve=1e3,mn=class{constructor(e,r){this.id=e;this.movementDirection="none";this._tilePos={position:new P(0,0),layer:void 0};this.movementStarted$=new J;this.movementStopped$=new J;this.directionChanged$=new J;this.positionChangeStarted$=new J;this.positionChangeFinished$=new J;this.tilePositionSet$=new J;this.autoMovementSet$=new J;this.lastMovementImpulse="none";this.facingDirection="down";this.depthChanged$=new J;this.movementProgress=0;this.currentMovementReverted=!1;var o,a,u;this.tilemap=r.tilemap,this.speed=r.speed,this.collidesWithTilesInternal=r.collidesWithTiles,this._tilePos.layer=r.charLayer,this.ignoreMissingTiles=(o=r.ignoreMissingTiles)!=null?o:!1,this.collisionGroups=new Set(r.collisionGroups||[]),this.ignoreCollisionGroups=new Set(r.ignoreCollisionGroups||[]),this.labels=new Set(r.labels||[]),this.numberOfDirections=r.numberOfDirections,r.facingDirection&&this.turnTowards(r.facingDirection),this.tileWidth=(a=r.tileWidth)!=null?a:1,this.tileHeight=(u=r.tileHeight)!=null?u:1}getId(){return this.id}getSpeed(){return this.speed}setSpeed(e){this.speed=e}setMovement(e){this.autoMovementSet$.next(e),this.movement=e}getMovement(){return this.movement}collidesWithTiles(){return this.collidesWithTilesInternal}setCollidesWithTiles(e){this.collidesWithTilesInternal=e}getIgnoreMissingTiles(){return this.ignoreMissingTiles}setIgnoreMissingTiles(e){this.ignoreMissingTiles=e}setTilePosition(e){this.currentMovementReverted=!1,this.isMoving()&&this.movementStopped$.next(this.movementDirection),this.tilePositionSet$.next(K({},e)),this.fire(this.positionChangeStarted$,this.tilePos,e),this.fire(this.positionChangeFinished$,this.tilePos,e),this.movementDirection="none",this.lastMovementImpulse="none",this.tilePos=e,this.movementProgress=0}getTilePos(){return this.tilePos}getNextTilePos(){if(!this.isMoving())return this.tilePos;if(this.currentMovementReverted)return this.tilePos;let e=this.tilePos.layer,r=this.tilePosInDirection(this.tilePos.position,this.movementDirection),o=this.tilemap.getTransition(r,this.tilePos.layer);return o&&(e=o),{position:this.tilePosInDirection(this.tilePos.position,this.movementDirection),layer:e}}getTileWidth(){return this.tileWidth}getTileHeight(){return this.tileHeight}move(e){this.lastMovementImpulse=e,e!="none"&&(this.isMoving()||(this.isBlockingDirection(e)?this.changeFacingDirection(e):this.startMoving(e)))}update(e){var r;(r=this.movement)==null||r.update(e),this.isMoving()&&this.updateCharacterPosition(e),this.lastMovementImpulse="none"}getMovementDirection(){return this.movementDirection}isBlockingDirection(e){if(e=="none")return!1;let r=this.tilePosInDirection(this.getNextTilePos().position,e),o=this.tilemap.getTransition(r,this.getNextTilePos().layer)||this.getNextTilePos().layer;return this.collidesWithTilesInternal&&this.isTileBlocking(e,o)?!0:this.isCharBlocking(e,o)}isTileBlocking(e,r){return this.someCharTile((o,a)=>{let u=this.tilePosInDirection(new P(o,a),e);return this.tilemap.hasBlockingTile(u,r,_i(e),this.ignoreMissingTiles)})}revertCurrentMovement(){this.isMoving()&&(this.currentMovementReverted=!0,this.movementDirection=_i(this.movementDirection),this.movementStopped$.next(this.facingDirection),this.facingDirection=this.movementDirection,this.movementProgress=Ve-this.movementProgress,this.movementStarted$.next(this.facingDirection))}isCurrentMovementReverted(){return this.currentMovementReverted}isCharBlocking(e,r){return this.someCharTile((o,a)=>{let u=this.tilePosInDirection(new P(o,a),e);return this.tilemap.hasBlockingChar(u,r,this.getCollisionGroups(),new Set([this.getId()]),this.ignoreCollisionGroups)})}isMoving(){return this.movementDirection!="none"}turnTowards(e){this.isMoving()||e!="none"&&this.changeFacingDirection(e)}changeFacingDirection(e){this.facingDirection!==e&&(this.facingDirection=e,this.directionChanged$.next(e))}getFacingDirection(){return this.facingDirection}getFacingPosition(){return this._tilePos.position.add(Ht(this.facingDirection))}addCollisionGroup(e){this.collisionGroups.add(e)}setCollisionGroups(e){this.collisionGroups=new Set(e)}setIgnoreCollisionGroups(e){this.ignoreCollisionGroups=new Set(e)}getCollisionGroups(){return Array.from(this.collisionGroups)}getIgnoreCollisionGroups(){return Array.from(this.ignoreCollisionGroups)}hasCollisionGroup(e){return this.collisionGroups.has(e)}removeCollisionGroup(e){this.collisionGroups.delete(e)}removeAllCollisionGroups(){this.collisionGroups.clear()}addLabels(e){for(let r of e)this.labels.add(r)}getLabels(){return[...this.labels.values()]}hasLabel(e){return this.labels.has(e)}clearLabels(){this.labels.clear()}removeLabels(e){for(let r of e)this.labels.delete(r)}getNumberOfDirections(){return this.numberOfDirections}movementStarted(){return this.movementStarted$}movementStopped(){return this.movementStopped$}directionChanged(){return this.directionChanged$}tilePositionSet(){return this.tilePositionSet$}positionChangeStarted(){return this.positionChangeStarted$}positionChangeFinished(){return this.positionChangeFinished$}autoMovementSet(){return this.autoMovementSet$}depthChanged(){return this.depthChanged$}getMovementProgress(){return this.movementProgress}setMovementProgress(e){let r=Math.max(0,Math.min(Ve,e));this.movementProgress=r}hasWalkedHalfATile(){return this.movementProgress>Ve/2}willCrossTileBorderThisUpdate(e){return this.movementProgress+this.maxProgressForDelta(e)>=Ve}updateCharacterPosition(e){let r=this.willCrossTileBorderThisUpdate(e),a=1-(r?Ve-this.movementProgress:this.maxProgressForDelta(e))/this.maxProgressForDelta(e);this.movementProgress=Math.min(this.movementProgress+this.maxProgressForDelta(e),Ve),r&&(this.movementProgress=0,this.shouldContinueMoving()?(this.fire(this.positionChangeFinished$,this.tilePos,this.getNextTilePos()),this.tilePos=this.getNextTilePos(),this.startMoving(this.lastMovementImpulse),a>0&&this.updateCharacterPosition(e*a)):this.stopMoving())}maxProgressForDelta(e){let o=e/1e3;return Math.floor(o*this.speed*Ve)}get tilePos(){return A.clone(this._tilePos)}set tilePos(e){A.copyOver(e,this._tilePos)}startMoving(e){e!=="none"&&(this.currentMovementReverted=!1,e!=this.movementDirection&&this.movementStarted$.next(e),this.movementDirection=e,this.facingDirection=e,this.fire(this.positionChangeStarted$,this.tilePos,this.getNextTilePos()))}tilePosInDirection(e,r){return e.add(Ht(this.tilemap.toMapDirection(r)))}shouldContinueMoving(){return this.lastMovementImpulse!=="none"&&!this.isBlockingDirection(this.lastMovementImpulse)}stopMoving(){if(this.movementDirection==="none")return;let e=this.tilePos,r=this.getNextTilePos(),o=this.movementDirection;this.tilePos=this.getNextTilePos(),this.movementDirection="none",this.movementStopped$.next(o),this.currentMovementReverted=!1,this.fire(this.positionChangeFinished$,e,r)}fire(e,{position:r,layer:o},{position:a,layer:u}){e.next({exitTile:r,enterTile:a,exitLayer:o,enterLayer:u})}someCharTile(e){let r=this.getNextTilePos().position;for(let o=r.x;o<r.x+this.getTileWidth();o++)for(let a=r.y;a<r.y+this.getTileHeight();a++)if(e(o,a))return!0;return!1}};var yr=class yr{constructor(e,r){this.walkingAnimationMapping=e;this.charsInRow=r;this.lastFootLeft=!1;this.directionToFrameRow={down:0,"down-left":1,"down-right":2,left:1,right:2,up:3,"up-left":1,"up-right":2};this._isEnabled=!0;this.frameChange$=new J;this.setWalkingAnimationMapping(e)}frameChange(){return this.frameChange$}setIsEnabled(e){this._isEnabled=e}isEnabled(){return this._isEnabled}updateCharacterFrame(e,r,o){this._isEnabled&&(r?this.setStandingFrameDuringWalk(e,o):this.setWalkingFrame(e))}setStandingFrame(e){this._isEnabled&&this._setStandingFrame(e)}setWalkingAnimationMapping(e){this.walkingAnimationMapping=e,this._isEnabled=this.walkingAnimationMapping!==void 0}getWalkingAnimationMapping(){return this.walkingAnimationMapping}getCharsInRow(){return this.charsInRow}setStandingFrameDuringWalk(e,r){this.isCurrentFrameStanding(e,r)||(this.lastFootLeft=!this.lastFootLeft),this._setStandingFrame(e)}setWalkingFrame(e){let r=this.framesOfDirection(e);r&&this.frameChange$.next(this.lastFootLeft?r.rightFoot:r.leftFoot)}_setStandingFrame(e){let r=this.framesOfDirecti