Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elmajs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elmajs - npm Package Compare versions

Comparing version 1.2.0 to 1.2.2

2

lib-esm/rec/Replay.js

@@ -231,3 +231,3 @@ import { Position } from '../shared';

for (const ride of this.rides) {
const touchEvents = ride.events.filter((event) => event.type === 0);
const touchEvents = ride.events.filter((event) => event.type === 0).sort((a, b) => b.time - a.time);
const appleEvents = ride.events.filter((event) => event.type === 4);

@@ -234,0 +234,0 @@ const unique = [...new Set(touchEvents.map((event) => event.touchInfo))].map((event, idx) => touchEvents[idx]);

@@ -18,5 +18,6 @@ "use strict";

};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -269,5 +270,5 @@ var __values = (this && this.__values) || function(o) {

var _loop_1 = function (ride) {
var touchEvents = ride.events.filter(function (event) { return event.type === 0; });
var touchEvents = ride.events.filter(function (event) { return event.type === 0; }).sort(function (a, b) { return b.time - a.time; });
var appleEvents = ride.events.filter(function (event) { return event.type === 4; });
var unique = __spread(new Set(touchEvents.map(function (event) { return event.touchInfo; }))).map(function (event, idx) { return touchEvents[idx]; });
var unique = __spreadArray([], __read(new Set(touchEvents.map(function (event) { return event.touchInfo; })))).map(function (event, idx) { return touchEvents[idx]; });
appleEvents.forEach(function (appleEvent) {

@@ -274,0 +275,0 @@ var touchEventWithSameTime = unique.findIndex(function (touchEvent) {

@@ -18,5 +18,6 @@ "use strict";

};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};

@@ -204,3 +205,3 @@ var __values = (this && this.__values) || function(o) {

var name = util_1.trimString(buffer.slice(0, PLAYERENTRY_NAME_SIZE));
var skippedInternals = __spread(buffer.slice(PLAYERENTRY_NAME_SIZE, PLAYERENTRY_NAME_SIZE + NUM_INTERNALS)).map(Boolean);
var skippedInternals = __spreadArray([], __read(buffer.slice(PLAYERENTRY_NAME_SIZE, PLAYERENTRY_NAME_SIZE + NUM_INTERNALS))).map(Boolean);
var lastInternal = buffer.readUInt32LE(PLAYERENTRY_NAME_SIZE + NUM_INTERNALS + PLAYERENTRY_PADDING);

@@ -207,0 +208,0 @@ var selectedInternal = buffer.readUInt32LE(PLAYERENTRY_NAME_SIZE + NUM_INTERNALS + PLAYERENTRY_PADDING + 4);

{
"name": "elmajs",
"version": "1.2.0",
"version": "1.2.2",
"description": "Elasto Mania NPM package to read, modify and write Elma files",

@@ -37,8 +37,8 @@ "main": "lib/index.js",

"@types/fs-extra": "^9.0.1",
"@types/jest": "^26.0.3",
"@types/jest": "^27.0.1",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^3.10.1",
"eslint": "^7.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"fs-extra": "^9.0.1",

@@ -48,4 +48,4 @@ "jest": "^24.7.1",

"ts-jest": "^24.0.2",
"ts-loader": "^8.0.1",
"typedoc": "^0.19.0",
"ts-loader": "^9.2.6",
"typedoc": "^0.22.4",
"typescript": "^4.0.2",

@@ -52,0 +52,0 @@ "webpack": "^5.1.3",

/*! For license information please see main.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("ElmaJS",[],e):"object"==typeof exports?exports.ElmaJS=e():t.ElmaJS=e()}(self,(function(){return t={742:(t,e)=>{"use strict";e.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=f(t),a=o[0],s=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),l=0,c=s>0?a-4:a;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,f=n-i;s<f;s+=a)o.push(u(t,s,s+a>f?f:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a<s;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(t,e,r)=>{"use strict";const n=r(742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=function(t){return+t!=t&&(t=0),f.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);const i=function(t){if(f.isBuffer(t)){const e=0|y(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return l(t),s(t<0?0:0|y(t))}function h(t){const e=t.length<0?0:0|y(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function y(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function d(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(i)return n?-1:W(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){let o,a=1,s=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,f/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===f)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+f>s&&(r=s-f),o=r;o>=0;o--){let r=!0;for(let n=0;n<f;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(q(n))return a;t[r+a]=n}return a}function b(t,e,r,n){return J(W(e,t.length-r),t,r,n)}function I(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function L(t,e,r,n){return J(H(e),t,r,n)}function B(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,f;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(f=(31&e)<<6|63&r,f>127&&(o=f));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(f=(15&e)<<12|(63&r)<<6|63&n,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(f=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,f>65535&&f<1114112&&(o=f))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=T));return r}(n)}e.kMaxLength=a,f.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),f.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}}),f.poolSize=8192,f.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,Uint8Array),f.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},f.allocUnsafe=function(t){return c(t)},f.allocUnsafeSlow=function(t){return c(t)},f.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==f.prototype},f.compare=function(t,e){if(Y(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),Y(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(t)||!f.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=f.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Y(e,Uint8Array))i+e.length>n.length?(f.isBuffer(e)||(e=f.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!f.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},f.byteLength=d,f.prototype._isBuffer=!0,f.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)v(this,e,e+1);return this},f.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},f.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},f.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):g.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(f.prototype[o]=f.prototype.inspect),f.prototype.compare=function(t,e,r,n,i){if(Y(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),u=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<s;++t)if(u[t]!==l[t]){o=u[t],a=l[t];break}return o<a?-1:a<o?1:0},f.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},f.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},f.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},f.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return I(this,t,e,r);case"base64":return L(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function A(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Q[t[n]];return i}function _(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function D(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function M(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,o){return e=+e,r>>>=0,o||M(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,o){return e=+e,r>>>=0,o||M(t,0,r,8),i.write(t,e,r,n,52,8),r+8}f.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,f.prototype),n},f.prototype.readUintLE=f.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUintBE=f.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},f.prototype.readUint8=f.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readBigUInt64LE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),f.prototype.readBigUInt64BE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),f.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},f.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readBigInt64LE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),f.prototype.readBigInt64BE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),f.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigUInt64LE=X((function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),f.prototype.writeBigUInt64BE=X((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigInt64LE=X((function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),f.prototype.writeBigInt64BE=X((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),f.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},f.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},f.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},f.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},f.prototype.copy=function(t,e,r,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},f.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=f.isBuffer(t)?t:f.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const C={};function F(t,e,r){C[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function z(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new C.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new C.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new C.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new C.ERR_BUFFER_OUT_OF_BOUNDS;throw new C.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?t+" is outside of buffer bounds":"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=$(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const Q=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function X(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},645:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,f=(1<<s)-1,u=f>>1,l=-7,c=r?i-1:0,h=r?-1:1,p=t[e+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+t[e+c],c+=h,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+t[e+c],c+=h,l-=8);if(0===o)o=1-u;else{if(o===f)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=u}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,f,u=8*o-i-1,l=(1<<u)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-a))<1&&(a--,f*=2),(e+=a+c>=1?h/f:h*Math.pow(2,1-c))*f>=2&&(a++,f/=2),a+c>=l?(s=0,a=l):a+c>=1?(s=(e*f-1)*Math.pow(2,i),a+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+p]=255&a,p+=y,a/=256,u-=8);t[r+p-y]|=128*d}},341:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(436),e),i(r(494),e),i(r(936),e),i(r(570),e),i(r(469),e),i(r(367),e)},951:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Gravity=e.ObjectType=void 0;var n,i,o=r(936);!function(t){t[t.Exit=1]="Exit",t[t.Apple=2]="Apple",t[t.Killer=3]="Killer",t[t.Start=4]="Start"}(n=e.ObjectType||(e.ObjectType={})),function(t){t[t.None=0]="None",t[t.Up=1]="Up",t[t.Down=2]="Down",t[t.Left=3]="Left",t[t.Right=4]="Right"}(i=e.Gravity||(e.Gravity={}));e.default=function(){this.position=new o.Position,this.type=n.Apple,this.gravity=i.None,this.animation=1}},88:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.Version=void 0;var o,a=r(764),s=r(341),f=6754362,u=8674642;!function(t){t[t.Across=0]="Across",t[t.Elma=1]="Elma"}(o=e.Version||(e.Version={}));var l=function(){function t(){this.version=o.Elma,this.link=0,this.integrity=[0,0,0,0],this.lgr="default",this.name="Unnamed level",this.ground="ground",this.sky="sky",this.polygons=[{grass:!1,vertices:[new s.Position(10,0),new s.Position(10,7),new s.Position(0,7),new s.Position(0,0)]}],this.objects=[{animation:1,gravity:s.Gravity.None,position:new s.Position(2,0+s.OBJECT_RADIUS),type:s.ObjectType.Start},{animation:1,gravity:s.Gravity.None,position:new s.Position(8,0+s.OBJECT_RADIUS),type:s.ObjectType.Exit}],this.pictures=[],this.top10={multi:[],single:[]}}return t.from=function(t){return this.parseBuffer(a.Buffer.from(t))},t.cryptTop10=function(t){for(var e=a.Buffer.from(t),r=21,n=9783,i=0;i<688;i++)e[i]^=255&r,r=(65535&(r=31*(n+=r%3389*3389)+3389))-2*(32768&r);return e},t.parseBuffer=function(e){var r=new t;r.polygons=[],r.objects=[];var i=0;switch(e.toString("ascii",0,5)){case"POT06":throw r.version=o.Across,new Error("Across levels are not supported");case"POT14":r.version=o.Elma;break;default:throw new Error("Not valid Elma level")}i+=7,r.link=e.readUInt32LE(i),i+=4;for(var a=0;a<4;a++)r.integrity[a]=e.readDoubleLE(i),i+=8;r.name=s.trimString(e.slice(i,i+51)),i+=51,r.lgr=s.trimString(e.slice(i,i+16)),i+=16,r.ground=s.trimString(e.slice(i,i+10)),i+=10,r.sky=s.trimString(e.slice(i,i+10)),i+=10;var l=e.readDoubleLE(i)-.4643643;i+=8;var c=n(this.parsePolygons(e,i,l),2),h=c[0],p=c[1];r.polygons=h,i=p;var y=e.readDoubleLE(i)-.4643643;i+=8,r.objects=this.parseObjects(e,i,y),i+=28*y;var d=e.readDoubleLE(i)-.2345672;if(i+=8,r.pictures=this.parsePictures(e,i,d),i+=54*d,e.readInt32LE(i)!==f)throw new Error("End of data marker mismatch");i+=4;var g=t.cryptTop10(e.slice(i,i+688));if(r.top10=s.bufferToTop10(g),i+=688,e.readInt32LE(i)!==u)throw new Error("End of file marker mismatch");return r},t.parsePolygons=function(t,e,r){for(var n=[],i=0;i<r;i++){var o=new s.Polygon;o.grass=Boolean(t.readInt32LE(e)),e+=4;var a=t.readInt32LE(e);e+=4;for(var f=0;f<a;f++){var u=t.readDoubleLE(e);e+=8;var l=t.readDoubleLE(e);e+=8,o.vertices.push(new s.Position(u,l))}n.push(o)}return[n,e]},t.parseObjects=function(t,e,r){for(var n=[],i=0;i<r;i++){var o=new s.ElmaObject;if(o.position.x=t.readDoubleLE(e),e+=8,o.position.y=t.readDoubleLE(e),e+=8,o.type=t.readInt32LE(e),o.type<1||o.type>4)throw new Error("Invalid object type value="+o.type+" at offset="+e);if(e+=4,o.gravity=t.readInt32LE(e),o.gravity<0||o.gravity>4)throw new Error("Invalid gravity value="+o.gravity+" at offset="+e);e+=4,o.animation=t.readInt32LE(e)+1,e+=4,n.push(o)}return n},t.parsePictures=function(t,e,r){for(var n=[],i=0;i<r;i++){var o=new s.Picture;if(o.name=s.trimString(t.slice(e,e+10)),e+=10,o.texture=s.trimString(t.slice(e,e+10)),e+=10,o.mask=s.trimString(t.slice(e,e+10)),e+=10,o.position.x=t.readDoubleLE(e),e+=8,o.position.y=t.readDoubleLE(e),e+=8,o.distance=t.readInt32LE(e),e+=4,o.clip=t.readInt32LE(e),o.clip<0||o.clip>2)throw new Error("Invalid clip value="+o.clip+" at offset="+e);e+=4,n.push(o)}return n},t.prototype.toBuffer=function(){var e,r,n,l,c,h,p,y,d,g,v=this.calculateIntegrity(),w=850;try{for(var E=i(this.polygons),m=E.next();!m.done;m=E.next())w+=8+16*(A=m.value).vertices.length}catch(t){e={error:t}}finally{try{m&&!m.done&&(r=E.return)&&r.call(E)}finally{if(e)throw e.error}}w+=28*this.objects.length+54*this.pictures.length;var b=a.Buffer.alloc(w);if(this.version!==o.Elma)throw new Error("Only Elma levels are supported");b.write("POT14",0,5,"ascii"),b.writeUInt16LE(65535&this.link,5),b.writeUInt32LE(this.link,7);for(var I=0;I<v.length;I++)b.writeDoubleLE(v[I],11+8*I);var L=s.nullpadString(this.name,51);b.write(L,43,51,"ascii");var B=s.nullpadString(this.lgr,16);b.write(B,94,16,"ascii");var S=s.nullpadString(this.ground,10);b.write(S,110,10,"ascii");var U=s.nullpadString(this.sky,10);b.write(U,120,10,"ascii"),b.writeDoubleLE(this.polygons.length+.4643643,130);var T=138;try{for(var O=i(this.polygons),P=O.next();!P.done;P=O.next()){var A=P.value;b.writeInt32LE(A.grass?1:0,T),T+=4,b.writeInt32LE(A.vertices.length,T),T+=4;try{for(var _=(c=void 0,i(A.vertices)),R=_.next();!R.done;R=_.next()){var x=R.value;b.writeDoubleLE(x.x,T),T+=8,b.writeDoubleLE(x.y,T),T+=8}}catch(t){c={error:t}}finally{try{R&&!R.done&&(h=_.return)&&h.call(_)}finally{if(c)throw c.error}}}}catch(t){n={error:t}}finally{try{P&&!P.done&&(l=O.return)&&l.call(O)}finally{if(n)throw n.error}}b.writeDoubleLE(this.objects.length+.4643643,T),T+=8;try{for(var j=i(this.objects),D=j.next();!D.done;D=j.next()){var M=D.value;b.writeDoubleLE(M.position.x,T),T+=8,b.writeDoubleLE(M.position.y,T),T+=8,b.writeInt32LE(M.type,T),T+=4,b.writeInt32LE(M.gravity,T),T+=4,b.writeInt32LE(M.animation-1,T),T+=4}}catch(t){p={error:t}}finally{try{D&&!D.done&&(y=j.return)&&y.call(j)}finally{if(p)throw p.error}}b.writeDoubleLE(this.pictures.length+.2345672,T),T+=8;try{for(var k=i(this.pictures),N=k.next();!N.done;N=k.next()){var C=N.value,F=s.nullpadString(C.name,10);b.write(F,T,10,"ascii"),T+=10;var $=s.nullpadString(C.texture,10);b.write($,T,10,"ascii"),T+=10;var z=s.nullpadString(C.mask,10);b.write(z,T,10,"ascii"),T+=10,b.writeDoubleLE(C.position.x,T),T+=8,b.writeDoubleLE(C.position.y,T),T+=8,b.writeInt32LE(C.distance,T),T+=4,b.writeInt32LE(C.clip,T),T+=4}}catch(t){d={error:t}}finally{try{N&&!N.done&&(g=k.return)&&g.call(k)}finally{if(d)throw d.error}}b.writeInt32LE(f,T),T+=4;var G=s.top10ToBuffer(this.top10);return t.cryptTop10(G).copy(b,T),T+=688,b.writeInt32LE(u,T),b},t.prototype.calculateIntegrity=function(){var t,e,r,n,o,a,f,u,l=0;try{for(var c=i(this.polygons),h=c.next();!h.done;h=c.next()){var p=h.value;try{for(var y=(r=void 0,i(p.vertices)),d=y.next();!d.done;d=y.next()){var g=d.value;l+=g.x+g.y}}catch(t){r={error:t}}finally{try{d&&!d.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}var v=0;try{for(var w=i(this.objects),E=w.next();!E.done;E=w.next()){var m=E.value,b=0;m.type===s.ObjectType.Exit?b=1:m.type===s.ObjectType.Apple?b=2:m.type===s.ObjectType.Killer?b=3:m.type===s.ObjectType.Start&&(b=4),v+=m.position.x+m.position.y+b}}catch(t){o={error:t}}finally{try{E&&!E.done&&(a=w.return)&&a.call(w)}finally{if(o)throw o.error}}var I=0;try{for(var L=i(this.pictures),B=L.next();!B.done;B=L.next()){var S=B.value;I+=S.position.x+S.position.y}}catch(t){f={error:t}}finally{try{B&&!B.done&&(u=L.return)&&u.call(L)}finally{if(f)throw f.error}}var U=3247.764325643*(l+v+I);return[U,this.getRandomInt(0,5871)+11877-U,this.getRandomInt(0,5871)+11877-U,this.getRandomInt(0,6102)+12112-U]},t.prototype.getRandomInt=function(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t))+t},t}();e.default=l},85:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(936);e.default=function(){this.name="barrel",this.texture="",this.mask="",this.position=new n.Position(0,0),this.distance=600,this.clip=n.Clip.Sky,this.grass=!1,this.vertices=[]}},595:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(){this.grass=!1,this.vertices=[]}},436:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Version=e.Level=e.Polygon=e.Picture=e.ObjectType=e.Gravity=e.ElmaObject=void 0;var i=r(951);Object.defineProperty(e,"ElmaObject",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(e,"Gravity",{enumerable:!0,get:function(){return i.Gravity}}),Object.defineProperty(e,"ObjectType",{enumerable:!0,get:function(){return i.ObjectType}});var o=r(85);Object.defineProperty(e,"Picture",{enumerable:!0,get:function(){return n(o).default}});var a=r(595);Object.defineProperty(e,"Polygon",{enumerable:!0,get:function(){return n(a).default}});var s=r(88);Object.defineProperty(e,"Level",{enumerable:!0,get:function(){return n(s).default}}),Object.defineProperty(e,"Version",{enumerable:!0,get:function(){return s.Version}})},599:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a};Object.defineProperty(e,"__esModule",{value:!0});var i=r(764),o=r(341),a=r(570),s=187565543,f=function(){function t(){this.pictureList=[],this.pictureData=[],this.path=""}return t.from=function(t){return this.parseBuffer(i.Buffer.from(t))},t.parseBuffer=function(e){var r=new t,i=e.toString("ascii",0,5);if("LGR12"!==i)throw new Error("Invalid LGR version: "+i);var o=e.readInt32LE(5),a=e.readInt32LE(9);if(1002!==a)throw new Error("Invalid header: "+a);var f=e.readInt32LE(13);r.pictureList=r.parseListData(e.slice(17,17+26*f),f);var u=n(r.parsePictureData(e.slice(17+26*f),o),2),l=u[0],c=u[1];if(r.pictureData=l,e.readInt32LE(17+26*f+c)!==s)throw new Error("EOF marker expected at byte: "+(17+26*f+c));return r},t.prototype.toBuffer=function(){var t=this.pictureList.length,e=this.pictureData.reduce((function(t,e){return t+e.data.length+24}),21+26*t),r=i.Buffer.alloc(e),n=0;return r.write("LGR12",n,5,"ascii"),n+=5,r.writeUInt32LE(this.pictureData.length,n),n+=4,r.writeInt32LE(1002,n),n+=4,r.writeUInt32LE(t,n),n+=4,this.pictureList.forEach((function(e,i){r.write(a.nullpadString(e.name,10),n+10*i,10,"ascii"),r.writeUInt32LE(e.pictureType,n+10*t+4*i),r.writeUInt32LE(e.distance,n+14*t+4*i),r.writeUInt32LE(e.clipping,n+18*t+4*i),r.writeUInt32LE(e.transparency,n+22*t+4*i)})),n+=26*t,this.pictureData.forEach((function(t){r.write(a.nullpadString(t.name,20),n,20,"ascii"),n+=20,r.writeUInt32LE(t.data.length,n),n+=4,n+=t.data.copy(r,n)})),r.writeInt32LE(s,n),r},t.prototype.parseListData=function(t,e){var r=[],n=0,i=t.slice(n,n+10*e);n+=10*e;var s=t.slice(n,n+4*e);n+=4*e;var f=t.slice(n,n+4*e);n+=4*e;var u=t.slice(n,n+4*e);n+=4*e;for(var l=t.slice(n,n+4*e),c=0;c<e;c++){var h=new o.PictureDeclaration;h.name=a.trimString(i.slice(10*c,10*c+10)),h.pictureType=s.readInt32LE(4*c),h.distance=f.readInt32LE(4*c),h.clipping=u.readInt32LE(4*c),h.transparency=l.readInt32LE(4*c),r.push(h)}return r},t.prototype.parsePictureData=function(t,e){for(var r=[],n=0,i=0;i<e;i++){var s=a.trimString(t.slice(n,n+12));n+=20;var f=t.readUInt32LE(n);n+=4;var u=t.slice(n,n+f);r.push(new o.PictureData(s,u)),n+=f}return[r,n]},t}();e.default=f},59:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(t,e){this.name=t,this.data=e}},868:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Transparency=e.PictureType=void 0;var n,i,o=r(936);!function(t){t[t.Normal=100]="Normal",t[t.Texture=101]="Texture",t[t.Mask=102]="Mask"}(n=e.PictureType||(e.PictureType={})),function(t){t[t.Solid=10]="Solid",t[t.Palette=11]="Palette",t[t.TopLeft=12]="TopLeft",t[t.TopRight=13]="TopRight",t[t.BottomLeft=14]="BottomLeft",t[t.BottomRight=15]="BottomRight"}(i=e.Transparency||(e.Transparency={}));e.default=function(){this.name="",this.pictureType=n.Normal,this.distance=450,this.clipping=o.Clip.Sky,this.transparency=i.TopLeft}},469:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Transparency=e.PictureType=e.PictureDeclaration=e.PictureData=e.LGR=void 0;var i=r(599);Object.defineProperty(e,"LGR",{enumerable:!0,get:function(){return n(i).default}});var o=r(59);Object.defineProperty(e,"PictureData",{enumerable:!0,get:function(){return n(o).default}});var a=r(868);Object.defineProperty(e,"PictureDeclaration",{enumerable:!0,get:function(){return n(a).default}}),Object.defineProperty(e,"PictureType",{enumerable:!0,get:function(){return a.PictureType}}),Object.defineProperty(e,"Transparency",{enumerable:!0,get:function(){return a.Transparency}})},899:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.EventType=void 0;var r;e.default=function(){this.type=0,this.time=0,this.touchInfo=0,this.groundInfo=0},(r=e.EventType||(e.EventType={}))[r.Touch=0]="Touch",r[r.Ground=1]="Ground",r[r.Apple=4]="Apple",r[r.Turn=5]="Turn",r[r.VoltRight=6]="VoltRight",r[r.VoltLeft=7]="VoltLeft"},391:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Direction=void 0;var n,i=r(936);(n=e.Direction||(e.Direction={}))[n.Left=0]="Left",n[n.Right=1]="Right";var o=function(){function t(){this.bike=new i.Position(0,0),this.leftWheel=new i.Position(0,0),this.rightWheel=new i.Position(0,0),this.head=new i.Position(0,0),this.bikeRotation=0,this.leftWheelRotation=0,this.rightWheelRotation=0,this.backWheelSpeed=0,this.collisionStrength=0,this.throttleAndDirection=0}return Object.defineProperty(t.prototype,"throttle",{get:function(){return 0!=(1&this.throttleAndDirection)},set:function(t){this.throttleAndDirection=-2&this.throttleAndDirection|(t?1:0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return 2&this.throttleAndDirection},set:function(t){this.throttleAndDirection=-5&this.throttleAndDirection|t<<2},enumerable:!1,configurable:!0}),t}();e.default=o},917:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.ReplayFinishStateReason=void 0;var a,s=r(936),f=r(570),u=r(494),l=r(899),c=4796277;!function(t){t.Touch="Touch",t.NoTouch="NoTouch",t.FrameDifference="FrameDifference"}(a=e.ReplayFinishStateReason||(e.ReplayFinishStateReason={}));var h=function(){function t(){this.link=0,this.level="",this.isMulti=!1,this.isFlagTag=!1,this.rides=[],this.path=""}return t.from=function(t){return this.parseBuffer(Buffer.from(t))},t.parseBuffer=function(e){for(var r=new t,i=0;i<e.length;){var o=n(this.parseRide(e.slice(i)),2),a=o[0],s=o[1];Object.assign(r,a),r.rides.push(s),i+=44+27*s.frames.length+16*s.events.length}return r},t.parseRide=function(e){var r=new u.Ride,n=0,i=e.readUInt32LE(n);n+=8;var o=Boolean(e.readInt32LE(n));n+=4;var a=Boolean(e.readInt32LE(n));n+=4;var s=e.readUInt32LE(n);n+=4;var l=f.trimString(e.slice(n,n+12));n+=16;var h={isMulti:o,isFlagTag:a,link:s,level:l};r.frames=t.parseFrames(e.slice(n,n+27*i),i),n+=27*i;var p=e.readUInt32LE(n);if(n+=4,r.events=t.parseEvents(e.slice(n,n+16*p),p),n+=16*p,e.readInt32LE(n)!==c)throw new Error("End of replay marker mismatch");return[h,r]},t.parseFrames=function(t,e){for(var r=[],n=0;n<e;n++){var i=new u.Frame;i.bike=new s.Position(t.readFloatLE(4*n),t.readFloatLE(4*n+4*e)),i.leftWheel=new s.Position(t.readInt16LE(2*n+8*e),t.readInt16LE(2*n+10*e)),i.rightWheel=new s.Position(t.readInt16LE(2*n+12*e),t.readInt16LE(2*n+14*e)),i.head=new s.Position(t.readInt16LE(2*n+16*e),t.readInt16LE(2*n+18*e)),i.bikeRotation=t.readInt16LE(2*n+20*e),i.leftWheelRotation=t.readUInt8(n+22*e),i.rightWheelRotation=t.readUInt8(n+23*e),i.throttleAndDirection=t.readUInt8(n+24*e),i.backWheelSpeed=t.readUInt8(n+25*e),i.collisionStrength=t.readUInt8(n+26*e),r.push(i)}return r},t.parseEvents=function(t,e){for(var r=[],n=0,i=0;i<e;i++){var o=t.readDoubleLE(n);n+=8;var a=t.readInt16LE(n);n+=2;var s=t.readUInt8(n);n+=2;var f=t.readFloatLE(n);if(n+=4,s<0||s>7)throw new Error("Invalid event type value="+s+" at event offset="+n);r.push({time:o,touchInfo:a,type:s,groundInfo:f})}return r},t.prototype.toBuffer=function(){var t=this,e=this.rides.reduce((function(t,e){return t+(44+27*e.frames.length+16*e.events.length)}),0),r=Buffer.alloc(e),n=0;return this.rides.forEach((function(e){var i=e.frames.length;r.writeUInt32LE(i,n),r.writeUInt32LE(131,n+4),r.writeUInt32LE(t.isMulti?1:0,n+8),r.writeUInt32LE(t.isFlagTag?1:0,n+12),r.writeUInt32LE(t.link,n+16),r.write(f.nullpadString(t.level,12),n+20,12,"ascii"),r.writeUInt32LE(0,n+32),n+=36;for(var o=0;o<i;o++)r.writeFloatLE(e.frames[o].bike.x,n+4*o),r.writeFloatLE(e.frames[o].bike.y,n+4*o+4*i),r.writeInt16LE(e.frames[o].leftWheel.x,n+2*o+8*i),r.writeInt16LE(e.frames[o].leftWheel.y,n+2*o+10*i),r.writeInt16LE(e.frames[o].rightWheel.x,n+2*o+12*i),r.writeInt16LE(e.frames[o].rightWheel.y,n+2*o+14*i),r.writeInt16LE(e.frames[o].head.x,n+2*o+16*i),r.writeInt16LE(e.frames[o].head.y,n+2*o+18*i),r.writeInt16LE(e.frames[o].bikeRotation,n+2*o+20*i),r.writeUInt8(e.frames[o].leftWheelRotation,n+o+22*i),r.writeUInt8(e.frames[o].rightWheelRotation,n+o+23*i),r.writeUInt8(e.frames[o].throttleAndDirection,n+o+24*i),r.writeUInt8(e.frames[o].backWheelSpeed,n+o+25*i),r.writeUInt8(e.frames[o].collisionStrength,n+o+26*i);n+=27*i,r.writeUInt32LE(e.events.length,n),n+=4,e.events.forEach((function(t){switch(r.writeDoubleLE(t.time,n),n+=8,t.type){case l.EventType.Touch:r.writeInt16LE(t.touchInfo,n),r.writeUInt8(t.type,n+2),r.writeUInt8(0,n+3),r.writeFloatLE(0,n+4);break;case l.EventType.Ground:r.writeInt16LE(-1,n),r.writeUInt8(t.type,n+2),r.writeUInt8(0,n+3),r.writeFloatLE(t.groundInfo,n+4);break;default:r.writeInt16LE(-1,n),r.writeUInt8(t.type,n+2),r.writeUInt8(0,n+3),r.writeFloatLE(.99,n+4)}n+=8})),r.writeUInt32LE(c,n),n+=4})),r},t.prototype.getTime=function(){var t=this.rides.reduce((function(t,e){var r=t?t.time:0,n=e.events.length>0?e.events[e.events.length-1]:void 0;return(n?n.time:0)>r?n:t}),void 0),e=33.333*this.rides.reduce((function(t,e){return e.frames.length>t?e.frames.length:t}),0);if(t&&t.type!==l.EventType.Touch||!t)return{finished:!1,reason:a.NoTouch,time:Math.round(e)};var r=2.2893772893772897*t.time*1e3;return e>r+33.333?{finished:!1,reason:a.FrameDifference,time:Math.round(e)}:{finished:!0,reason:a.Touch,time:Math.floor(r)}},Object.defineProperty(t.prototype,"apples",{get:function(){var t,e,r=0,n=function(t){var e=t.events.filter((function(t){return 0===t.type})),n=t.events.filter((function(t){return 4===t.type})),o=i(new Set(e.map((function(t){return t.touchInfo})))).map((function(t,r){return e[r]}));n.forEach((function(t){var e=o.findIndex((function(e){return e.time===t.time}));e>-1&&(o.splice(e,1),r+=1)}))};try{for(var a=o(this.rides),s=a.next();!s.done;s=a.next())n(s.value)}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalApples",{get:function(){return this.rides.reduce((function(t,e){return t+e.events.filter((function(t){return 4===t.type})).length}),0)},enumerable:!1,configurable:!0}),t}();e.default=h},720:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(){this.frames=[],this.events=[]}},494:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ReplayFinishStateReason=e.Replay=e.Ride=e.Direction=e.Frame=e.EventType=e.Event=void 0;var i=r(899);Object.defineProperty(e,"Event",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(e,"EventType",{enumerable:!0,get:function(){return i.EventType}});var o=r(391);Object.defineProperty(e,"Frame",{enumerable:!0,get:function(){return n(o).default}}),Object.defineProperty(e,"Direction",{enumerable:!0,get:function(){return o.Direction}});var a=r(720);Object.defineProperty(e,"Ride",{enumerable:!0,get:function(){return n(a).default}});var s=r(917);Object.defineProperty(e,"Replay",{enumerable:!0,get:function(){return n(s).default}}),Object.defineProperty(e,"ReplayFinishStateReason",{enumerable:!0,get:function(){return s.ReplayFinishStateReason}})},936:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OBJECT_RADIUS=e.OBJECT_DIAMETER=e.HEAD_RADIUS=e.HEAD_DIAMETER=e.Clip=e.Position=void 0;var r;e.Position=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e},(r=e.Clip||(e.Clip={}))[r.Unclipped=0]="Unclipped",r[r.Ground=1]="Ground",r[r.Sky=2]="Sky",e.HEAD_DIAMETER=.476,e.HEAD_RADIUS=.238,e.OBJECT_DIAMETER=.8,e.OBJECT_RADIUS=.4},922:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(n(arguments[e]));return t},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.VideoDetail=e.SoundOptimization=e.PlayMode=void 0;var a,s,f,u=r(764),l=r(570),c=116,h=15,p=20,y=123432221;!function(t){t[t.Single=1]="Single",t[t.Multi=0]="Multi"}(a=e.PlayMode||(e.PlayMode={})),function(t){t[t.Compatibility=1]="Compatibility",t[t.BestQuality=0]="BestQuality"}(s=e.SoundOptimization||(e.SoundOptimization={})),function(t){t[t.Low=0]="Low",t[t.High=1]="High"}(f=e.VideoDetail||(e.VideoDetail={}));var d=function(){function t(){this.version=200,this.times=Array(90).fill({single:[],multi:[]}),this.players=[],this.playerAName="",this.playerBName="",this.playerAKeys={brake:208,changeDirection:57,rotateLeft:203,rotateRight:205,throttle:200,toggleNavigator:47,toggleShowHide:2,toggleTimer:20},this.playerBKeys={brake:80,changeDirection:82,rotateLeft:79,rotateRight:81,throttle:76,toggleNavigator:48,toggleShowHide:3,toggleTimer:21},this.soundEnabled=!0,this.soundOptimization=s.BestQuality,this.playMode=a.Single,this.flagTag=!1,this.swapBikes=!1,this.videoDetail=f.High,this.animatedObjects=!0,this.animatedMenus=!0,this.incScreenSizeKey=13,this.decScreenSizeKey=12,this.screenshotKey=23,this.lastEditedLevName="",this.lastPlayedExternal=""}return t.from=function(t){if(67910!==t.length)throw Error("Invalid state.dat file, expected buffer length of 67910, got "+t.length);return this.parseBuffer(t)},t.parseBuffer=function(e){var r=new t,n=this.cryptState(e),i=0;if(200!==n.readUInt32LE(i))throw Error("Invalid state.dat file");i+=4;for(var o=0;o<90;o++){var a=n.slice(i,i+688),s=l.bufferToTop10(a);r.times[o]=s,i+=688}var f=n.readUInt32LE(i+5800);if(f>50)throw Error("Expected max 50 player entries, got "+f);for(o=0;o<f;o++){var u=i+o*c,d=this.parsePlayer(n.slice(u,u+c));r.players.push(d)}i+=5804,r.playerAName=l.trimString(n.slice(i,i+h)),i+=h,r.playerBName=l.trimString(n.slice(i,i+h)),i+=h,r.soundEnabled=Boolean(n.readInt32LE(i)),i+=4,r.soundOptimization=n.readInt32LE(i),i+=4,r.playMode=n.readInt32LE(i),i+=4,r.flagTag=Boolean(n.readInt32LE(i)),i+=4,r.swapBikes=!Boolean(n.readInt32LE(i)),i+=4,r.videoDetail=n.readInt32LE(i),i+=4,r.animatedObjects=Boolean(n.readInt32LE(i)),i+=4,r.animatedMenus=Boolean(n.readInt32LE(i)),i+=4,r.playerAKeys=this.parsePlayerKeys(n.slice(i,i+32)),i+=32,r.playerBKeys=this.parsePlayerKeys(n.slice(i,i+32)),i+=32,r.incScreenSizeKey=n.readUInt32LE(i),i+=4,r.decScreenSizeKey=n.readUInt32LE(i),i+=4,r.screenshotKey=n.readUInt32LE(i),i+=4,r.lastEditedLevName=l.trimString(n.slice(i,i+p)),i+=p,r.lastPlayedExternal=l.trimString(n.slice(i,i+p)),i+=p;var g=n.readUInt32LE(i);if(g!==y&&123432112!==g)throw Error("Expected EOF marker, got "+g);return r},t.parsePlayer=function(t){if(t.length!==c)throw Error("Expected buffer of length 116, got "+t.length);return{name:l.trimString(t.slice(0,16)),skippedInternals:i(t.slice(16,70)).map(Boolean),lastInternal:t.readUInt32LE(108),selectedInternal:t.readUInt32LE(112)}},t.parsePlayerKeys=function(t){if(32!==t.length)throw Error("Expected buffer of length 32, got "+t.length);var e=0,r=t.readUInt32LE(e);e+=4;var n=t.readUInt32LE(e);e+=4;var i=t.readUInt32LE(e);e+=4;var o=t.readUInt32LE(e);e+=4;var a=t.readUInt32LE(e);e+=4;var s=t.readUInt32LE(e);e+=4;var f=t.readUInt32LE(e);return e+=4,{throttle:r,brake:n,rotateRight:i,rotateLeft:o,changeDirection:a,toggleNavigator:s,toggleTimer:f,toggleShowHide:t.readUInt32LE(e)}},t.cryptState=function(t){var e,r,n=u.Buffer.from(t),i=[4,61920,5800,4,h,h,4,4,4,4,4,4,4,4,32,32,4,4,4,p,p],a=0;try{for(var s=o(i),f=s.next();!f.done;f=s.next()){var l=f.value;this.cryptStatePiece(n.slice(a,a+l)).copy(n,a),a+=l}}catch(t){e={error:t}}finally{try{f&&!f.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.cryptStatePiece=function(t){for(var e=u.Buffer.from(t),r=23,n=9782,i=0;i<t.length;i++)e[i]^=255&r,r=(65535&(r=31*(n+=r%3391*3391)+3391))-2*(32768&r);return e},t.prototype.toBuffer=function(){var e,r,n,i,a=u.Buffer.alloc(67910),s=0;a.writeUInt32LE(200),s+=4;try{for(var f=o(this.times.slice(0,90)),d=f.next();!d.done;d=f.next()){var g=d.value;l.top10ToBuffer(g).copy(a,s),s+=688}}catch(t){e={error:t}}finally{try{d&&!d.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}s=61924;try{for(var v=o(this.players.slice(0,50)),w=v.next();!w.done;w=v.next()){var E=w.value,m=l.nullpadString(E.name,16);a.write(m,s,16,"ascii"),s+=16;var b=E.skippedInternals.slice(0,54);b.forEach((function(t){a.writeUInt8(t?1:0,s),s+=1})),b.length<54&&(s+=54-b.length),s+=38,a.writeInt32LE(E.lastInternal,s),s+=4,a.writeInt32LE(E.selectedInternal,s),s+=4}}catch(t){n={error:t}}finally{try{w&&!w.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}return this.players.length<50&&(a.fill(0,s,s+c*(50-this.players.length)),s+=c*(50-this.players.length)),a.writeUInt32LE(this.players.length,s),s+=4,a.write(l.nullpadString(this.playerAName,h),s,h,"ascii"),s+=h,a.write(l.nullpadString(this.playerBName,h),s,h,"ascii"),s+=h,a.writeInt32LE(this.soundEnabled?1:0,s),s+=4,a.writeInt32LE(this.soundOptimization,s),s+=4,a.writeInt32LE(this.playMode,s),s+=4,a.writeInt32LE(this.flagTag?1:0,s),s+=4,a.writeInt32LE(this.swapBikes?0:1,s),s+=4,a.writeInt32LE(this.videoDetail,s),s+=4,a.writeInt32LE(this.animatedObjects?1:0,s),s+=4,a.writeInt32LE(this.animatedMenus?1:0,s),s+=4,[this.playerAKeys,this.playerBKeys].forEach((function(t){a.writeUInt32LE(t.throttle,s),s+=4,a.writeUInt32LE(t.brake,s),s+=4,a.writeUInt32LE(t.rotateRight,s),s+=4,a.writeUInt32LE(t.rotateLeft,s),s+=4,a.writeUInt32LE(t.changeDirection,s),s+=4,a.writeUInt32LE(t.toggleNavigator,s),s+=4,a.writeUInt32LE(t.toggleTimer,s),s+=4,a.writeUInt32LE(t.toggleShowHide,s),s+=4})),a.writeUInt32LE(this.incScreenSizeKey,s),s+=4,a.writeUInt32LE(this.decScreenSizeKey,s),s+=4,a.writeUInt32LE(this.screenshotKey,s),s+=4,a.write(l.nullpadString(this.lastEditedLevName,p),s,p,"ascii"),s+=p,a.write(l.nullpadString(this.lastPlayedExternal,p),s,p,"ascii"),s+=p,a.writeUInt32LE(y,s),t.cryptState(a)},t}();e.default=d},367:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SoundOptimization=e.VideoDetail=e.PlayMode=e.State=void 0;var i=r(922);Object.defineProperty(e,"State",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(e,"PlayMode",{enumerable:!0,get:function(){return i.PlayMode}}),Object.defineProperty(e,"VideoDetail",{enumerable:!0,get:function(){return i.VideoDetail}}),Object.defineProperty(e,"SoundOptimization",{enumerable:!0,get:function(){return i.SoundOptimization}})},570:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.bufferToTop10=e.bufferToTop10Part=e.top10ToBuffer=e.trimString=e.nullpadString=e.formatTime=void 0;var n=r(764);function i(t,e){if(!/^[\x00-\x7F]*$/.test(t))throw new Error("String contains non-ASCII values");return t.length>e?t.slice(0,e):t.padEnd(e,"\0")}function o(t){var e=n.Buffer.from(t),r=e.indexOf("\0");return e.toString("ascii",0,-1!==r?r:void 0)}function a(t){var e=n.Buffer.from(t);if(344!==e.length)throw Error("Top10 buffer length expected to be 344, got "+e.length);for(var r=e.readInt32LE(0),i=[],a=0;a<r;a++){var s=4+4*a,f=44+15*a,u=f+15,l=194+15*a,c=l+15,h=e.readInt32LE(s),p=o(e.slice(f,u)),y=o(e.slice(l,c));i.push({time:h,name1:p,name2:y})}return i}e.formatTime=function(t){var e=Math.trunc(t%100),r=Math.trunc(t/100%60),n=Math.trunc(t/6e3%60),i=Math.trunc(t/36e4);return(i?i+":":"")+n.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+","+e.toString().padStart(2,"0")},e.nullpadString=i,e.trimString=o,e.top10ToBuffer=function(t){var e=Object.values(t).map((function(t){t.sort((function(t,e){return t.time>e.time?1:t.time<e.time?-1:0}));var e=n.Buffer.alloc(344);e.writeUInt32LE(t.length>=10?10:t.length,0);for(var r=0;r<t.length;r++)r<10&&(e.writeUInt32LE(t[r].time,4+4*r),e.write(i(t[r].name1,15),44+15*r),e.write(i(t[r].name2,15),194+15*r));return e}));return n.Buffer.concat(e,688)},e.bufferToTop10Part=a,e.bufferToTop10=function(t){var e=n.Buffer.from(t);if(688!==e.length)throw Error("Top10 buffer length expected to be 688, got "+e.length);return{single:a(e.slice(0,344)),multi:a(e.slice(344))}}}},e={},function r(n){if(e[n])return e[n].exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(341);var t,e}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("ElmaJS",[],e):"object"==typeof exports?exports.ElmaJS=e():t.ElmaJS=e()}(self,(function(){return t={742:(t,e)=>{"use strict";e.byteLength=function(t){var e=f(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=f(t),a=o[0],s=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),l=0,c=s>0?a-4:a;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,f=n-i;s<f;s+=a)o.push(u(t,s,s+a>f?f:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a<s;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(t,e,r)=>{"use strict";const n=r(742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=function(t){return+t!=t&&(t=0),f.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=s(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);const i=function(t){if(f.isBuffer(t)){const e=0|y(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return l(t),s(t<0?0:0|y(t))}function h(t){const e=t.length<0?0:0|y(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function y(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function d(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(i)return n?-1:W(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,i){let o,a=1,s=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,f/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===f)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+f>s&&(r=s-f),o=r;o>=0;o--){let r=!0;for(let n=0;n<f;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function m(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(q(n))return a;t[r+a]=n}return a}function b(t,e,r,n){return J(W(e,t.length-r),t,r,n)}function I(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function L(t,e,r,n){return J(H(e),t,r,n)}function B(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,f;switch(a){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(f=(31&e)<<6|63&r,f>127&&(o=f));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(f=(15&e)<<12|(63&r)<<6|63&n,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(f=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,f>65535&&f<1114112&&(o=f))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=T));return r}(n)}e.kMaxLength=a,f.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),f.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}}),f.poolSize=8192,f.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,Uint8Array),f.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},f.allocUnsafe=function(t){return c(t)},f.allocUnsafeSlow=function(t){return c(t)},f.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==f.prototype},f.compare=function(t,e){if(Y(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),Y(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(t)||!f.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=f.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Y(e,Uint8Array))i+e.length>n.length?(f.isBuffer(e)||(e=f.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!f.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},f.byteLength=d,f.prototype._isBuffer=!0,f.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)v(this,e,e+1);return this},f.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},f.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},f.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):g.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(f.prototype[o]=f.prototype.inspect),f.prototype.compare=function(t,e,r,n,i){if(Y(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),u=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<s;++t)if(u[t]!==l[t]){o=u[t],a=l[t];break}return o<a?-1:a<o?1:0},f.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},f.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},f.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},f.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return I(this,t,e,r);case"base64":return L(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function P(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function A(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Q[t[n]];return i}function _(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function D(t,e,r,n,i){z(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function M(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,o){return e=+e,r>>>=0,o||M(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,o){return e=+e,r>>>=0,o||M(t,0,r,8),i.write(t,e,r,n,52,8),r+8}f.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,f.prototype),n},f.prototype.readUintLE=f.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUintBE=f.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},f.prototype.readUint8=f.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readBigUInt64LE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),f.prototype.readBigUInt64BE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),f.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},f.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readBigInt64LE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),f.prototype.readBigInt64BE=X((function(t){G(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),f.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigUInt64LE=X((function(t,e=0){return j(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),f.prototype.writeBigUInt64BE=X((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);x(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o>>0)-a&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigInt64LE=X((function(t,e=0){return j(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),f.prototype.writeBigInt64BE=X((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),f.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},f.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},f.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},f.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},f.prototype.copy=function(t,e,r,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},f.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=f.isBuffer(t)?t:f.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const C={};function F(t,e,r){C[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function z(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new C.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,o)}function G(t,e){if("number"!=typeof t)throw new C.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw G(t,r),new C.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new C.ERR_BUFFER_OUT_OF_BOUNDS;throw new C.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=$(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function W(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const Q=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function X(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},645:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,f=(1<<s)-1,u=f>>1,l=-7,c=r?i-1:0,h=r?-1:1,p=t[e+c];for(c+=h,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+t[e+c],c+=h,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=n;l>0;a=256*a+t[e+c],c+=h,l-=8);if(0===o)o=1-u;else{if(o===f)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=u}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,f,u=8*o-i-1,l=(1<<u)-1,c=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-a))<1&&(a--,f*=2),(e+=a+c>=1?h/f:h*Math.pow(2,1-c))*f>=2&&(a++,f/=2),a+c>=l?(s=0,a=l):a+c>=1?(s=(e*f-1)*Math.pow(2,i),a+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=y,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+p]=255&a,p+=y,a/=256,u-=8);t[r+p-y]|=128*d}},341:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(436),e),i(r(494),e),i(r(936),e),i(r(570),e),i(r(469),e),i(r(367),e)},951:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Gravity=e.ObjectType=void 0;var n,i,o=r(936);!function(t){t[t.Exit=1]="Exit",t[t.Apple=2]="Apple",t[t.Killer=3]="Killer",t[t.Start=4]="Start"}(n=e.ObjectType||(e.ObjectType={})),function(t){t[t.None=0]="None",t[t.Up=1]="Up",t[t.Down=2]="Down",t[t.Left=3]="Left",t[t.Right=4]="Right"}(i=e.Gravity||(e.Gravity={}));e.default=function(){this.position=new o.Position,this.type=n.Apple,this.gravity=i.None,this.animation=1}},88:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.Version=void 0;var o,a=r(764),s=r(341),f=6754362,u=8674642;!function(t){t[t.Across=0]="Across",t[t.Elma=1]="Elma"}(o=e.Version||(e.Version={}));var l=function(){function t(){this.version=o.Elma,this.link=0,this.integrity=[0,0,0,0],this.lgr="default",this.name="Unnamed level",this.ground="ground",this.sky="sky",this.polygons=[{grass:!1,vertices:[new s.Position(10,0),new s.Position(10,7),new s.Position(0,7),new s.Position(0,0)]}],this.objects=[{animation:1,gravity:s.Gravity.None,position:new s.Position(2,0+s.OBJECT_RADIUS),type:s.ObjectType.Start},{animation:1,gravity:s.Gravity.None,position:new s.Position(8,0+s.OBJECT_RADIUS),type:s.ObjectType.Exit}],this.pictures=[],this.top10={multi:[],single:[]}}return t.from=function(t){return this.parseBuffer(a.Buffer.from(t))},t.cryptTop10=function(t){for(var e=a.Buffer.from(t),r=21,n=9783,i=0;i<688;i++)e[i]^=255&r,r=(65535&(r=31*(n+=r%3389*3389)+3389))-2*(32768&r);return e},t.parseBuffer=function(e){var r=new t;r.polygons=[],r.objects=[];var i=0;switch(e.toString("ascii",0,5)){case"POT06":throw r.version=o.Across,new Error("Across levels are not supported");case"POT14":r.version=o.Elma;break;default:throw new Error("Not valid Elma level")}i+=7,r.link=e.readUInt32LE(i),i+=4;for(var a=0;a<4;a++)r.integrity[a]=e.readDoubleLE(i),i+=8;r.name=s.trimString(e.slice(i,i+51)),i+=51,r.lgr=s.trimString(e.slice(i,i+16)),i+=16,r.ground=s.trimString(e.slice(i,i+10)),i+=10,r.sky=s.trimString(e.slice(i,i+10)),i+=10;var l=e.readDoubleLE(i)-.4643643;i+=8;var c=n(this.parsePolygons(e,i,l),2),h=c[0],p=c[1];r.polygons=h,i=p;var y=e.readDoubleLE(i)-.4643643;i+=8,r.objects=this.parseObjects(e,i,y),i+=28*y;var d=e.readDoubleLE(i)-.2345672;if(i+=8,r.pictures=this.parsePictures(e,i,d),i+=54*d,e.readInt32LE(i)!==f)throw new Error("End of data marker mismatch");i+=4;var g=t.cryptTop10(e.slice(i,i+688));if(r.top10=s.bufferToTop10(g),i+=688,e.readInt32LE(i)!==u)throw new Error("End of file marker mismatch");return r},t.parsePolygons=function(t,e,r){for(var n=[],i=0;i<r;i++){var o=new s.Polygon;o.grass=Boolean(t.readInt32LE(e)),e+=4;var a=t.readInt32LE(e);e+=4;for(var f=0;f<a;f++){var u=t.readDoubleLE(e);e+=8;var l=t.readDoubleLE(e);e+=8,o.vertices.push(new s.Position(u,l))}n.push(o)}return[n,e]},t.parseObjects=function(t,e,r){for(var n=[],i=0;i<r;i++){var o=new s.ElmaObject;if(o.position.x=t.readDoubleLE(e),e+=8,o.position.y=t.readDoubleLE(e),e+=8,o.type=t.readInt32LE(e),o.type<1||o.type>4)throw new Error("Invalid object type value="+o.type+" at offset="+e);if(e+=4,o.gravity=t.readInt32LE(e),o.gravity<0||o.gravity>4)throw new Error("Invalid gravity value="+o.gravity+" at offset="+e);e+=4,o.animation=t.readInt32LE(e)+1,e+=4,n.push(o)}return n},t.parsePictures=function(t,e,r){for(var n=[],i=0;i<r;i++){var o=new s.Picture;if(o.name=s.trimString(t.slice(e,e+10)),e+=10,o.texture=s.trimString(t.slice(e,e+10)),e+=10,o.mask=s.trimString(t.slice(e,e+10)),e+=10,o.position.x=t.readDoubleLE(e),e+=8,o.position.y=t.readDoubleLE(e),e+=8,o.distance=t.readInt32LE(e),e+=4,o.clip=t.readInt32LE(e),o.clip<0||o.clip>2)throw new Error("Invalid clip value="+o.clip+" at offset="+e);e+=4,n.push(o)}return n},t.prototype.toBuffer=function(){var e,r,n,l,c,h,p,y,d,g,v=this.calculateIntegrity(),w=850;try{for(var E=i(this.polygons),m=E.next();!m.done;m=E.next())w+=8+16*(A=m.value).vertices.length}catch(t){e={error:t}}finally{try{m&&!m.done&&(r=E.return)&&r.call(E)}finally{if(e)throw e.error}}w+=28*this.objects.length+54*this.pictures.length;var b=a.Buffer.alloc(w);if(this.version!==o.Elma)throw new Error("Only Elma levels are supported");b.write("POT14",0,5,"ascii"),b.writeUInt16LE(65535&this.link,5),b.writeUInt32LE(this.link,7);for(var I=0;I<v.length;I++)b.writeDoubleLE(v[I],11+8*I);var L=s.nullpadString(this.name,51);b.write(L,43,51,"ascii");var B=s.nullpadString(this.lgr,16);b.write(B,94,16,"ascii");var S=s.nullpadString(this.ground,10);b.write(S,110,10,"ascii");var U=s.nullpadString(this.sky,10);b.write(U,120,10,"ascii"),b.writeDoubleLE(this.polygons.length+.4643643,130);var T=138;try{for(var O=i(this.polygons),P=O.next();!P.done;P=O.next()){var A=P.value;b.writeInt32LE(A.grass?1:0,T),T+=4,b.writeInt32LE(A.vertices.length,T),T+=4;try{for(var _=(c=void 0,i(A.vertices)),R=_.next();!R.done;R=_.next()){var x=R.value;b.writeDoubleLE(x.x,T),T+=8,b.writeDoubleLE(x.y,T),T+=8}}catch(t){c={error:t}}finally{try{R&&!R.done&&(h=_.return)&&h.call(_)}finally{if(c)throw c.error}}}}catch(t){n={error:t}}finally{try{P&&!P.done&&(l=O.return)&&l.call(O)}finally{if(n)throw n.error}}b.writeDoubleLE(this.objects.length+.4643643,T),T+=8;try{for(var j=i(this.objects),D=j.next();!D.done;D=j.next()){var M=D.value;b.writeDoubleLE(M.position.x,T),T+=8,b.writeDoubleLE(M.position.y,T),T+=8,b.writeInt32LE(M.type,T),T+=4,b.writeInt32LE(M.gravity,T),T+=4,b.writeInt32LE(M.animation-1,T),T+=4}}catch(t){p={error:t}}finally{try{D&&!D.done&&(y=j.return)&&y.call(j)}finally{if(p)throw p.error}}b.writeDoubleLE(this.pictures.length+.2345672,T),T+=8;try{for(var k=i(this.pictures),N=k.next();!N.done;N=k.next()){var C=N.value,F=s.nullpadString(C.name,10);b.write(F,T,10,"ascii"),T+=10;var $=s.nullpadString(C.texture,10);b.write($,T,10,"ascii"),T+=10;var z=s.nullpadString(C.mask,10);b.write(z,T,10,"ascii"),T+=10,b.writeDoubleLE(C.position.x,T),T+=8,b.writeDoubleLE(C.position.y,T),T+=8,b.writeInt32LE(C.distance,T),T+=4,b.writeInt32LE(C.clip,T),T+=4}}catch(t){d={error:t}}finally{try{N&&!N.done&&(g=k.return)&&g.call(k)}finally{if(d)throw d.error}}b.writeInt32LE(f,T),T+=4;var G=s.top10ToBuffer(this.top10);return t.cryptTop10(G).copy(b,T),T+=688,b.writeInt32LE(u,T),b},t.prototype.calculateIntegrity=function(){var t,e,r,n,o,a,f,u,l=0;try{for(var c=i(this.polygons),h=c.next();!h.done;h=c.next()){var p=h.value;try{for(var y=(r=void 0,i(p.vertices)),d=y.next();!d.done;d=y.next()){var g=d.value;l+=g.x+g.y}}catch(t){r={error:t}}finally{try{d&&!d.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}var v=0;try{for(var w=i(this.objects),E=w.next();!E.done;E=w.next()){var m=E.value,b=0;m.type===s.ObjectType.Exit?b=1:m.type===s.ObjectType.Apple?b=2:m.type===s.ObjectType.Killer?b=3:m.type===s.ObjectType.Start&&(b=4),v+=m.position.x+m.position.y+b}}catch(t){o={error:t}}finally{try{E&&!E.done&&(a=w.return)&&a.call(w)}finally{if(o)throw o.error}}var I=0;try{for(var L=i(this.pictures),B=L.next();!B.done;B=L.next()){var S=B.value;I+=S.position.x+S.position.y}}catch(t){f={error:t}}finally{try{B&&!B.done&&(u=L.return)&&u.call(L)}finally{if(f)throw f.error}}var U=3247.764325643*(l+v+I);return[U,this.getRandomInt(0,5871)+11877-U,this.getRandomInt(0,5871)+11877-U,this.getRandomInt(0,6102)+12112-U]},t.prototype.getRandomInt=function(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t))+t},t}();e.default=l},85:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(936);e.default=function(){this.name="barrel",this.texture="",this.mask="",this.position=new n.Position(0,0),this.distance=600,this.clip=n.Clip.Sky,this.grass=!1,this.vertices=[]}},595:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(){this.grass=!1,this.vertices=[]}},436:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Version=e.Level=e.Polygon=e.Picture=e.ObjectType=e.Gravity=e.ElmaObject=void 0;var i=r(951);Object.defineProperty(e,"ElmaObject",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(e,"Gravity",{enumerable:!0,get:function(){return i.Gravity}}),Object.defineProperty(e,"ObjectType",{enumerable:!0,get:function(){return i.ObjectType}});var o=r(85);Object.defineProperty(e,"Picture",{enumerable:!0,get:function(){return n(o).default}});var a=r(595);Object.defineProperty(e,"Polygon",{enumerable:!0,get:function(){return n(a).default}});var s=r(88);Object.defineProperty(e,"Level",{enumerable:!0,get:function(){return n(s).default}}),Object.defineProperty(e,"Version",{enumerable:!0,get:function(){return s.Version}})},599:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a};Object.defineProperty(e,"__esModule",{value:!0});var i=r(764),o=r(341),a=r(570),s=187565543,f=function(){function t(){this.pictureList=[],this.pictureData=[],this.path=""}return t.from=function(t){return this.parseBuffer(i.Buffer.from(t))},t.parseBuffer=function(e){var r=new t,i=e.toString("ascii",0,5);if("LGR12"!==i)throw new Error("Invalid LGR version: "+i);var o=e.readInt32LE(5),a=e.readInt32LE(9);if(1002!==a)throw new Error("Invalid header: "+a);var f=e.readInt32LE(13);r.pictureList=r.parseListData(e.slice(17,17+26*f),f);var u=n(r.parsePictureData(e.slice(17+26*f),o),2),l=u[0],c=u[1];if(r.pictureData=l,e.readInt32LE(17+26*f+c)!==s)throw new Error("EOF marker expected at byte: "+(17+26*f+c));return r},t.prototype.toBuffer=function(){var t=this.pictureList.length,e=this.pictureData.reduce((function(t,e){return t+e.data.length+24}),21+26*t),r=i.Buffer.alloc(e),n=0;return r.write("LGR12",n,5,"ascii"),n+=5,r.writeUInt32LE(this.pictureData.length,n),n+=4,r.writeInt32LE(1002,n),n+=4,r.writeUInt32LE(t,n),n+=4,this.pictureList.forEach((function(e,i){r.write(a.nullpadString(e.name,10),n+10*i,10,"ascii"),r.writeUInt32LE(e.pictureType,n+10*t+4*i),r.writeUInt32LE(e.distance,n+14*t+4*i),r.writeUInt32LE(e.clipping,n+18*t+4*i),r.writeUInt32LE(e.transparency,n+22*t+4*i)})),n+=26*t,this.pictureData.forEach((function(t){r.write(a.nullpadString(t.name,20),n,20,"ascii"),n+=20,r.writeUInt32LE(t.data.length,n),n+=4,n+=t.data.copy(r,n)})),r.writeInt32LE(s,n),r},t.prototype.parseListData=function(t,e){var r=[],n=0,i=t.slice(n,n+10*e);n+=10*e;var s=t.slice(n,n+4*e);n+=4*e;var f=t.slice(n,n+4*e);n+=4*e;var u=t.slice(n,n+4*e);n+=4*e;for(var l=t.slice(n,n+4*e),c=0;c<e;c++){var h=new o.PictureDeclaration;h.name=a.trimString(i.slice(10*c,10*c+10)),h.pictureType=s.readInt32LE(4*c),h.distance=f.readInt32LE(4*c),h.clipping=u.readInt32LE(4*c),h.transparency=l.readInt32LE(4*c),r.push(h)}return r},t.prototype.parsePictureData=function(t,e){for(var r=[],n=0,i=0;i<e;i++){var s=a.trimString(t.slice(n,n+12));n+=20;var f=t.readUInt32LE(n);n+=4;var u=t.slice(n,n+f);r.push(new o.PictureData(s,u)),n+=f}return[r,n]},t}();e.default=f},59:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(t,e){this.name=t,this.data=e}},868:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Transparency=e.PictureType=void 0;var n,i,o=r(936);!function(t){t[t.Normal=100]="Normal",t[t.Texture=101]="Texture",t[t.Mask=102]="Mask"}(n=e.PictureType||(e.PictureType={})),function(t){t[t.Solid=10]="Solid",t[t.Palette=11]="Palette",t[t.TopLeft=12]="TopLeft",t[t.TopRight=13]="TopRight",t[t.BottomLeft=14]="BottomLeft",t[t.BottomRight=15]="BottomRight"}(i=e.Transparency||(e.Transparency={}));e.default=function(){this.name="",this.pictureType=n.Normal,this.distance=450,this.clipping=o.Clip.Sky,this.transparency=i.TopLeft}},469:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Transparency=e.PictureType=e.PictureDeclaration=e.PictureData=e.LGR=void 0;var i=r(599);Object.defineProperty(e,"LGR",{enumerable:!0,get:function(){return n(i).default}});var o=r(59);Object.defineProperty(e,"PictureData",{enumerable:!0,get:function(){return n(o).default}});var a=r(868);Object.defineProperty(e,"PictureDeclaration",{enumerable:!0,get:function(){return n(a).default}}),Object.defineProperty(e,"PictureType",{enumerable:!0,get:function(){return a.PictureType}}),Object.defineProperty(e,"Transparency",{enumerable:!0,get:function(){return a.Transparency}})},899:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.EventType=void 0;var r;e.default=function(){this.type=0,this.time=0,this.touchInfo=0,this.groundInfo=0},(r=e.EventType||(e.EventType={}))[r.Touch=0]="Touch",r[r.Ground=1]="Ground",r[r.Apple=4]="Apple",r[r.Turn=5]="Turn",r[r.VoltRight=6]="VoltRight",r[r.VoltLeft=7]="VoltLeft"},391:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Direction=void 0;var n,i=r(936);(n=e.Direction||(e.Direction={}))[n.Left=0]="Left",n[n.Right=1]="Right";var o=function(){function t(){this.bike=new i.Position(0,0),this.leftWheel=new i.Position(0,0),this.rightWheel=new i.Position(0,0),this.head=new i.Position(0,0),this.bikeRotation=0,this.leftWheelRotation=0,this.rightWheelRotation=0,this.backWheelSpeed=0,this.collisionStrength=0,this.throttleAndDirection=0}return Object.defineProperty(t.prototype,"throttle",{get:function(){return 0!=(1&this.throttleAndDirection)},set:function(t){this.throttleAndDirection=-2&this.throttleAndDirection|(t?1:0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return 2&this.throttleAndDirection},set:function(t){this.throttleAndDirection=-5&this.throttleAndDirection|t<<2},enumerable:!1,configurable:!0}),t}();e.default=o},917:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__spreadArray||function(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.ReplayFinishStateReason=void 0;var a,s=r(936),f=r(570),u=r(494),l=r(899),c=4796277;!function(t){t.Touch="Touch",t.NoTouch="NoTouch",t.FrameDifference="FrameDifference"}(a=e.ReplayFinishStateReason||(e.ReplayFinishStateReason={}));var h=function(){function t(){this.link=0,this.level="",this.isMulti=!1,this.isFlagTag=!1,this.rides=[],this.path=""}return t.from=function(t){return this.parseBuffer(Buffer.from(t))},t.parseBuffer=function(e){for(var r=new t,i=0;i<e.length;){var o=n(this.parseRide(e.slice(i)),2),a=o[0],s=o[1];Object.assign(r,a),r.rides.push(s),i+=44+27*s.frames.length+16*s.events.length}return r},t.parseRide=function(e){var r=new u.Ride,n=0,i=e.readUInt32LE(n);n+=8;var o=Boolean(e.readInt32LE(n));n+=4;var a=Boolean(e.readInt32LE(n));n+=4;var s=e.readUInt32LE(n);n+=4;var l=f.trimString(e.slice(n,n+12));n+=16;var h={isMulti:o,isFlagTag:a,link:s,level:l};r.frames=t.parseFrames(e.slice(n,n+27*i),i),n+=27*i;var p=e.readUInt32LE(n);if(n+=4,r.events=t.parseEvents(e.slice(n,n+16*p),p),n+=16*p,e.readInt32LE(n)!==c)throw new Error("End of replay marker mismatch");return[h,r]},t.parseFrames=function(t,e){for(var r=[],n=0;n<e;n++){var i=new u.Frame;i.bike=new s.Position(t.readFloatLE(4*n),t.readFloatLE(4*n+4*e)),i.leftWheel=new s.Position(t.readInt16LE(2*n+8*e),t.readInt16LE(2*n+10*e)),i.rightWheel=new s.Position(t.readInt16LE(2*n+12*e),t.readInt16LE(2*n+14*e)),i.head=new s.Position(t.readInt16LE(2*n+16*e),t.readInt16LE(2*n+18*e)),i.bikeRotation=t.readInt16LE(2*n+20*e),i.leftWheelRotation=t.readUInt8(n+22*e),i.rightWheelRotation=t.readUInt8(n+23*e),i.throttleAndDirection=t.readUInt8(n+24*e),i.backWheelSpeed=t.readUInt8(n+25*e),i.collisionStrength=t.readUInt8(n+26*e),r.push(i)}return r},t.parseEvents=function(t,e){for(var r=[],n=0,i=0;i<e;i++){var o=t.readDoubleLE(n);n+=8;var a=t.readInt16LE(n);n+=2;var s=t.readUInt8(n);n+=2;var f=t.readFloatLE(n);if(n+=4,s<0||s>7)throw new Error("Invalid event type value="+s+" at event offset="+n);r.push({time:o,touchInfo:a,type:s,groundInfo:f})}return r},t.prototype.toBuffer=function(){var t=this,e=this.rides.reduce((function(t,e){return t+(44+27*e.frames.length+16*e.events.length)}),0),r=Buffer.alloc(e),n=0;return this.rides.forEach((function(e){var i=e.frames.length;r.writeUInt32LE(i,n),r.writeUInt32LE(131,n+4),r.writeUInt32LE(t.isMulti?1:0,n+8),r.writeUInt32LE(t.isFlagTag?1:0,n+12),r.writeUInt32LE(t.link,n+16),r.write(f.nullpadString(t.level,12),n+20,12,"ascii"),r.writeUInt32LE(0,n+32),n+=36;for(var o=0;o<i;o++)r.writeFloatLE(e.frames[o].bike.x,n+4*o),r.writeFloatLE(e.frames[o].bike.y,n+4*o+4*i),r.writeInt16LE(e.frames[o].leftWheel.x,n+2*o+8*i),r.writeInt16LE(e.frames[o].leftWheel.y,n+2*o+10*i),r.writeInt16LE(e.frames[o].rightWheel.x,n+2*o+12*i),r.writeInt16LE(e.frames[o].rightWheel.y,n+2*o+14*i),r.writeInt16LE(e.frames[o].head.x,n+2*o+16*i),r.writeInt16LE(e.frames[o].head.y,n+2*o+18*i),r.writeInt16LE(e.frames[o].bikeRotation,n+2*o+20*i),r.writeUInt8(e.frames[o].leftWheelRotation,n+o+22*i),r.writeUInt8(e.frames[o].rightWheelRotation,n+o+23*i),r.writeUInt8(e.frames[o].throttleAndDirection,n+o+24*i),r.writeUInt8(e.frames[o].backWheelSpeed,n+o+25*i),r.writeUInt8(e.frames[o].collisionStrength,n+o+26*i);n+=27*i,r.writeUInt32LE(e.events.length,n),n+=4,e.events.forEach((function(t){switch(r.writeDoubleLE(t.time,n),n+=8,t.type){case l.EventType.Touch:r.writeInt16LE(t.touchInfo,n),r.writeUInt8(t.type,n+2),r.writeUInt8(0,n+3),r.writeFloatLE(0,n+4);break;case l.EventType.Ground:r.writeInt16LE(-1,n),r.writeUInt8(t.type,n+2),r.writeUInt8(0,n+3),r.writeFloatLE(t.groundInfo,n+4);break;default:r.writeInt16LE(-1,n),r.writeUInt8(t.type,n+2),r.writeUInt8(0,n+3),r.writeFloatLE(.99,n+4)}n+=8})),r.writeUInt32LE(c,n),n+=4})),r},t.prototype.getTime=function(){var t=this.rides.reduce((function(t,e){var r=t?t.time:0,n=e.events.length>0?e.events[e.events.length-1]:void 0;return(n?n.time:0)>r?n:t}),void 0),e=33.333*this.rides.reduce((function(t,e){return e.frames.length>t?e.frames.length:t}),0);if(t&&t.type!==l.EventType.Touch||!t)return{finished:!1,reason:a.NoTouch,time:Math.round(e)};var r=2.2893772893772897*t.time*1e3;return e>r+33.333?{finished:!1,reason:a.FrameDifference,time:Math.round(e)}:{finished:!0,reason:a.Touch,time:Math.floor(r)}},Object.defineProperty(t.prototype,"apples",{get:function(){var t,e,r=0,a=function(t){var e=t.events.filter((function(t){return 0===t.type})).sort((function(t,e){return e.time-t.time})),o=t.events.filter((function(t){return 4===t.type})),a=i([],n(new Set(e.map((function(t){return t.touchInfo}))))).map((function(t,r){return e[r]}));o.forEach((function(t){var e=a.findIndex((function(e){return e.time===t.time}));e>-1&&(a.splice(e,1),r+=1)}))};try{for(var s=o(this.rides),f=s.next();!f.done;f=s.next())a(f.value)}catch(e){t={error:e}}finally{try{f&&!f.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalApples",{get:function(){return this.rides.reduce((function(t,e){return t+e.events.filter((function(t){return 4===t.type})).length}),0)},enumerable:!1,configurable:!0}),t}();e.default=h},720:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(){this.frames=[],this.events=[]}},494:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.ReplayFinishStateReason=e.Replay=e.Ride=e.Direction=e.Frame=e.EventType=e.Event=void 0;var i=r(899);Object.defineProperty(e,"Event",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(e,"EventType",{enumerable:!0,get:function(){return i.EventType}});var o=r(391);Object.defineProperty(e,"Frame",{enumerable:!0,get:function(){return n(o).default}}),Object.defineProperty(e,"Direction",{enumerable:!0,get:function(){return o.Direction}});var a=r(720);Object.defineProperty(e,"Ride",{enumerable:!0,get:function(){return n(a).default}});var s=r(917);Object.defineProperty(e,"Replay",{enumerable:!0,get:function(){return n(s).default}}),Object.defineProperty(e,"ReplayFinishStateReason",{enumerable:!0,get:function(){return s.ReplayFinishStateReason}})},936:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OBJECT_RADIUS=e.OBJECT_DIAMETER=e.HEAD_RADIUS=e.HEAD_DIAMETER=e.Clip=e.Position=void 0;var r;e.Position=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e},(r=e.Clip||(e.Clip={}))[r.Unclipped=0]="Unclipped",r[r.Ground=1]="Ground",r[r.Sky=2]="Sky",e.HEAD_DIAMETER=.476,e.HEAD_RADIUS=.238,e.OBJECT_DIAMETER=.8,e.OBJECT_RADIUS=.4},922:function(t,e,r){"use strict";var n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__spreadArray||function(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0}),e.VideoDetail=e.SoundOptimization=e.PlayMode=void 0;var a,s,f,u=r(764),l=r(570),c=116,h=15,p=20,y=123432221;!function(t){t[t.Single=1]="Single",t[t.Multi=0]="Multi"}(a=e.PlayMode||(e.PlayMode={})),function(t){t[t.Compatibility=1]="Compatibility",t[t.BestQuality=0]="BestQuality"}(s=e.SoundOptimization||(e.SoundOptimization={})),function(t){t[t.Low=0]="Low",t[t.High=1]="High"}(f=e.VideoDetail||(e.VideoDetail={}));var d=function(){function t(){this.version=200,this.times=Array(90).fill({single:[],multi:[]}),this.players=[],this.playerAName="",this.playerBName="",this.playerAKeys={brake:208,changeDirection:57,rotateLeft:203,rotateRight:205,throttle:200,toggleNavigator:47,toggleShowHide:2,toggleTimer:20},this.playerBKeys={brake:80,changeDirection:82,rotateLeft:79,rotateRight:81,throttle:76,toggleNavigator:48,toggleShowHide:3,toggleTimer:21},this.soundEnabled=!0,this.soundOptimization=s.BestQuality,this.playMode=a.Single,this.flagTag=!1,this.swapBikes=!1,this.videoDetail=f.High,this.animatedObjects=!0,this.animatedMenus=!0,this.incScreenSizeKey=13,this.decScreenSizeKey=12,this.screenshotKey=23,this.lastEditedLevName="",this.lastPlayedExternal=""}return t.from=function(t){if(67910!==t.length)throw Error("Invalid state.dat file, expected buffer length of 67910, got "+t.length);return this.parseBuffer(t)},t.parseBuffer=function(e){var r=new t,n=this.cryptState(e),i=0;if(200!==n.readUInt32LE(i))throw Error("Invalid state.dat file");i+=4;for(var o=0;o<90;o++){var a=n.slice(i,i+688),s=l.bufferToTop10(a);r.times[o]=s,i+=688}var f=n.readUInt32LE(i+5800);if(f>50)throw Error("Expected max 50 player entries, got "+f);for(o=0;o<f;o++){var u=i+o*c,d=this.parsePlayer(n.slice(u,u+c));r.players.push(d)}i+=5804,r.playerAName=l.trimString(n.slice(i,i+h)),i+=h,r.playerBName=l.trimString(n.slice(i,i+h)),i+=h,r.soundEnabled=Boolean(n.readInt32LE(i)),i+=4,r.soundOptimization=n.readInt32LE(i),i+=4,r.playMode=n.readInt32LE(i),i+=4,r.flagTag=Boolean(n.readInt32LE(i)),i+=4,r.swapBikes=!Boolean(n.readInt32LE(i)),i+=4,r.videoDetail=n.readInt32LE(i),i+=4,r.animatedObjects=Boolean(n.readInt32LE(i)),i+=4,r.animatedMenus=Boolean(n.readInt32LE(i)),i+=4,r.playerAKeys=this.parsePlayerKeys(n.slice(i,i+32)),i+=32,r.playerBKeys=this.parsePlayerKeys(n.slice(i,i+32)),i+=32,r.incScreenSizeKey=n.readUInt32LE(i),i+=4,r.decScreenSizeKey=n.readUInt32LE(i),i+=4,r.screenshotKey=n.readUInt32LE(i),i+=4,r.lastEditedLevName=l.trimString(n.slice(i,i+p)),i+=p,r.lastPlayedExternal=l.trimString(n.slice(i,i+p)),i+=p;var g=n.readUInt32LE(i);if(g!==y&&123432112!==g)throw Error("Expected EOF marker, got "+g);return r},t.parsePlayer=function(t){if(t.length!==c)throw Error("Expected buffer of length 116, got "+t.length);return{name:l.trimString(t.slice(0,16)),skippedInternals:i([],n(t.slice(16,70))).map(Boolean),lastInternal:t.readUInt32LE(108),selectedInternal:t.readUInt32LE(112)}},t.parsePlayerKeys=function(t){if(32!==t.length)throw Error("Expected buffer of length 32, got "+t.length);var e=0,r=t.readUInt32LE(e);e+=4;var n=t.readUInt32LE(e);e+=4;var i=t.readUInt32LE(e);e+=4;var o=t.readUInt32LE(e);e+=4;var a=t.readUInt32LE(e);e+=4;var s=t.readUInt32LE(e);e+=4;var f=t.readUInt32LE(e);return e+=4,{throttle:r,brake:n,rotateRight:i,rotateLeft:o,changeDirection:a,toggleNavigator:s,toggleTimer:f,toggleShowHide:t.readUInt32LE(e)}},t.cryptState=function(t){var e,r,n=u.Buffer.from(t),i=[4,61920,5800,4,h,h,4,4,4,4,4,4,4,4,32,32,4,4,4,p,p],a=0;try{for(var s=o(i),f=s.next();!f.done;f=s.next()){var l=f.value;this.cryptStatePiece(n.slice(a,a+l)).copy(n,a),a+=l}}catch(t){e={error:t}}finally{try{f&&!f.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return n},t.cryptStatePiece=function(t){for(var e=u.Buffer.from(t),r=23,n=9782,i=0;i<t.length;i++)e[i]^=255&r,r=(65535&(r=31*(n+=r%3391*3391)+3391))-2*(32768&r);return e},t.prototype.toBuffer=function(){var e,r,n,i,a=u.Buffer.alloc(67910),s=0;a.writeUInt32LE(200),s+=4;try{for(var f=o(this.times.slice(0,90)),d=f.next();!d.done;d=f.next()){var g=d.value;l.top10ToBuffer(g).copy(a,s),s+=688}}catch(t){e={error:t}}finally{try{d&&!d.done&&(r=f.return)&&r.call(f)}finally{if(e)throw e.error}}s=61924;try{for(var v=o(this.players.slice(0,50)),w=v.next();!w.done;w=v.next()){var E=w.value,m=l.nullpadString(E.name,16);a.write(m,s,16,"ascii"),s+=16;var b=E.skippedInternals.slice(0,54);b.forEach((function(t){a.writeUInt8(t?1:0,s),s+=1})),b.length<54&&(s+=54-b.length),s+=38,a.writeInt32LE(E.lastInternal,s),s+=4,a.writeInt32LE(E.selectedInternal,s),s+=4}}catch(t){n={error:t}}finally{try{w&&!w.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}return this.players.length<50&&(a.fill(0,s,s+c*(50-this.players.length)),s+=c*(50-this.players.length)),a.writeUInt32LE(this.players.length,s),s+=4,a.write(l.nullpadString(this.playerAName,h),s,h,"ascii"),s+=h,a.write(l.nullpadString(this.playerBName,h),s,h,"ascii"),s+=h,a.writeInt32LE(this.soundEnabled?1:0,s),s+=4,a.writeInt32LE(this.soundOptimization,s),s+=4,a.writeInt32LE(this.playMode,s),s+=4,a.writeInt32LE(this.flagTag?1:0,s),s+=4,a.writeInt32LE(this.swapBikes?0:1,s),s+=4,a.writeInt32LE(this.videoDetail,s),s+=4,a.writeInt32LE(this.animatedObjects?1:0,s),s+=4,a.writeInt32LE(this.animatedMenus?1:0,s),s+=4,[this.playerAKeys,this.playerBKeys].forEach((function(t){a.writeUInt32LE(t.throttle,s),s+=4,a.writeUInt32LE(t.brake,s),s+=4,a.writeUInt32LE(t.rotateRight,s),s+=4,a.writeUInt32LE(t.rotateLeft,s),s+=4,a.writeUInt32LE(t.changeDirection,s),s+=4,a.writeUInt32LE(t.toggleNavigator,s),s+=4,a.writeUInt32LE(t.toggleTimer,s),s+=4,a.writeUInt32LE(t.toggleShowHide,s),s+=4})),a.writeUInt32LE(this.incScreenSizeKey,s),s+=4,a.writeUInt32LE(this.decScreenSizeKey,s),s+=4,a.writeUInt32LE(this.screenshotKey,s),s+=4,a.write(l.nullpadString(this.lastEditedLevName,p),s,p,"ascii"),s+=p,a.write(l.nullpadString(this.lastPlayedExternal,p),s,p,"ascii"),s+=p,a.writeUInt32LE(y,s),t.cryptState(a)},t}();e.default=d},367:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SoundOptimization=e.VideoDetail=e.PlayMode=e.State=void 0;var i=r(922);Object.defineProperty(e,"State",{enumerable:!0,get:function(){return n(i).default}}),Object.defineProperty(e,"PlayMode",{enumerable:!0,get:function(){return i.PlayMode}}),Object.defineProperty(e,"VideoDetail",{enumerable:!0,get:function(){return i.VideoDetail}}),Object.defineProperty(e,"SoundOptimization",{enumerable:!0,get:function(){return i.SoundOptimization}})},570:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.bufferToTop10=e.bufferToTop10Part=e.top10ToBuffer=e.trimString=e.nullpadString=e.formatTime=void 0;var n=r(764);function i(t,e){if(!/^[\x00-\x7F]*$/.test(t))throw new Error("String contains non-ASCII values");return t.length>e?t.slice(0,e):t.padEnd(e,"\0")}function o(t){var e=n.Buffer.from(t),r=e.indexOf("\0");return e.toString("ascii",0,-1!==r?r:void 0)}function a(t){var e=n.Buffer.from(t);if(344!==e.length)throw Error("Top10 buffer length expected to be 344, got "+e.length);for(var r=e.readInt32LE(0),i=[],a=0;a<r;a++){var s=4+4*a,f=44+15*a,u=f+15,l=194+15*a,c=l+15,h=e.readInt32LE(s),p=o(e.slice(f,u)),y=o(e.slice(l,c));i.push({time:h,name1:p,name2:y})}return i}e.formatTime=function(t){var e=Math.trunc(t%100),r=Math.trunc(t/100%60),n=Math.trunc(t/6e3%60),i=Math.trunc(t/36e4);return(i?i+":":"")+n.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")+","+e.toString().padStart(2,"0")},e.nullpadString=i,e.trimString=o,e.top10ToBuffer=function(t){var e=Object.values(t).map((function(t){t.sort((function(t,e){return t.time>e.time?1:t.time<e.time?-1:0}));var e=n.Buffer.alloc(344);e.writeUInt32LE(t.length>=10?10:t.length,0);for(var r=0;r<t.length;r++)r<10&&(e.writeUInt32LE(t[r].time,4+4*r),e.write(i(t[r].name1,15),44+15*r),e.write(i(t[r].name2,15),194+15*r));return e}));return n.Buffer.concat(e,688)},e.bufferToTop10Part=a,e.bufferToTop10=function(t){var e=n.Buffer.from(t);if(688!==e.length)throw Error("Top10 buffer length expected to be 688, got "+e.length);return{single:a(e.slice(0,344)),multi:a(e.slice(344))}}}},e={},function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}(341);var t,e}));
//# sourceMappingURL=main.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc