diff --git a/dist/asc.js b/dist/asc.js index fd475f3a..9d6650c7 100644 --- a/dist/asc.js +++ b/dist/asc.js @@ -1,2 +1,2 @@ -!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(function(){try{return require("assemblyscript")}catch(n){}}()):"function"==typeof define&&define.amd?define(["assemblyscript"],e):"object"==typeof exports?exports.asc=e(function(){try{return require("assemblyscript")}catch(n){}}()):n.asc=e(n.assemblyscript)}("undefined"!=typeof self?self:this,function(__WEBPACK_EXTERNAL_MODULE__10__){return function(n){var e={};function t(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var i in n)t.d(r,i,function(e){return n[e]}.bind(null,i));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=4)}([function(n,e,t){var r,i;e.nextTick=function(n){setTimeout(n,0)},e.platform=e.arch=e.execPath=e.title="browser",e.pid=1,e.browser=!0,e.env={},e.argv=[],e.binding=function(n){throw new Error("No such module. (Possibly not yet loaded)")},i="/",e.cwd=function(){return i},e.chdir=function(n){r||(r=t(1)),i=r.resolve(n,i)},e.exit=e.kill=e.umask=e.dlopen=e.uptime=e.memoryUsage=e.uvCounters=function(){},e.features={}},function(n,e,t){(function(n){function t(n,e){for(var t=0,r=n.length-1;r>=0;r--){var i=n[r];"."===i?n.splice(r,1):".."===i?(n.splice(r,1),t++):t&&(n.splice(r,1),t--)}if(e)for(;t--;t)n.unshift("..");return n}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(n){return r.exec(n).slice(1)};function o(n,e){if(n.filter)return n.filter(e);for(var t=[],r=0;r=-1&&!r;i--){var a=i>=0?arguments[i]:n.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,r="/"===a.charAt(0))}return(r?"/":"")+(e=t(o(e.split("/"),function(n){return!!n}),!r).join("/"))||"."},e.normalize=function(n){var r=e.isAbsolute(n),i="/"===a(n,-1);return(n=t(o(n.split("/"),function(n){return!!n}),!r).join("/"))||r||(n="."),n&&i&&(n+="/"),(r?"/":"")+n},e.isAbsolute=function(n){return"/"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(o(n,function(n,e){if("string"!=typeof n)throw new TypeError("Arguments to path.join must be strings");return n}).join("/"))},e.relative=function(n,t){function r(n){for(var e=0;e=0&&""===n[t];t--);return e>t?[]:n.slice(e,t-e+1)}n=e.resolve(n).substr(1),t=e.resolve(t).substr(1);for(var i=r(n.split("/")),o=r(t.split("/")),a=Math.min(i.length,o.length),s=a,l=0;l{try{assemblyscript=__webpack_require__(10)}catch(e){try{__webpack_require__(!function(){var n=new Error("Cannot find module 'ts-node'");throw n.code="MODULE_NOT_FOUND",n}()).register({project:path.join(".","..","src","tsconfig.json")}),__webpack_require__(!function(){var n=new Error("Cannot find module '../src/glue/js'");throw n.code="MODULE_NOT_FOUND",n}()),assemblyscript=__webpack_require__(!function(){var n=new Error("Cannot find module '../src'");throw n.code="MODULE_NOT_FOUND",n}()),isDev=!0}catch(e_ts){try{assemblyscript=eval("require('./assemblyscript')")}catch(n){throw n.stack=e_ts.stack+"\n---\n"+n.stack,n}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.7.0":__webpack_require__(!function(){var n=new Error("Cannot find module '../package.json'");throw n.code="MODULE_NOT_FOUND",n}()).version,exports.options=__webpack_require__(11),exports.sourceMapRoot="assemblyscript:///",exports.libraryPrefix=assemblyscript.LIBRARY_PREFIX,exports.defaultOptimizeLevel=3,exports.defaultShrinkLevel=1,exports.libraryFiles=exports.isBundle?Object({array:'/// \n\nimport { BLOCK_MAXSIZE } from "./rt/common";\nimport { COMPARATOR, SORT } from "./util/sort";\nimport { ArrayBuffer, ArrayBufferView } from "./arraybuffer";\nimport { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/number";\nimport { idof, isArray as builtin_isArray } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";\n\n/** Ensures that the given array has _at least_ the specified backing size. */\nfunction ensureSize(array: usize, minSize: usize, alignLog2: u32): void {\n var oldCapacity = changetype(array).dataLength;\n if (minSize > oldCapacity >>> alignLog2) {\n if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n let oldData = changetype(changetype(array).data);\n let newCapacity = minSize << alignLog2;\n let newData = __realloc(oldData, newCapacity);\n memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity);\n if (newData !== oldData) { // oldData has been free\'d\n store(changetype(array), __retain(newData), offsetof("data"));\n changetype(array).dataStart = newData;\n }\n changetype(array).dataLength = newCapacity;\n }\n}\n\nexport class Array extends ArrayBufferView {\n [key: number]: T;\n\n // Implementing ArrayBufferView isn\'t strictly necessary here but is done to allow glue code\n // to work with typed and normal arrays interchangeably. Technically, normal arrays do not need\n // `dataStart` (equals `data`) and `dataLength` (equals computed `data.byteLength`).\n\n // Also note that Array with non-nullable T must guard against implicit null values whenever\n // length is modified in a way that a null value would exist. Otherwise, the compiler wouldn\'t be\n // able to guarantee type-safety anymore. For lack of a better word, such an array is "holey".\n\n private length_: i32;\n\n static isArray(value: U): bool {\n return builtin_isArray(value) && value !== null;\n }\n\n static create(capacity: i32 = 0): Array {\n if (capacity > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n var array = changetype>(__allocArray(capacity, alignof(), idof())); // retains\n changetype>(array).length_ = 0; // safe even if T is a non-nullable reference\n memory.fill(array.dataStart, 0, array.dataLength);\n return array;\n }\n\n constructor(length: i32 = 0) {\n super(length, alignof());\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n this.length_ = length;\n }\n\n @unsafe get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.length_;\n }\n\n set length(length: i32) {\n if (isReference()) {\n if (!isNullable()) {\n if (length > this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), length, alignof());\n this.length_ = length;\n }\n\n every(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!callbackfn(load(this.dataStart + (index << alignof())), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (predicate(load(this.dataStart + (index << alignof())), index, this)) return index;\n }\n return -1;\n }\n\n @operator("[]") private __get(index: i32): T {\n if (isReference()) {\n if (!isNullable()) {\n if (index >= this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n var length = this.length_;\n if (isReference()) {\n if (!isNullable()) {\n if (index > length) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), index + 1, alignof());\n this.__unchecked_set(index, value);\n if (index >= length) this.length_ = index + 1;\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = this.dataStart + (index << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (index << alignof()), value);\n }\n }\n\n fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) {\n memory.fill(\n dataStart + start,\n u8(value),\n (end - start)\n );\n }\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return this;\n }\n\n includes(searchElement: T, fromIndex: i32 = 0): bool {\n return this.indexOf(searchElement, fromIndex) >= 0;\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n var length = this.length_;\n if (length == 0 || fromIndex >= length) return -1;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n var dataStart = this.dataStart;\n while (fromIndex < length) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = this.length_): i32 {\n var length = this.length_;\n if (length == 0) return -1;\n if (fromIndex < 0) fromIndex = length + fromIndex;\n else if (fromIndex >= length) fromIndex = length - 1;\n var dataStart = this.dataStart;\n while (fromIndex >= 0) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(value: T): i32 {\n var length = this.length_;\n var newLength = length + 1;\n ensureSize(changetype(this), newLength, alignof());\n if (isManaged()) {\n let offset = this.dataStart + (length << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (length << alignof()), value);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n concat(other: Array): Array {\n var thisLen = this.length_;\n var otherLen = select(0, other.length_, other === null);\n var outLen = thisLen + otherLen;\n if (outLen > BLOCK_MAXSIZE >>> alignof()) throw new Error(E_INVALIDLENGTH);\n var out = changetype>(__allocArray(outLen, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n var thisSize = thisLen << alignof();\n if (isManaged()) {\n let thisStart = this.dataStart;\n for (let offset: usize = 0; offset < thisSize; offset += sizeof()) {\n let ref = load(thisStart + offset);\n store(outStart + offset, __retain(ref));\n }\n outStart += thisSize;\n let otherStart = other.dataStart;\n let otherSize = otherLen << alignof();\n for (let offset: usize = 0; offset < otherSize; offset += sizeof()) {\n let ref = load(otherStart + offset);\n store(outStart + offset, __retain(ref));\n }\n } else {\n memory.copy(outStart, this.dataStart, thisSize);\n memory.copy(outStart + thisSize, other.dataStart, otherLen << alignof());\n }\n return out;\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var len = this.length_;\n\n end = min(end, len);\n var to = target < 0 ? max(len + target, 0) : min(target, len);\n var from = start < 0 ? max(len + start, 0) : min(start, len);\n var last = end < 0 ? max(len + end, 0) : min(end, len);\n var count = min(last - from, len - to);\n\n if (from < to && to < (from + count)) {\n from += count - 1;\n to += count - 1;\n while (count) {\n store(dataStart + (to << alignof()), load(dataStart + (from << alignof())));\n --from, --to, --count;\n }\n } else {\n memory.copy(\n dataStart + (to << alignof()),\n dataStart + (from << alignof()),\n count << alignof()\n );\n }\n return this;\n }\n\n pop(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var element = load(this.dataStart + ((--length) << alignof()));\n this.length_ = length;\n return element;\n }\n\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n callbackfn(load(this.dataStart + (index << alignof())), index, this);\n }\n }\n\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array {\n var length = this.length_;\n var out = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n for (let index = 0; index < min(length, this.length_); ++index) {\n let result = callbackfn(load(this.dataStart + (index << alignof())), index, this); // retains\n if (isManaged()) {\n store(outStart + (index << alignof()), __retain(changetype(result)));\n } else {\n store(outStart + (index << alignof()), result);\n }\n // releases result\n }\n return out;\n }\n\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array {\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n let value = load(this.dataStart + (index << alignof()));\n if (callbackfn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n reduceRight(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = this.length_ - 1; index >= 0; --index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n shift(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var base = this.dataStart;\n var element = load(base);\n var lastIndex = length - 1;\n memory.copy(\n base,\n base + sizeof(),\n lastIndex << alignof()\n );\n store(base + (lastIndex << alignof()),\n // @ts-ignore: cast\n null\n );\n this.length_ = lastIndex;\n return element;\n }\n\n some(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (callbackfn(load(this.dataStart + (index << alignof())), index, this)) return true;\n }\n return false;\n }\n\n unshift(element: T): i32 {\n var newLength = this.length_ + 1;\n ensureSize(changetype(this), newLength, alignof());\n var dataStart = this.dataStart;\n memory.copy(\n dataStart + sizeof(),\n dataStart,\n (newLength - 1) << alignof()\n );\n if (isManaged()) {\n store(dataStart, __retain(changetype(element)));\n } else {\n store(dataStart, element);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n begin = begin < 0 ? max(begin + length, 0) : min(begin, length);\n end = end < 0 ? max(end + length, 0) : min(end , length);\n length = max(end - begin, 0);\n var slice = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var sliceBase = slice.dataStart;\n var thisBase = this.dataStart + (begin << alignof());\n if (isManaged()) {\n let off = 0;\n let end = length << alignof();\n while (off < end) {\n let ref = load(thisBase + off);\n store(sliceBase + off, __retain(ref));\n off += sizeof();\n }\n } else {\n memory.copy(sliceBase, thisBase, length << alignof());\n }\n return slice;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n deleteCount = max(min(deleteCount, length - start), 0);\n var result = changetype>(__allocArray(deleteCount, alignof(), idof>())); // retains\n var resultStart = result.dataStart;\n var thisStart = this.dataStart;\n var thisBase = thisStart + (start << alignof());\n if (isManaged()) {\n for (let i = 0; i < deleteCount; ++i) {\n store(resultStart + (i << alignof()),\n load(thisBase + (i << alignof()))\n );\n // element is moved, so refcount doesn\'t change\n }\n } else {\n memory.copy(\n resultStart,\n thisBase,\n deleteCount << alignof()\n );\n }\n var offset = start + deleteCount;\n if (length != offset) {\n memory.copy(\n thisBase,\n thisStart + (offset << alignof()),\n (length - offset) << alignof()\n );\n }\n this.length_ = length - deleteCount;\n return result;\n }\n\n reverse(): Array {\n var length = this.length_;\n if (length) {\n let front = this.dataStart;\n let back = this.dataStart + ((length - 1) << alignof());\n while (front < back) {\n let temp = load(front);\n store(front, load(back));\n store(back, temp);\n front += sizeof();\n back -= sizeof();\n }\n }\n return this;\n }\n\n sort(comparator: (a: T, b: T) => i32 = COMPARATOR()): this {\n var length = this.length_;\n if (length <= 1) return this;\n var base = this.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b;\n store(base, a); // arr[0] = a;\n }\n return this;\n }\n SORT(base, length, comparator);\n return this;\n }\n\n join(separator: string = ","): string {\n if (isBoolean()) return this.join_bool(separator);\n if (isInteger()) return this.join_int(separator);\n if (isFloat()) return this.join_flt(separator);\n if (isString()) return this.join_str(separator);\n if (isArray()) return this.join_arr(separator);\n if (isReference()) return this.join_ref(separator);\n ERROR("unspported element type");\n return unreachable();\n }\n\n private join_bool(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return select("true", "false", load(dataStart));\n\n var sepLen = separator.length;\n var valueLen = 5; // max possible length of element len("false")\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: bool;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + i);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + lastIndex);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_int(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n // @ts-ignore: type\n if (!lastIndex) return changetype(itoa(load(dataStart))); // retains\n\n var sepLen = separator.length;\n const valueLen = (sizeof() <= 4 ? 10 : 20) + i32(isSigned());\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_flt(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) {\n return changetype(dtoa(\n // @ts-ignore: type\n load(dataStart))\n ); // retains\n }\n\n const valueLen = MAX_DOUBLE_LENGTH;\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_str(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return load(dataStart);\n\n var sepLen = separator.length;\n var estLen = 0;\n var value: string | null;\n for (let i = 0, len = lastIndex + 1; i < len; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) estLen += value.length;\n }\n var offset = 0;\n var result = changetype(__alloc((estLen + sepLen * lastIndex) << 1, idof())); // retains\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) {\n let valueLen = changetype(value).length;\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n if (value !== null) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n changetype(value).length << 1\n );\n }\n return result;\n }\n\n private join_arr(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n\n var result = "";\n var sepLen = separator.length;\n var base = this.dataStart;\n var value: T;\n if (!lastIndex) {\n value = load(base);\n // @ts-ignore: type\n return value ? value.join(separator) : "";\n }\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n if (sepLen) result += separator;\n }\n value = load(base + (lastIndex << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n return result; // registered by concatenation (FIXME: lots of garbage)\n }\n\n private join_ref(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var base = this.dataStart;\n if (!lastIndex) return "[object Object]";\n\n const valueLen = 15; // max possible length of element len("[object Object]")\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof()));\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n if (value) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n if (load(base + (lastIndex << alignof()))) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n toString(): string {\n return this.join();\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = this.dataStart;\n let end = cur + this.dataLength;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n // automatically visits ArrayBufferView (.data) next\n }\n}\n',arraybuffer:'/// \n\nimport { BLOCK, BLOCK_MAXSIZE, BLOCK_OVERHEAD } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INVALIDLENGTH } from "./util/error";\n\nexport abstract class ArrayBufferView {\n\n @unsafe data: ArrayBuffer;\n @unsafe dataStart: usize;\n @unsafe dataLength: u32;\n\n protected constructor(length: i32, alignLog2: i32) {\n if (length > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length = length << alignLog2, idof());\n this.data = changetype(buffer); // retains\n this.dataStart = buffer;\n this.dataLength = length;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n get length(): i32 {\n ERROR("missing implementation: subclasses must implement ArrayBufferView#length");\n return unreachable();\n }\n}\n\n@sealed export class ArrayBuffer {\n\n static isView(value: T): bool {\n if (value) {\n if (value instanceof Int8Array) return true;\n if (value instanceof Uint8Array) return true;\n if (value instanceof Uint8ClampedArray) return true;\n if (value instanceof Int16Array) return true;\n if (value instanceof Uint16Array) return true;\n if (value instanceof Int32Array) return true;\n if (value instanceof Uint32Array) return true;\n if (value instanceof Int64Array) return true;\n if (value instanceof Uint64Array) return true;\n if (value instanceof Float32Array) return true;\n if (value instanceof Float64Array) return true;\n if (value instanceof DataView) return true;\n }\n return false;\n }\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length, idof());\n memory.fill(buffer, 0, length);\n return changetype(buffer); // retains\n }\n\n get byteLength(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n }\n\n slice(begin: i32 = 0, end: i32 = BLOCK_MAXSIZE): ArrayBuffer {\n var length = this.byteLength;\n begin = begin < 0 ? max(length + begin, 0) : min(begin, length);\n end = end < 0 ? max(length + end , 0) : min(end , length);\n var outSize = max(end - begin, 0);\n var out = __alloc(outSize, idof());\n memory.copy(out, changetype(this) + begin, outSize);\n return changetype(out); // retains\n }\n\n toString(): string {\n return "[object ArrayBuffer]";\n }\n}\n',"bindings/Date":"export declare function UTC(\n // NOTE: Using i32 below saves us a f64.convert_s instruction and moves the responsibility for\n // converting the value to the WASM/JS boundary.\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: f64\n): f64;\nexport declare function now(): f64;\n","bindings/Math":"export declare const E: f64;\nexport declare const LN2: f64;\nexport declare const LN10: f64;\nexport declare const LOG2E: f64;\nexport declare const LOG10E: f64;\nexport declare const PI: f64;\nexport declare const SQRT1_2: f64;\nexport declare const SQRT2: f64;\n\nexport declare function abs(x: f64): f64;\nexport declare function acos(x: f64): f64;\nexport declare function acosh(x: f64): f64;\nexport declare function asin(x: f64): f64;\nexport declare function asinh(x: f64): f64;\nexport declare function atan(x: f64): f64;\nexport declare function atan2(y: f64, x: f64): f64;\nexport declare function atanh(x: f64): f64;\nexport declare function cbrt(x: f64): f64;\nexport declare function ceil(x: f64): f64;\nexport declare function clz32(x: f64): f64;\nexport declare function cos(x: f64): f64;\nexport declare function cosh(x: f64): f64;\nexport declare function exp(x: f64): f64;\nexport declare function expm1(x: f64): f64;\nexport declare function floor(x: f64): f64;\nexport declare function fround(x: f64): f32;\nexport declare function hypot(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function imul(a: f64, b: f64): f64;\nexport declare function log(x: f64): f64;\nexport declare function log10(x: f64): f64;\nexport declare function log1p(x: f64): f64;\nexport declare function log2(x: f64): f64;\nexport declare function max(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function min(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function pow(base: f64, exponent: f64): f64;\nexport declare function random(): f64;\nexport declare function round(x: f64): f64;\nexport declare function sign(x: f64): f64;\nexport declare function sin(x: f64): f64;\nexport declare function sinh(x: f64): f64;\nexport declare function sqrt(x: f64): f64;\nexport declare function tan(x: f64): f64;\nexport declare function tanh(x: f64): f64;\nexport declare function trunc(x: f64): f64;\n","bindings/wasi_unstable":"// see: https://wasi.dev\n\n/* tslint:disable:max-line-length */\n\n// helper types to be more explicit\ntype char = u8;\ntype ptr = usize; // all pointers are usize'd\ntype struct = T; // structs are references already in AS\n\n/** Read command-line argument data. */\nexport declare function args_get(\n /** Input: Pointer to a buffer to write the argument pointers. */\n argv: ptr>,\n /** Input: Pointer to a buffer to write the argument string data. */\n argv_buf: ptr\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function args_sizes_get(\n /** Output: Number of arguments. */\n argc: ptr,\n /** Output: Size of the argument string data. */\n argv_buf_size: ptr\n): errno;\n\n/** Return the resolution of a clock. */\nexport declare function clock_res_get(\n /** Input: The clock for which to return the resolution. */\n clock: clockid,\n /** Output: The resolution of the clock. */\n resolution: ptr\n): errno;\n\n/** Return the time value of a clock. */\nexport declare function clock_time_get(\n /** Input: Cock for which to return the time. */\n clock: clockid,\n /** Input: Maximum lag (exclusive) that the returned time value may have, compared to its actual value. */\n precision: timestamp,\n /** Output: Time value of the clock. */\n time: ptr\n): errno;\n\n/** Read environment variable data. */\nexport declare function environ_get(\n /** Input: Pointer to a buffer to write the environment variable pointers. */\n environ: ptr,\n /** Input: Pointer to a buffer to write the environment variable string data. */\n environ_buf: usize\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function environ_sizes_get(\n /** Output: The number of environment variables. */\n environ_count: ptr,\n /** Output: The size of the environment variable string data. */\n environ_buf_size: ptr\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_advise(\n /** Input: The file descriptor for the file for which to provide file advisory information. */\n fd: fd,\n /** Input: The offset within the file to which the advisory applies. */\n offset: filesize,\n /** Input: The length of the region to which the advisory applies. */\n len: filesize,\n /** Input: The advice. */\n advice: advice\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_allocate(\n /** Input: The file descriptor for the file in which to allocate space. */\n fd: fd,\n /** Input: The offset at which to start the allocation. */\n offset: filesize,\n /** Input: The length of the area that is allocated. */\n len: filesize\n): errno;\n\n/** Close a file descriptor. */\nexport declare function fd_close(\n /** Input: The file descriptor to close. */\n fd: fd\n): errno;\n\n/** Synchronize the data of a file to disk. */\nexport declare function fd_datasync(\n /** Input: The file descriptor of the file to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Get the attributes of a file descriptor. */\nexport declare function fd_fdstat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file descriptor's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the flags associated with a file descriptor. */\nexport declare function fd_fdstat_set_flags(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the file descriptor flags. */\n flags: fdflags\n): errno;\n\n/** Adjust the rights associated with a file descriptor. */\nexport declare function fd_fdstat_set_rights(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_base: rights,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_inheriting: rights\n): errno;\n\n/** Return the attributes of an open file. */\nexport declare function fd_filestat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros. */\nexport declare function fd_filestat_set_size(\n /** Input: A file descriptor for the file to adjust. */\n fd: fd,\n /** Input: The desired file size. */\n size: filesize\n): errno;\n\n/** Adjust the timestamps of an open file or directory. */\nexport declare function fd_filestat_set_times(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Read from a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pread(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors in which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors in which to store data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to read. */\n offset: filesize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_get(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: The buffer where the description is stored. */\n buf: struct\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_dir_name(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: Buffer into which to write the preopened directory name. */\n path: ptr,\n /** Input: Length of the buffer into which to write the preopened directory name. */\n path_len: usize\n): errno;\n\n/** Write to a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pwrite(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to write. */\n offset: filesize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/** Read from a file descriptor. */\nexport declare function fd_read(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors to which to store data. */\n iovs_len: usize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Read directory entries from a directory. */\nexport declare function fd_readdir(\n /** Input: Directory from which to read the directory entries. */\n fd: fd,\n /** Input: Buffer where directory entries are stored. */\n buf: ptr>,\n /** Input: Length of the buffer where directory entries are stored. */\n buf_len: usize,\n /** Input: Location within the directory to start reading. */\n cookie: dircookie,\n /** Output: Number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached. */\n buf_used: ptr\n): errno;\n\n/** Atomically replace a file descriptor by renumbering another file descriptor. */\nexport declare function fd_renumber(\n /** Input: The file descriptor to renumber. */\n from: fd,\n /** Input: The file descriptor to overwrite. */\n to: fd\n): errno;\n\n/** Move the offset of a file descriptor. */\nexport declare function fd_seek(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The number of bytes to move. */\n offset: filedelta,\n /** Input: The base from which the offset is relative. */\n whence: whence,\n /** Output: The new offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Synchronize the data and metadata of a file to disk. */\nexport declare function fd_sync(\n /** Input: The file descriptor of the file containing the data and metadata to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Return the current offset of a file descriptor. */\nexport declare function fd_tell(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Output: The current offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Write to a file descriptor. */\nexport declare function fd_write(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/* Create a directory. */\nexport declare function path_create_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path at which to create the directory. */\n path: ptr,\n /** Input: The path at which to create the directory. */\n path_len: usize\n): errno;\n\n/** Return the attributes of a file or directory. */\nexport declare function path_filestat_get(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to inspect. */\n path: ptr,\n /** Input: The path of the file or directory to inspect. */\n path_len: usize,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the timestamps of a file or directory. */\nexport declare function path_filestat_set_times(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to operate on. */\n path: ptr,\n /** Input: The path of the file or directory to operate on. */\n path_len: usize,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Create a hard link. */\nexport declare function path_link(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n old_flags: lookupflags,\n /** Input: The source path from which to link. */\n old_path: ptr,\n /** Input: The source path from which to link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path at which to create the hard link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the hard link. */\n new_path_len: usize\n): errno;\n\n/** Open a file or directory. */\nexport declare function path_open(\n /** Input: The working directory at which the resolution of the path starts. */\n dirfd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n dirflags: lookupflags,\n /** Input: The path of the file or directory to open. */\n path: ptr,\n /** Input: The length of the path of the file or directory to open. */\n path_len: usize,\n /** Input: The method by which to open the file. */\n oflags: oflags,\n /** Input: The initial base rights that apply to operations using the file descriptor itself. */\n fs_rights_base: rights,\n /** Input: The initial inheriting rights that apply to file descriptors derived from it. */\n fs_rights_inheriting: rights,\n /** Input: The initial flags of the file descriptor. */\n fs_flags: fdflags,\n /** Output: The file descriptor of the file that has been opened. */\n fd: ptr\n): errno;\n\n/** Read the contents of a symbolic link. */\nexport declare function path_readlink(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path of the symbolic link from which to read. */\n path: ptr,\n /** Input: The length of the path of the symbolic link from which to read. */\n path_len: usize,\n /** Input: The buffer to which to write the contents of the symbolic link. */\n buf: ptr,\n /** Input: The length of the buffer to which to write the contents of the symbolic link. */\n buf_len: usize,\n /** Output: The number of bytes placed in the buffer. */\n buf_used: ptr\n): errno;\n\n/** Remove a directory. */\nexport declare function path_remove_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a directory to remove. */\n path: ptr,\n /** Input: The length of the path to a directory to remove. */\n path_len: usize\n): errno;\n\n/** Rename a file or directory. */\nexport declare function path_rename(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: The source path of the file or directory to rename. */\n old_path: ptr,\n /** Input: The length of the source path of the file or directory to rename. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path to which to rename the file or directory. */\n new_path: ptr,\n /** Input: The length of the destination path to which to rename the file or directory. */\n new_path_len: usize\n): errno;\n\n/** Create a symbolic link. */\nexport declare function path_symlink(\n /** Input: The contents of the symbolic link. */\n old_path: ptr,\n /** Input: The length of the contents of the symbolic link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The destination path at which to create the symbolic link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the symbolic link. */\n new_path_len: usize\n): errno;\n\n/** Unlink a file. */\nexport declare function path_unlink_file(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a file to unlink. */\n path: ptr,\n /** Input: The length of the path to a file to unlink. */\n path_len: usize\n): errno;\n\n/** Concurrently poll for the occurrence of a set of events. */\nexport declare function poll_oneoff(\n /** Input: The events to which to subscribe. */\n in_: ptr>,\n /** Input: The events that have occurred. */\n out: ptr>,\n /** Input: Both the number of subscriptions and events. */\n nsubscriptions: usize,\n /** Output: The number of events stored. */\n nevents: ptr\n): errno;\n\n/** Terminate the process normally. An exit code of 0 indicates successful termination of the program. The meanings of other values is dependent on the environment. */\nexport declare function proc_exit(\n /** Input: The exit code returned by the process. */\n rval: u32\n): void;\n\n/** Send a signal to the process of the calling thread. */\nexport declare function proc_raise(\n /** Input: The signal condition to trigger. */\n sig: signal\n): errno;\n\n/** Write high-quality random data into a buffer. */\nexport declare function random_get(\n /** Input: The buffer to fill with random data. */\n buf: usize,\n /** Input: The length of the buffer to fill with random data. */\n buf_len: usize\n): errno;\n\n/** Temporarily yield execution of the calling thread. */\nexport declare function sched_yield(): errno;\n\n/** Receive a message from a socket. */\nexport declare function sock_recv(\n /** Input: The socket on which to receive data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n ri_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to store data. */\n ri_data_len: usize,\n /** Input: Message flags. */\n ri_flags: riflags,\n /** Output: Number of bytes stored in `ri_data`. */\n ro_datalen: ptr,\n /** Output: Message flags. */\n ro_flags: ptr\n): errno;\n\n/** Send a message on a socket. */\nexport declare function sock_send(\n /** Input: The socket on which to send data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to retrieve data */\n si_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to retrieve data */\n si_data_len: usize,\n /** Input: Message flags. */\n si_flags: siflags,\n /** Output: Number of bytes transmitted. */\n so_datalen: ptr\n): errno;\n\n/** Shut down socket send and receive channels. */\nexport declare function sock_shutdown(\n /** Input: The socket on which to shutdown channels. */\n sock: fd,\n /** Input: Which channels on the socket to shut down. */\n how: sdflags\n): errno;\n\n// === Types ======================================================================================\n\n/** File or memory access pattern advisory information. */\nexport namespace advice {\n /** The application has no advice to give on its behavior with respect to the specified data. */\n // @ts-ignore: decorator\n @inline\n export const NORMAL: advice = 0;\n /** The application expects to access the specified data sequentially from lower offsets to higher offsets. */\n // @ts-ignore: decorator\n @inline\n export const SEQUENTIAL : advice = 1;\n /** The application expects to access the specified data in a random order. */\n // @ts-ignore: decorator\n @inline\n export const RANDOM: advice = 2;\n /** The application expects to access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const WILLNEED: advice = 3;\n /** The application expects that it will not access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const DONTNEED: advice = 4;\n /** The application expects to access the specified data once and then not reuse it thereafter. */\n // @ts-ignore: decorator\n @inline\n export const NOREUSE: advice = 5;\n}\nexport type advice = u8;\n\n/** Identifiers for clocks. */\nexport namespace clockid {\n /** The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. */\n // @ts-ignore: decorator\n @inline\n export const REALTIME: clockid = 0;\n /** The store-wide monotonic clock. Absolute value has no meaning. */\n // @ts-ignore: decorator\n @inline\n export const MONOTONIC: clockid = 1;\n /** The CPU-time clock associated with the current process. */\n // @ts-ignore: decorator\n @inline\n export const PROCESS_CPUTIME_ID: clockid = 2;\n /** The CPU-time clock associated with the current thread. */\n // @ts-ignore: decorator\n @inline\n export const THREAD_CPUTIME_ID: clockid = 3;\n}\nexport type clockid = u32;\n\n/** Identifier for a device containing a file system. Can be used in combination with `inode` to uniquely identify a file or directory in the filesystem. */\nexport type device = u64;\n\n/** A reference to the offset of a directory entry. */\nexport type dircookie = u64;\n\n/** A directory entry. */\n@unmanaged export class dirent {\n /** The offset of the next directory entry stored in this directory. */\n next: dircookie;\n /** The serial number of the file referred to by this directory entry. */\n ino: inode;\n /** The length of the name of the directory entry. */\n namlen: u32;\n /** The type of the file referred to by this directory entry. */\n type: filetype;\n private __padding0: u16;\n}\n\n/** Error codes returned by functions. */\nexport namespace errno {\n /** No error occurred. System call completed successfully. */\n // @ts-ignore: decorator\n @inline\n export const SUCCESS: errno = 0;\n /** Argument list too long. */\n // @ts-ignore: decorator\n @inline\n export const TOOBIG: errno = 1;\n /** Permission denied. */\n // @ts-ignore: decorator\n @inline\n export const ACCES: errno = 2;\n /** Address in use. */\n // @ts-ignore: decorator\n @inline\n export const ADDRINUSE: errno = 3;\n /** Address not available. */\n // @ts-ignore: decorator\n @inline\n export const ADDRNOTAVAIL: errno = 4;\n /** Address family not supported. */\n // @ts-ignore: decorator\n @inline\n export const AFNOSUPPORT: errno = 5;\n /** Resource unavailable, or operation would block. */\n // @ts-ignore: decorator\n @inline\n export const AGAIN: errno = 6;\n /** Connection already in progress. */\n // @ts-ignore: decorator\n @inline\n export const ALREADY: errno = 7;\n /** Bad file descriptor. */\n // @ts-ignore: decorator\n @inline\n export const BADF: errno = 8;\n /** Bad message. */\n // @ts-ignore: decorator\n @inline\n export const BADMSG: errno = 9;\n /** Device or resource busy. */\n // @ts-ignore: decorator\n @inline\n export const BUSY: errno = 10;\n /** Operation canceled. */\n // @ts-ignore: decorator\n @inline\n export const CANCELED: errno = 11;\n /** No child processes. */\n // @ts-ignore: decorator\n @inline\n export const CHILD: errno = 12;\n /** Connection aborted. */\n // @ts-ignore: decorator\n @inline\n export const CONNABORTED: errno = 13;\n /** Connection refused. */\n // @ts-ignore: decorator\n @inline\n export const CONNREFUSED: errno = 14;\n /** Connection reset. */\n // @ts-ignore: decorator\n @inline\n export const CONNRESET: errno = 15;\n /** Resource deadlock would occur. */\n // @ts-ignore: decorator\n @inline\n export const DEADLK: errno = 16;\n /** Destination address required. */\n // @ts-ignore: decorator\n @inline\n export const DESTADDRREQ: errno = 17;\n /** Mathematics argument out of domain of function. */\n // @ts-ignore: decorator\n @inline\n export const DOM: errno = 18;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const DQUOT: errno = 19;\n /** File exists. */\n // @ts-ignore: decorator\n @inline\n export const EXIST: errno = 20;\n /** Bad address. */\n // @ts-ignore: decorator\n @inline\n export const FAULT: errno = 21;\n /** File too large. */\n // @ts-ignore: decorator\n @inline\n export const FBIG: errno = 22;\n /** Host is unreachable. */\n // @ts-ignore: decorator\n @inline\n export const HOSTUNREACH: errno = 23;\n /** Identifier removed. */\n // @ts-ignore: decorator\n @inline\n export const IDRM: errno = 24;\n /** Illegal byte sequence. */\n // @ts-ignore: decorator\n @inline\n export const ILSEQ: errno = 25;\n /** Operation in progress. */\n // @ts-ignore: decorator\n @inline\n export const INPROGRESS: errno = 26;\n /** Interrupted function. */\n // @ts-ignore: decorator\n @inline\n export const INTR: errno = 27;\n /** Invalid argument. */\n // @ts-ignore: decorator\n @inline\n export const INVAL: errno = 28;\n /** I/O error. */\n // @ts-ignore: decorator\n @inline\n export const IO: errno = 29;\n /** Socket is connected. */\n // @ts-ignore: decorator\n @inline\n export const ISCONN: errno = 30;\n /** Is a directory. */\n // @ts-ignore: decorator\n @inline\n export const ISDIR: errno = 31;\n /** Too many levels of symbolic links. */\n // @ts-ignore: decorator\n @inline\n export const LOOP: errno = 32;\n /** File descriptor value too large. */\n // @ts-ignore: decorator\n @inline\n export const MFILE: errno = 33;\n /** Too many links. */\n // @ts-ignore: decorator\n @inline\n export const MLINK: errno = 34;\n /** Message too large. */\n // @ts-ignore: decorator\n @inline\n export const MSGSIZE: errno = 35;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const MULTIHOP: errno = 36;\n /** Filename too long. */\n // @ts-ignore: decorator\n @inline\n export const NAMETOOLONG: errno = 37;\n /** Network is down. */\n // @ts-ignore: decorator\n @inline\n export const NETDOWN: errno = 38;\n /** Connection aborted by network. */\n // @ts-ignore: decorator\n @inline\n export const NETRESET: errno = 39;\n /** Network unreachable. */\n // @ts-ignore: decorator\n @inline\n export const NETUNREACH: errno = 40;\n /** Too many files open in system. */\n // @ts-ignore: decorator\n @inline\n export const NFILE: errno = 41;\n /** No buffer space available. */\n // @ts-ignore: decorator\n @inline\n export const NOBUFS: errno = 42;\n /** No such device. */\n // @ts-ignore: decorator\n @inline\n export const NODEV: errno = 43;\n /** No such file or directory. */\n // @ts-ignore: decorator\n @inline\n export const NOENT: errno = 44;\n /** Executable file format error. */\n // @ts-ignore: decorator\n @inline\n export const NOEXEC: errno = 45;\n /** No locks available. */\n // @ts-ignore: decorator\n @inline\n export const NOLCK: errno = 46;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const NOLINK: errno = 47;\n /** Not enough space. */\n // @ts-ignore: decorator\n @inline\n export const NOMEM: errno = 48;\n /** No message of the desired type. */\n // @ts-ignore: decorator\n @inline\n export const NOMSG: errno = 49;\n /** Protocol not available. */\n // @ts-ignore: decorator\n @inline\n export const NOPROTOOPT: errno = 50;\n /** No space left on device. */\n // @ts-ignore: decorator\n @inline\n export const NOSPC: errno = 51;\n /** Function not supported. */\n // @ts-ignore: decorator\n @inline\n export const NOSYS: errno = 52;\n /** The socket is not connected. */\n // @ts-ignore: decorator\n @inline\n export const NOTCONN: errno = 53;\n /** Not a directory or a symbolic link to a directory. */\n // @ts-ignore: decorator\n @inline\n export const NOTDIR: errno = 54;\n /** Directory not empty. */\n // @ts-ignore: decorator\n @inline\n export const NOTEMPTY: errno = 55;\n /** State not recoverable. */\n // @ts-ignore: decorator\n @inline\n export const NOTRECOVERABLE: errno = 56;\n /** Not a socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSOCK: errno = 57;\n /** Not supported, or operation not supported on socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSUP: errno = 58;\n /** Inappropriate I/O control operation. */\n // @ts-ignore: decorator\n @inline\n export const NOTTY: errno = 59;\n /** No such device or address. */\n // @ts-ignore: decorator\n @inline\n export const NXIO: errno = 60;\n /** Value too large to be stored in data type. */\n // @ts-ignore: decorator\n @inline\n export const OVERFLOW: errno = 61;\n /** Previous owner died. */\n // @ts-ignore: decorator\n @inline\n export const OWNERDEAD: errno = 62;\n /** Operation not permitted. */\n // @ts-ignore: decorator\n @inline\n export const PERM: errno = 63;\n /** Broken pipe. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: errno = 64;\n /** Protocol error. */\n // @ts-ignore: decorator\n @inline\n export const PROTO: errno = 65;\n /** Protocol not supported. */\n // @ts-ignore: decorator\n @inline\n export const PROTONOSUPPORT: errno = 66;\n /** Protocol wrong type for socket. */\n // @ts-ignore: decorator\n @inline\n export const PROTOTYPE: errno = 67;\n /** Result too large. */\n // @ts-ignore: decorator\n @inline\n export const RANGE: errno = 68;\n /** Read-only file system. */\n // @ts-ignore: decorator\n @inline\n export const ROFS: errno = 69;\n /** Invalid seek. */\n // @ts-ignore: decorator\n @inline\n export const SPIPE: errno = 70;\n /** No such process. */\n // @ts-ignore: decorator\n @inline\n export const SRCH: errno = 71;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const STALE: errno = 72;\n /** Connection timed out. */\n // @ts-ignore: decorator\n @inline\n export const TIMEDOUT: errno = 73;\n /** Text file busy. */\n // @ts-ignore: decorator\n @inline\n export const TXTBSY: errno = 74;\n /** Cross-device link. */\n // @ts-ignore: decorator\n @inline\n export const XDEV: errno = 75;\n /** Extension: Capabilities insufficient. */\n // @ts-ignore: decorator\n @inline\n export const NOTCAPABLE: errno = 76;\n}\nexport type errno = u16;\n\n/** An event that occurred. */\n@unmanaged export abstract class event {\n /** User-provided value that got attached to `subscription#userdata`. */\n userdata: userdata;\n /** If non-zero, an error that occurred while processing the subscription request. */\n error: errno;\n /* The type of the event that occurred. */\n type: eventtype;\n private __padding0: u16;\n}\n\n/** An event that occurred when type is `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\n@unmanaged export class rwevent extends event {\n /* The number of bytes available for reading or writing. */\n nbytes: filesize;\n /* The state of the file descriptor. */\n flags: eventrwflags;\n private __padding1: u32;\n}\n\n/** The state of the file descriptor subscribed to with `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\nexport namespace eventrwflags {\n /** The peer of this socket has closed or disconnected. */\n // @ts-ignore: decorator\n @inline\n export const HANGUP: eventrwflags = 1;\n}\nexport type eventrwflags = u16;\n\n/** Type of a subscription to an event or its occurrence. */\nexport namespace eventtype {\n /** The time value of clock has reached the timestamp. */\n // @ts-ignore: decorator\n @inline\n export const CLOCK: eventtype = 0;\n /** File descriptor has data available for reading. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: eventtype = 1;\n /** File descriptor has capacity available for writing */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: eventtype = 2;\n}\nexport type eventtype = u8;\n\n/** Exit code generated by a process when exiting. */\nexport type exitcode = u32;\n\n/** A file descriptor number. */\nexport type fd = u32;\n\n/** File descriptor flags. */\nexport namespace fdflags {\n /** Append mode: Data written to the file is always appended to the file's end. */\n // @ts-ignore: decorator\n @inline\n export const APPEND: fdflags = 1;\n /** Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. */\n // @ts-ignore: decorator\n @inline\n export const DSYNC: fdflags = 2;\n /** Non-blocking mode. */\n // @ts-ignore: decorator\n @inline\n export const NONBLOCK: fdflags = 4;\n /** Synchronized read I/O operations. */\n // @ts-ignore: decorator\n @inline\n export const RSYNC: fdflags = 8;\n /** Write according to synchronized I/O file integrity completion. */\n // @ts-ignore: decorator\n @inline\n export const SYNC: fdflags = 16;\n}\nexport type fdflags = u16;\n\n/** File descriptor attributes. */\n@unmanaged export class fdstat {\n /** File type. */\n filetype: filetype;\n /** File descriptor flags. */\n flags: fdflags;\n /** Rights that apply to this file descriptor. */\n rights_base: rights;\n /** Maximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., through `path_open`. */\n rights_inheriting: rights;\n}\n\n/** Relative offset within a file. */\nexport type filedelta = i64;\n\n/** Non-negative file size or length of a region within a file. */\nexport type filesize = u64;\n\n/** File attributes. */\n@unmanaged export class filestat {\n /** Device ID of device containing the file. */\n dev: device;\n /** File serial number. */\n ino: inode;\n /** File type. */\n filetype: filetype;\n /** Number of hard links to the file. */\n nlink: linkcount;\n /** For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. */\n size: filesize;\n /** Last data access timestamp. */\n atim: timestamp;\n /** Last data modification timestamp. */\n mtim: timestamp;\n /** Last file status change timestamp. */\n ctim: timestamp;\n}\n\n/** The type of a file descriptor or file. */\nexport namespace filetype {\n /** The type of the file descriptor or file is unknown or is different from any of the other types specified. */\n // @ts-ignore: decorator\n @inline\n export const UNKNOWN: filetype = 0;\n /** The file descriptor or file refers to a block device inode. */\n // @ts-ignore: decorator\n @inline\n export const BLOCK_DEVICE: filetype = 1;\n /** The file descriptor or file refers to a character device inode. */\n // @ts-ignore: decorator\n @inline\n export const CHARACTER_DEVICE: filetype = 2;\n /** The file descriptor or file refers to a directory inode. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: filetype = 3;\n /** The file descriptor or file refers to a regular file inode. */\n // @ts-ignore: decorator\n @inline\n export const REGULAR_FILE: filetype = 4;\n /** The file descriptor or file refers to a datagram socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_DGRAM: filetype = 5;\n /** The file descriptor or file refers to a byte-stream socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_STREAM: filetype = 6;\n /** The file refers to a symbolic link inode. */\n // @ts-ignore: decorator\n @inline\n export const SYMBOLIC_LINK: filetype = 7;\n}\nexport type filetype = u8;\n\n/** Which file time attributes to adjust. */\nexport namespace fstflags {\n /** Adjust the last data access timestamp to the value stored in `filestat#st_atim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM: fstflags = 1;\n /** Adjust the last data access timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM_NOW: fstflags = 2;\n /** Adjust the last data modification timestamp to the value stored in `filestat#st_mtim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM: fstflags = 4;\n /** Adjust the last data modification timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM_NOW: fstflags = 8;\n}\nexport type fstflags = u16;\n\n/** File serial number that is unique within its file system. */\nexport type inode = u64;\n\n/** A region of memory for scatter/gather reads. */\n@unmanaged export class iovec {\n /** The address of the buffer to be filled. */\n buf: usize;\n /** The length of the buffer to be filled. */\n buf_len: usize;\n}\n\n/** Number of hard links to an inode. */\nexport type linkcount = u32;\n\n/** Flags determining the method of how paths are resolved. */\nexport namespace lookupflags {\n /** As long as the resolved path corresponds to a symbolic link, it is expanded. */\n // @ts-ignore: decorator\n @inline\n export const SYMLINK_FOLLOW: lookupflags = 1;\n}\nexport type lookupflags = u32;\n\n/** Open flags. */\nexport namespace oflags {\n /** Create file if it does not exist. */\n // @ts-ignore: decorator\n @inline\n export const CREAT: oflags = 1;\n /** Fail if not a directory. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: oflags = 2;\n /** Fail if file already exists. */\n // @ts-ignore: decorator\n @inline\n export const EXCL: oflags = 4;\n /** Truncate file to size 0. */\n // @ts-ignore: decorator\n @inline\n export const TRUNC: oflags = 8;\n}\nexport type oflags = u16;\n\n// TODO: undocumented\nexport namespace preopentype {\n // @ts-ignore: decorator\n @inline\n export const DIR: preopentype = 0;\n}\nexport type preopentype = u8;\n\n// TODO: undocumented\nexport abstract class prestat {\n type: preopentype;\n}\n\n// TODO: undocumented\nexport class dirprestat extends prestat {\n name_len: usize;\n}\n\n/** Flags provided to `sock_recv`. */\nexport namespace riflags {\n /** Returns the message without removing it from the socket's receive queue. */\n // @ts-ignore: decorator\n @inline\n export const PEEK: riflags = 1;\n /** On byte-stream sockets, block until the full amount of data can be returned. */\n // @ts-ignore: decorator\n @inline\n export const WAITALL: riflags = 2;\n}\nexport type riflags = u16;\n\n/** File descriptor rights, determining which actions may be performed. */\nexport namespace rights {\n /** The right to invoke `fd_datasync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_DATASYNC: rights = 1;\n /** The right to invoke `fd_read` and `sock_recv`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: rights = 2;\n /** The right to invoke `fd_seek`. This flag implies `rights.FD_TELL`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SEEK: rights = 4;\n /** The right to invoke `fd_fdstat_set_flags`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FDSTAT_SET_FLAGS: rights = 8;\n /** The right to invoke `fd_sync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SYNC: rights = 16;\n /** The right to invoke `fd_seek` in such a way that the file offset remains unaltered (i.e., `whence.CUR` with offset zero), or to invoke `fd_tell`). */\n // @ts-ignore: decorator\n @inline\n export const FD_TELL: rights = 32;\n /** The right to invoke `fd_write` and `sock_send`. If `rights.FD_SEEK` is set, includes the right to invoke `fd_pwrite`. */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: rights = 64;\n /** The right to invoke `fd_advise`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ADVISE: rights = 128;\n /** The right to invoke `fd_allocate`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ALLOCATE: rights = 256;\n /** The right to invoke `path_create_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_DIRECTORY: rights = 512;\n /** If `rights.PATH_OPEN` is set, the right to invoke `path_open` with `oflags.CREAT`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_FILE: rights = 1024;\n /** The right to invoke `path_link` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_SOURCE: rights = 2048;\n /** The right to invoke `path_link` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_TARGET: rights = 4096;\n /** The right to invoke `path_open`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_OPEN: rights = 8192;\n /** The right to invoke `fd_readdir`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READDIR: rights = 16384;\n /** The right to invoke `path_readlink`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_READLINK: rights = 32768;\n /** The right to invoke `path_rename` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_SOURCE: rights = 65536;\n /** The right to invoke `path_rename` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_TARGET: rights = 131072;\n /** The right to invoke `path_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_GET: rights = 262144;\n /** The right to change a file's size (there is no `path_filestat_set_size`). If `rights.PATH_OPEN` is set, includes the right to invoke `path_open` with `oflags.TRUNC`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_SIZE: rights = 524288;\n /** The right to invoke `path_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_TIMES: rights = 1048576;\n /** The right to invoke `fd_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_GET: rights = 2097152;\n /** The right to invoke `fd_filestat_set_size`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_SIZE: rights = 4194304;\n /** The right to invoke `fd_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_TIMES: rights = 8388608;\n /** The right to invoke `path_symlink`. */\n // @ts-ignore: decorator\n @inline\n export const RIGHT_PATH_SYMLINK: rights = 16777216;\n /** The right to invoke `path_remove_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_REMOVE_DIRECTORY: rights = 33554432;\n /** The right to invoke `path_unlink_file`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_UNLINK_FILE: rights = 67108864;\n /** If `rights.FD_READ` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_READ`. If `rights.FD_WRITE` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_WRITE`. */\n // @ts-ignore: decorator\n @inline\n export const POLL_FD_READWRITE: rights = 134217728;\n /** The right to invoke `sock_shutdown`. */\n // @ts-ignore: decorator\n @inline\n export const SOCK_SHUTDOWN: rights = 268435456;\n}\nexport type rights = u64;\n\n/** Flags returned by `sock_recv`. */\nexport namespace roflags {\n /** Message data has been truncated. */\n // @ts-ignore: decorator\n @inline\n export const DATA_TRUNCATED: roflags = 1;\n}\nexport type roflags = u16;\n\n/** Which channels on a socket to shut down. */\nexport namespace sdflags {\n /** Disables further receive operations. */\n // @ts-ignore: decorator\n @inline\n export const RD: sdflags = 1;\n /** Disables further send operations. */\n // @ts-ignore: decorator\n @inline\n export const WR: sdflags = 2;\n}\nexport type sdflags = u8;\n\n/** Flags provided to `sock_send`. */\nexport namespace siflags {\n // As there are currently no flags defined, it must be set to zero.\n}\nexport type siflags = u16;\n\n/** Signal condition. */\nexport namespace signal {\n /** Hangup. */\n // @ts-ignore: decorator\n @inline\n export const HUP: signal = 1;\n /** Terminate interrupt signal. */\n // @ts-ignore: decorator\n @inline\n export const INT: signal = 2;\n /** Terminal quit signal. */\n // @ts-ignore: decorator\n @inline\n export const QUIT: signal = 3;\n /** Illegal instruction. */\n // @ts-ignore: decorator\n @inline\n export const ILL: signal = 4;\n /** Trace/breakpoint trap. */\n // @ts-ignore: decorator\n @inline\n export const TRAP: signal = 5;\n /** Process abort signal. */\n // @ts-ignore: decorator\n @inline\n export const ABRT: signal = 6;\n /** Access to an undefined portion of a memory object. */\n // @ts-ignore: decorator\n @inline\n export const BUS: signal = 7;\n /** Erroneous arithmetic operation. */\n // @ts-ignore: decorator\n @inline\n export const FPE: signal = 8;\n /** Kill. */\n // @ts-ignore: decorator\n @inline\n export const KILL: signal = 9;\n /** User-defined signal 1. */\n // @ts-ignore: decorator\n @inline\n export const USR1: signal = 10;\n /** Invalid memory reference. */\n // @ts-ignore: decorator\n @inline\n export const SEGV: signal = 11;\n /** User-defined signal 2. */\n // @ts-ignore: decorator\n @inline\n export const USR2: signal = 12;\n /** Write on a pipe with no one to read it. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: signal = 13;\n /** Alarm clock. */\n // @ts-ignore: decorator\n @inline\n export const ALRM: signal = 14;\n /** Termination signal. */\n // @ts-ignore: decorator\n @inline\n export const TERM: signal = 15;\n /** Child process terminated, stopped, or continued. */\n // @ts-ignore: decorator\n @inline\n export const CHLD: signal = 16;\n /** Continue executing, if stopped. */\n // @ts-ignore: decorator\n @inline\n export const CONT: signal = 17;\n /** Stop executing. */\n // @ts-ignore: decorator\n @inline\n export const STOP: signal = 18;\n /** Terminal stop signal. */\n // @ts-ignore: decorator\n @inline\n export const TSTP: signal = 19;\n /** Background process attempting read. */\n // @ts-ignore: decorator\n @inline\n export const TTIN: signal = 20;\n /** Background process attempting write. */\n // @ts-ignore: decorator\n @inline\n export const TTOU: signal = 21;\n /** High bandwidth data is available at a socket. */\n // @ts-ignore: decorator\n @inline\n export const URG: signal = 22;\n /** CPU time limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XCPU: signal = 23;\n /** File size limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XFSZ: signal = 24;\n /** Virtual timer expired. */\n // @ts-ignore: decorator\n @inline\n export const VTALRM: signal = 25;\n // @ts-ignore: decorator\n @inline\n export const PROF: signal = 26;\n // @ts-ignore: decorator\n @inline\n export const WINCH: signal = 27;\n // @ts-ignore: decorator\n @inline\n export const POLL: signal = 28;\n // @ts-ignore: decorator\n @inline\n export const PWR: signal = 29;\n /** Bad system call. */\n // @ts-ignore: decorator\n @inline\n export const SYS: signal = 30;\n}\nexport type signal = u8;\n\n/** Flags determining how to interpret the timestamp provided in `subscription_t::u.clock.timeout. */\nexport namespace subclockflags {\n /** If set, treat the timestamp provided in `clocksubscription` as an absolute timestamp. */\n // @ts-ignore: decorator\n @inline\n export const ABSTIME: subclockflags = 1;\n}\nexport type subclockflags = u16;\n\n/** Subscription to an event. */\n@unmanaged export abstract class subscription {\n /** User-provided value that is attached to the subscription. */\n userdata: userdata;\n /** The type of the event to which to subscribe. */\n type: eventtype;\n private __padding0: u32;\n}\n\n/* Subscription to an event of type `eventtype.CLOCK`.**/\n@unmanaged export class clocksubscription extends subscription {\n /** The user-defined unique identifier of the clock. */\n identifier: userdata;\n /** The clock against which to compare the timestamp. */\n clock_id: clockid;\n /** The absolute or relative timestamp. */\n timeout: timestamp;\n /** The amount of time that the implementation may wait additionally to coalesce with other events. */\n precision: timestamp;\n /** Flags specifying whether the timeout is absolute or relative. */\n flags: subclockflags;\n private __padding1: u32;\n}\n\n/* Subscription to an event of type `eventtype.FD_READ` or `eventtype.FD_WRITE`.**/\n@unmanaged export class fdsubscription extends subscription {\n /** The file descriptor on which to wait for it to become ready for reading or writing. */\n fd: fd;\n}\n\n/** Timestamp in nanoseconds. */\nexport type timestamp = u64;\n\n/** User-provided value that may be attached to objects that is retained when extracted from the implementation. */\nexport type userdata = u64;\n\n/** The position relative to which to set the offset of the file descriptor. */\nexport namespace whence {\n /** Seek relative to current position. */\n // @ts-ignore: decorator\n @inline\n export const CUR: whence = 0;\n /** Seek relative to end-of-file. */\n // @ts-ignore: decorator\n @inline\n export const END: whence = 1;\n /** Seek relative to start-of-file. */\n // @ts-ignore: decorator\n @inline\n export const SET: whence = 2;\n}\nexport type whence = u8;\n","bindings/wasi":'export * from "./wasi_unstable";\n',builtins:'// @ts-ignore: decorator\n@builtin @inline\nexport const NaN: f64 = 0 / 0;\n\n// @ts-ignore: decorator\n@builtin @inline\nexport const Infinity: f64 = 1 / 0;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isInteger(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFloat(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isBoolean(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isSigned(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isReference(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isString(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArray(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArrayLike(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFunction(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isNullable(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isDefined(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isConstant(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isManaged(value?: T): bool;\n\nexport function isNaN(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value != value;\n}\n\nexport function isFinite(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value - value == 0;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function clz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ctz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function popcnt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotl(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotr(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function abs(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function max(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function min(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ceil(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function floor(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function copysign(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function nearest(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function reinterpret(value: number): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sqrt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function trunc(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function load(offset: usize, immOffset?: usize, immAlign?: usize): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function store(offset: usize, value: void, immOffset?: usize, immAlign?: usize): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sizeof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function alignof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function offsetof(fieldName?: string): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function idof(): u32;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function unreachable(): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function changetype(value: void): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function assert(isTrueish: T, message?: string): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function unchecked(expr: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_indirect(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_direct(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function instantiate(...args: void[]): T;\n\nexport namespace atomic {\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: T, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n\n // @ts-ignore: decorator\n @builtin\n export declare function notify(ptr: usize, count: i32): i32;\n}\n\n// @ts-ignore: decorator\n@lazy\nexport const enum AtomicWaitResult {\n OK = 0,\n NOT_EQUAL = 1,\n TIMED_OUT = 2\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8(value: void): i8;\n\nexport namespace i8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i8 = -128;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i8 = 127;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16(value: void): i16;\n\nexport namespace i16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i16 = -32768;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i16 = 32767;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32(value: void): i32;\n\nexport namespace i32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i32 = -2147483648;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i32 = 2147483647;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f32(value: f32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64(value: void): i64;\n\nexport namespace i64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i64 = -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i64 = 9223372036854775807;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f64(value: f64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw32 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isize(value: void): isize;\n\nexport namespace isize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: isize = sizeof() == sizeof()\n ? -2147483648\n : -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: isize = sizeof() == sizeof()\n ? 2147483647\n : 9223372036854775807;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u8(value: void): u8;\n\nexport namespace u8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u8 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u8 = 255;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u16(value: void): u16;\n\nexport namespace u16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u16 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u16 = 65535;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u32(value: void): u32;\n\nexport namespace u32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u32 = 4294967295;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u64(value: void): u64;\n\nexport namespace u64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u64 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u64 = 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function usize(value: void): usize;\n\nexport namespace usize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: usize = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: usize = sizeof() == sizeof()\n ? 4294967295\n : 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function bool(value: void): bool;\n\nexport namespace bool {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: bool = false;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: bool = true;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32(value: void): f32;\n\nexport namespace f32 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x34000000); // 0x1p-23f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x00000001); // 0x0.000001p+0f\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7F7FFFFF); // 0x1.fffffep+127f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x00800000); // 0x1p-126f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f32 = -16777215;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f32 = 16777215;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f32, y: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i32(value: i32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f32): f32;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64(value: void): f64;\n\nexport namespace f64 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x3CB0000000000000); // 0x1p-52\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x0000000000000001); // 0x0.0000000000001p+0\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7FEFFFFFFFFFFFFF); // 0x1.fffffffffffffp+1023\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x0010000000000000); // 0x1p-1022\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f64 = -9007199254740991;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f64 = 9007199254740991;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f64, y: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i64(value: i64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f64): f64;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function v128(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace v128 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128; // except i64\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function not(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function bitselect(v1: v128, v2: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8x16(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace i8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\n\nexport namespace i16x8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\n\nexport namespace i32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f32x4_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f32x4_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64x2(a: i64, b: i64): v128;\n\nexport namespace i64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f64x2_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f64x2_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\n\nexport namespace f32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i32x4(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i32x4(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64x2(a: f64, b: f64): v128;\n\nexport namespace f64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i64x2(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i64x2(a: v128): v128;\n}\n\nexport namespace v8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(\n a: v128, b: v128,\n l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8,\n l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8\n ): v128;\n}\n\n// @ts-ignore: decorator\n@external("env", "abort")\ndeclare function abort(\n message?: string | null,\n fileName?: string | null,\n lineNumber?: u32,\n columnNumber?: u32\n): void;\n\n// @ts-ignore: decorator\n@external("env", "trace")\ndeclare function trace(\n message: string,\n n?: i32,\n a0?: f64,\n a1?: f64,\n a2?: f64,\n a3?: f64,\n a4?: f64\n): void;\n',dataview:'import { BLOCK_MAXSIZE } from "./rt/common";\nimport { ArrayBuffer } from "./arraybuffer";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH } from "./util/error";\n\n// TODO: there is probably a smarter way to check byteOffset for accesses larger than 1 byte\n\nexport class DataView {\n\n private data: ArrayBuffer;\n private dataStart: usize;\n private dataLength: i32;\n\n constructor(\n buffer: ArrayBuffer,\n byteOffset: i32 = 0,\n byteLength: i32 = buffer.byteLength\n ) {\n if (\n i32(byteLength > BLOCK_MAXSIZE) |\n i32(byteOffset + byteLength > buffer.byteLength)\n ) throw new RangeError(E_INVALIDLENGTH);\n this.data = buffer; // retains\n var dataStart = changetype(buffer) + byteOffset;\n this.dataStart = dataStart;\n this.dataLength = byteLength;\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getInt8(byteOffset: i32): i8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getInt32(byteOffset: i32, littleEndian: boolean = false): i32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint8(byteOffset: i32): u8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint32(byteOffset: i32, littleEndian: boolean = false): u32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setInt8(byteOffset: i32, value: i8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint8(byteOffset: i32, value: u8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n // Non-standard additions that make sense in WebAssembly, but won\'t work in JS:\n\n getInt64(byteOffset: i32, littleEndian: boolean = false): i64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i64 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint64(byteOffset: i32, littleEndian: boolean = false): u64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n toString(): string {\n return "[object DataView]";\n }\n}\n',date:'import {\n UTC as Date_UTC,\n now as Date_now\n} from "./bindings/Date";\n\nexport class Date {\n\n @inline static UTC(\n year: i32,\n month: i32 = 0,\n day: i32 = 1,\n hour: i32 = 0,\n minute: i32 = 0,\n second: i32 = 0,\n millisecond: i64 = 0\n ): i64 {\n return Date_UTC(year, month, day, hour, minute, second, millisecond);\n }\n\n @inline static now(): i64 {\n return Date_now();\n }\n\n private value: i64;\n\n constructor(value: i64) {\n this.value = value;\n }\n\n getTime(): i64 {\n return this.value;\n }\n\n setTime(value: i64): i64 {\n this.value = value;\n return value;\n }\n}\n',diagnostics:"// @ts-ignore: decorator\n@builtin\nexport declare function ERROR(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function WARNING(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function INFO(message?: string): void;\n",error:'export class Error {\n\n name: string = "Error";\n stack: string = ""; // TODO\n\n constructor(\n public message: string = ""\n ) {}\n\n toString(): string {\n var message = this.message;\n return message.length\n ? this.name + ": " + message\n : this.name;\n }\n}\n\nexport class RangeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "RangeError";\n }\n}\n\nexport class TypeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "TypeError";\n }\n}\n\nexport class SyntaxError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "SyntaxError";\n }\n}\n',fixedarray:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_HOLEYARRAY } from "./util/error";\n\n// NOTE: DO NOT USE YET!\n\n// TODO: FixedArray with S being the static size, i.e. `new FixedArray`.\n// Then hard-wire this special type to the compiler and do static length checks instead :)\n\nexport class FixedArray {\n [key: number]: T;\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n var outSize = length << alignof();\n var out = __alloc(outSize, idof>());\n memory.fill(out, 0, outSize);\n return changetype>(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >>> alignof();\n }\n\n @operator("[]") private __get(index: i32): T {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n this.__unchecked_set(index, value);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(changetype(this) + (index << alignof()));\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = changetype(this) + (index << alignof());\n let oldValue = load(offset);\n if (changetype(value) != oldValue) {\n store(offset, __retain(changetype(value)));\n __release(changetype(oldValue));\n }\n } else {\n store(changetype(this) + (index << alignof()), value);\n }\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = changetype(this);\n let end = cur + changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n }\n}\n',heap:"// @ts-ignore: decorator\n@builtin\nexport declare const HEAP_BASE: usize;\n",iterator:"export abstract class Iterable {\n // ?\n}\n\n@sealed\nexport abstract class Iterator {\n\n // private constructor(iterable: Iterable) {\n // }\n\n // TODO: these need to evaluate the classId at the respective reference in order to obtain the\n // next value, i.e. arrays work differently than maps. we'd then have:\n //\n // ╒═══════════════════ Iterator layout (32-bit) ══════════════════╕\n // 3 2 1\n // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n // ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n // │ index │\n // ├─────────────────────────────────────────────────────────┬───┬─┤\n // │ reference │ 0 │D│\n // └─────────────────────────────────────────────────────────┴───┴─┘\n // D: Done flag\n\n // get value(this: u64): T {\n // ?\n // }\n\n // next(this: u64): Iterator {\n // ?\n // }\n\n done(this: u64): bool {\n return (this & 1);\n }\n}\n",map:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash map based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a map entry. */\n@unmanaged class MapEntry {\n key: K;\n value: V;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K/V is <= 32-bits\n const maxkv = sizeof() > sizeof() ? sizeof() : sizeof();\n const align = (maxkv > sizeof() ? maxkv : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Map {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // MapEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() {\n this.clear();\n }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): MapEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n get(key: K): V {\n var entry = this.find(key, HASH(key));\n return entry ? entry.value : unreachable();\n }\n\n set(key: K, value: V): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (entry) {\n if (isManaged()) {\n let oldRef = changetype(entry.value);\n if (changetype(value) != oldRef) {\n entry.value = changetype(__retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n entry.value = value;\n }\n } else {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n let entries = this.entries;\n entry = changetype>(changetype(entries) + this.entriesOffset++ * ENTRY_SIZE());\n // link with the map\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n entry.value = isManaged()\n ? changetype(__retain(changetype(value)))\n : value;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key));\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key));\n if (isManaged()) __release(changetype(entry.value));\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr);\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr);\n newEntry.key = oldEntry.key;\n newEntry.value = oldEntry.value;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Map]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged() || isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n if (isManaged()) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n if (isManaged()) {\n let val = changetype(entry.value);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',math:'import * as JSMath from "./bindings/Math";\nexport { JSMath };\n\nimport {\n abs as builtin_abs,\n ceil as builtin_ceil,\n clz as builtin_clz,\n copysign as builtin_copysign,\n floor as builtin_floor,\n max as builtin_max,\n min as builtin_min,\n sqrt as builtin_sqrt,\n trunc as builtin_trunc\n} from "./builtins";\n\n// SUN COPYRIGHT NOTICE\n//\n// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n// Developed at SunPro, a Sun Microsystems, Inc. business.\n// Permission to use, copy, modify, and distribute this software\n// is freely granted, provided that this notice is preserved.\n//\n// Applies to all functions marked with a comment referring here.\n\n// TODO: sin, cos, tan for Math namespace\n\n/** @internal */\nfunction R(z: f64): f64 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3FC5555555555555), // 1.66666666666666657415e-01\n pS1 = reinterpret(0xBFD4D61203EB6F7D), // -3.25565818622400915405e-01\n pS2 = reinterpret(0x3FC9C1550E884455), // 2.01212532134862925881e-01\n pS3 = reinterpret(0xBFA48228B5688F3B), // -4.00555345006794114027e-02\n pS4 = reinterpret(0x3F49EFE07501B288), // 7.91534994289814532176e-04\n pS5 = reinterpret(0x3F023DE10DFDF709), // 3.47933107596021167570e-05\n qS1 = reinterpret(0xC0033A271C8A2D4B), // -2.40339491173441421878e+00\n qS2 = reinterpret(0x40002AE59C598AC8), // 2.02094576023350569471e+00\n qS3 = reinterpret(0xBFE6066C1B8D0159), // -6.88283971605453293030e-01\n qS4 = reinterpret(0x3FB3B8C5B12E9282); // 7.70381505559019352791e-02\n var p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n var q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2.c\n k = 2043,\n kln2 = reinterpret(0x40962066151ADD8B); // 0x1.62066151add8bp+10\n var scale = reinterpret(((0x3FF + k / 2) << 20) << 32);\n return NativeMath.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@lazy\nvar random_seeded = false;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_32: u32;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_32: u32;\n\nfunction murmurHash3(h: u64): u64 { // Force all bits of a hash block to avalanche\n h ^= h >> 33; // see: https://github.com/aappleby/smhasher\n h *= 0xFF51AFD7ED558CCD;\n h ^= h >> 33;\n h *= 0xC4CEB9FE1A85EC53;\n h ^= h >> 33;\n return h;\n}\n\nfunction splitMix32(h: u32): u32 {\n h += 0x6D2B79F5;\n h = (h ^ (h >> 15)) * (h | 1);\n h ^= h + (h ^ (h >> 7)) * (h | 61);\n return h ^ (h >> 14);\n}\n\nexport namespace NativeMath {\n\n // @ts-ignore: decorator\n @lazy\n export const E = reinterpret(0x4005BF0A8B145769); // 2.7182818284590452354\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = reinterpret(0x3FE62E42FEFA39EF); // 0.69314718055994530942\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = reinterpret(0x40026BB1BBB55516); // 2.30258509299404568402\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = reinterpret(0x3FF71547652B82FE); // 1.4426950408889634074\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = reinterpret(0x3FDBCB7B1526E50E); // 0.43429448190325182765\n\n // @ts-ignore: decorator\n @lazy\n export const PI = reinterpret(0x400921FB54442D18); // 3.14159265358979323846\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = reinterpret(0x3FE6A09E667F3BCD); // 0.70710678118654752440\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = reinterpret(0x3FF6A09E667F3BCD); // 1.41421356237309504880\n\n // @ts-ignore: decorator\n @inline export function abs(x: f64): f64 {\n return builtin_abs(x);\n }\n\n export function acos(x: f64): f64 { // see: musl/src/math/acos.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix <= 0x3C600000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * R(x * x)));\n }\n var s: f64, w: f64, z: f64;\n if (hx >> 31) {\n // z = (1.0 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = R(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1.0 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n var df = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n var c = (z - df * df) / (s + df);\n w = R(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f64): f64 { // see: musl/src/math/acosh.c\n const s = reinterpret(0x3FE62E42FEFA39EF);\n var e = reinterpret(x) >> 52 & 0x7FF;\n if (e < 0x3FF + 1) return log1p(x - 1 + builtin_sqrt((x - 1) * (x - 1) + 2 * (x - 1)));\n if (e < 0x3FF + 26) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f64): f64 { // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) return x * pio2_hi + Ox1p_120f;\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix < 0x3E500000 && ix >= 0x00100000) return x;\n return x + x * R(x * x);\n }\n // var z = (1.0 - builtin_abs(x)) * 0.5;\n var z = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z);\n var r = R(z);\n if (ix >= 0x3FEF3333) x = pio2_hi - (2 * (s + s * r) - pio2_lo);\n else {\n let f = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n let c = (z - f * f) / (s + f);\n x = 0.5 * pio2_hi - (2 * s * r - (pio2_lo - 2 * c) - (0.5 * pio2_hi - 2 * f));\n }\n if (hx >> 31) return -x;\n return x;\n }\n\n export function asinh(x: f64): f64 { // see: musl/src/math/asinh.c\n const c = reinterpret(0x3FE62E42FEFA39EF); // 0.693147180559945309417232121458176568\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var y = reinterpret(u & 0x7FFFFFFFFFFFFFFF);\n if (e >= 0x3FF + 26) y = log(y) + c;\n else if (e >= 0x3FF + 1) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (e >= 0x3FF - 26) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f64): f64 { // see musl/src/math/atan.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3FDDAC670561BB4F), // 4.63647609000806093515e-01\n atanhi1 = reinterpret(0x3FE921FB54442D18), // 7.85398163397448278999e-01\n atanhi2 = reinterpret(0x3FEF730BD281F69B), // 9.82793723247329054082e-01\n atanhi3 = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n atanlo0 = reinterpret(0x3C7A2B7F222F65E2), // 2.26987774529616870924e-17\n atanlo1 = reinterpret(0x3C81A62633145C07), // 3.06161699786838301793e-17\n atanlo2 = reinterpret(0x3C7007887AF0CBBD), // 1.39033110312309984516e-17\n atanlo3 = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n aT0 = reinterpret(0x3FD555555555550D), // 3.33333333333329318027e-01\n aT1 = reinterpret(0xBFC999999998EBC4), // -1.99999999998764832476e-01\n aT2 = reinterpret(0x3FC24924920083FF), // 1.42857142725034663711e-01\n aT3 = reinterpret(0xBFBC71C6FE231671), // -1.11111104054623557880e-01,\n aT4 = reinterpret(0x3FB745CDC54C206E), // 9.09088713343650656196e-02\n aT5 = reinterpret(0xBFB3B0F2AF749A6D), // -7.69187620504482999495e-02\n aT6 = reinterpret(0x3FB10D66A0D03D51), // 6.66107313738753120669e-02\n aT7 = reinterpret(0xBFADDE2D52DEFD9A), // -5.83357013379057348645e-02\n aT8 = reinterpret(0x3FA97B4B24760DEB), // 4.97687799461593236017e-02\n aT9 = reinterpret(0xBFA2B4442C6A6C2F), // -3.65315727442169155270e-02\n aT10 = reinterpret(0x3F90AD3AE322DA11), // 1.62858201153657823623e-02\n Ox1p_120f = reinterpret(0x03800000);\n var ix = (reinterpret(x) >> 32);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f64;\n if (ix >= 0x44100000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3FDC0000) {\n if (ix < 0x3E400000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3FF30000) {\n if (ix < 0x3FE60000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x40038000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * (aT4 + w * (aT6 + w * (aT8 + w * aT10)))));\n var s2 = w * (aT1 + w * (aT3 + w * (aT5 + w * (aT7 + w * aT9))));\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f64): f64 { // see: musl/src/math/atanh.c\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var s = u >> 63;\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n if (e < 0x3FF - 1) {\n if (e >= 0x3FF - 32) y = 0.5 * log1p(2 * y + 2 * y * y / (1 - y));\n } else {\n y = 0.5 * log1p(2 * (y / (1 - y)));\n }\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f64, x: f64): f64 { // see: musl/src/math/atan2.c and SUN COPYRIGHT NOTICE above\n const pi_lo = reinterpret(0x3CA1A62633145C07); // 1.2246467991473531772E-16\n if (isNaN(x) || isNaN(y)) return x + y;\n var u = reinterpret(x);\n var ix = (u >> 32);\n var lx = u;\n u = reinterpret(y);\n var iy = (u >> 32);\n var ly = u;\n if ((ix - 0x3FF00000 | lx) == 0) return atan(y);\n var m = ((iy >> 31) & 1) | ((ix >> 30) & 2);\n ix = ix & 0x7FFFFFFF;\n iy = iy & 0x7FFFFFFF;\n if ((iy | ly) == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n if ((ix | lx) == 0) return m & 1 ? -PI / 2 : PI / 2;\n if (ix == 0x7FF00000) {\n if (iy == 0x7FF00000) {\n switch (m) {\n case 0: return PI / 4;\n case 1: return -PI / 4;\n case 2: return 3 * PI / 4;\n case 3: return -3 * PI / 4;\n }\n } else {\n switch (m) {\n case 0: return 0.0;\n case 1: return -0.0;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n }\n var z: f64;\n if (ix + (64 << 20) < iy || iy == 0x7FF00000) return m & 1 ? -PI / 2 : PI / 2;\n if ((m & 2) && iy + (64 << 20) < ix) z = 0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return PI - (z - pi_lo);\n case 3: return (z - pi_lo) - PI;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f64): f64 { // see: musl/src/math/cbrt.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 715094163,\n B2 = 696219795,\n P0 = reinterpret(0x3FFE03E60F61E692), // 1.87595182427177009643\n P1 = reinterpret(0xBFFE28E092F02420), // -1.88497979543377169875\n P2 = reinterpret(0x3FF9F1604A49D6C2), // 1.621429720105354466140\n P3 = reinterpret(0xBFE844CBBEE751D9), // -0.758397934778766047437\n P4 = reinterpret(0x3FC2B000D4E4EDD7), // 0.145996192886612446982\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32) & 0x7FFFFFFF;\n if (hx >= 0x7FF00000) return x + x;\n if (hx < 0x00100000) {\n u = reinterpret(x * Ox1p54);\n hx = (u >> 32) & 0x7FFFFFFF;\n if (hx == 0) return x;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 1 << 63;\n u |= hx << 32;\n var t = reinterpret(u);\n var r = (t * t) * (t / x);\n t = t * ((P0 + r * (P1 + r * P2)) + ((r * r) * r) * (P3 + r * P4));\n t = reinterpret((reinterpret(t) + 0x80000000) & 0xFFFFFFFFC0000000);\n var s = t * t;\n r = x / s;\n r = (r - t) / (2 * t + r);\n t = t + t * r;\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f64): f64 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f64): f64 {\n if (!isFinite(x)) return 32;\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function cosh(x: f64): f64 { // see: musl/src/math/cosh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n x = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w < 0x3FE62E42) {\n if (w < 0x3FF00000 - (26 << 20)) return 1;\n t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (w < 0x40862E42) {\n t = exp(x);\n return 0.5 * (t + 1 / t);\n }\n t = expo2(x);\n return t;\n }\n\n export function exp(x: f64): f64 { // see: musl/src/math/exp.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n overflow = reinterpret(0x40862E42FEFA39EF), // 709.782712893383973096\n underflow = reinterpret(0xC0874910D52D3051), // -745.13321910194110842\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var hx = (reinterpret(x) >> 32);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x4086232B) {\n if (isNaN(x)) return x;\n if (x > overflow) return x * Ox1p1023;\n if (x < underflow) return 0;\n }\n var hi: f64, lo: f64 = 0;\n var k = 0;\n if (hx > 0x3FD62E42) {\n if (hx >= 0x3FF0A2B2) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x3E300000) {\n hi = x;\n } else return 1.0 + x;\n var xs = x * x;\n // var c = x - xp2 * (P1 + xp2 * (P2 + xp2 * (P3 + xp2 * (P4 + xp2 * P5))));\n var xq = xs * xs;\n var c = x - (xs * P1 + xq * ((P2 + xs * P3) + xq * (P4 + xs * P5)));\n var y = 1.0 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f64): f64 { // see: musl/src/math/expm1.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x40862E42FEFA39EF), // 7.09782712893383973096e+02\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n Q1 = reinterpret(0xBFA11111111110F4), // -3.33333333333331316428e-02\n Q2 = reinterpret(0x3F5A01A019FE5585), // 1.58730158725481460165e-03\n Q3 = reinterpret(0xBF14CE199EAADBB7), // -7.93650757867487942473e-05\n Q4 = reinterpret(0x3ED0CFCA86E65239), // 4.00821782732936239552e-06\n Q5 = reinterpret(0xBE8AFDB76E09C32D), // -2.01099218183624371326e-07\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32 & 0x7FFFFFFF);\n var k = 0, sign_ = (u >> 63);\n if (hx >= 0x4043687A) {\n if (isNaN(x)) return x;\n if (sign_) return -1;\n if (x > o_threshold) return x * Ox1p1023;\n }\n var c = 0.0, t: f64;\n if (hx > 0x3FD62E42) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3FF0A2B2\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x3C900000) return x;\n var hfx = 0.5 * x;\n var hxs = x * hfx;\n // var r1 = 1.0 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));\n var hxq = hxs * hxs;\n var r1 = (1.0 + hxs * Q1) + hxq * ((Q2 + hxs * Q3) + hxq * (Q4 + hxs * Q5));\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x3FF + k) << 52;\n var twopk = reinterpret(u);\n var y: f64;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 1024) y = y * 2.0 * Ox1p1023;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x3FF - k) << 52;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f64): f64 {\n return builtin_floor(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f64): f32 {\n return x;\n }\n\n export function hypot(x: f64, y: f64): f64 { // see: musl/src/math/hypot.c\n const\n SPLIT = reinterpret(0x41A0000000000000) + 1, // 0x1p27 + 1\n Ox1p700 = reinterpret(0x6BB0000000000000),\n Ox1p_700 = reinterpret(0x1430000000000000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFFFFFFFFFF;\n uy &= 0x7FFFFFFFFFFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n var ex = (ux >> 52);\n var ey = (uy >> 52);\n y = reinterpret(uy);\n if (ey == 0x7FF) return y;\n x = reinterpret(ux);\n if (ex == 0x7FF || uy == 0) return x;\n if (ex - ey > 64) return x + y;\n var z = 1.0;\n if (ex > 0x3FF + 510) {\n z = Ox1p700;\n x *= Ox1p_700;\n y *= Ox1p_700;\n } else if (ey < 0x3FF - 450) {\n z = Ox1p_700;\n x *= Ox1p700;\n y *= Ox1p700;\n }\n var c = x * SPLIT;\n var h = x - c + c;\n var l = x - h;\n var hx = x * x;\n var lx = h * h - hx + (2 * h + l) * l;\n c = y * SPLIT;\n h = y - c + c;\n l = y - h;\n var hy = y * y;\n var ly = h * h - hy + (2 * h + l) * l;\n return z * builtin_sqrt(ly + lx + hy + hx);\n }\n\n export function imul(x: f64, y: f64): f64 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f64): f64 { // see: musl/src/math/log.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f64): f64 { // see: musl/src/math/log10.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3FDBCB7B15200000), // 4.34294481878168880939e-01\n ivln10lo = reinterpret(0x3DBB9438CA9AADD5), // 2.50829467116452752298e-11\n log10_2hi = reinterpret(0x3FD34413509F6000), // 3.01029995663611771306e-01\n log10_2lo = reinterpret(0x3D59FEF311F12B36), // 3.69423907715893078616e-13\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln10hi;\n var dk = k;\n var y = dk * log10_2hi;\n var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n return val_lo + w;\n }\n\n export function log1p(x: f64): f64 { // see: musl/src/math/log1p.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244); // 1.479819860511658591e-01\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 1;\n var c = 0.0, f = 0.0;\n if (hx < 0x3FDA827A || (hx >> 31)) {\n if (hx >= 0xBFF00000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (hx << 1 < 0x3CA00000 << 1) return x;\n if (hx <= 0xBFD2BEC4) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (hx >= 0x7FF00000) return x;\n if (k) {\n u = reinterpret(1 + x);\n let hu = (u >> 32);\n hu += 0x3FF00000 - 0x3FE6A09E;\n k = (hu >> 20) - 0x3FF;\n if (k < 54) {\n let uf = reinterpret(u);\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n hu = (hu & 0x000FFFFF) + 0x3FE6A09E;\n u = hu << 32 | (u & 0xFFFFFFFF);\n f = reinterpret(u) - 1;\n }\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f64): f64 { // see: musl/src/math/log2.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FF7154765200000), // 1.44269504072144627571e+00\n ivln2lo = reinterpret(0x3DE705FC2EEFA200), // 1.67517131648865118353e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln2hi;\n var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;\n var y = k;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n val_hi = w;\n return val_lo + val_hi;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f64, value2: f64): f64 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f64, value2: f64): f64 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f64, y: f64): f64 { // see: musl/src/math/pow.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3FE2B80340000000), // 5.84962487220764160156e-01\n dp_l1 = reinterpret(0x3E4CFDEB43CFD006), // 1.35003920212974897128e-08\n two53 = reinterpret(0x4340000000000000), // 9007199254740992.0\n huge = reinterpret(0x7E37E43C8800759C), // 1e+300\n tiny = reinterpret(0x01A56E1FC2F8F359), // 1e-300\n L1 = reinterpret(0x3FE3333333333303), // 5.99999999999994648725e-01\n L2 = reinterpret(0x3FDB6DB6DB6FABFF), // 4.28571428578550184252e-01\n L3 = reinterpret(0x3FD55555518F264D), // 3.33333329818377432918e-01\n L4 = reinterpret(0x3FD17460A91D4101), // 2.72728123808534006489e-01\n L5 = reinterpret(0x3FCD864A93C9DB65), // 2.30660745775561754067e-01\n L6 = reinterpret(0x3FCA7E284A454EEF), // 2.06975017800338417784e-01\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n lg2 = reinterpret(0x3FE62E42FEFA39EF), // 6.93147180559945286227e-01\n lg2_h = reinterpret(0x3FE62E4300000000), // 6.93147182464599609375e-01\n lg2_l = reinterpret(0xBE205C610CA86C39), // -1.90465429995776804525e-09\n ovt = reinterpret(0x3C971547652B82FE), // 8.0085662595372944372e-017\n cp = reinterpret(0x3FEEC709DC3A03FD), // 9.61796693925975554329e-01\n cp_h = reinterpret(0x3FEEC709E0000000), // 9.61796700954437255859e-01\n cp_l = reinterpret(0xBE3E2FE0145B01F5), // -7.02846165095275826516e-09\n ivln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n ivln2_h = reinterpret(0x3FF7154760000000), // 1.44269502162933349609e+00\n ivln2_l = reinterpret(0x3E54AE0BF85DDF44), // 1.92596299112661746887e-08\n inv3 = reinterpret(0x3FD5555555555555); // 0.3333333333333333333333\n var u_ = reinterpret(x);\n var hx = (u_ >> 32);\n var lx = u_;\n u_ = reinterpret(y);\n var hy = (u_ >> 32);\n var ly = u_;\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if ((iy | ly) == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3FF00000 && lx == 0) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if ( // NaN if either arg is NaN\n ix > 0x7FF00000 || (ix == 0x7FF00000 && lx != 0) ||\n iy > 0x7FF00000 || (iy == 0x7FF00000 && ly != 0)\n ) return x + y;\n var yisint = 0, k: i32;\n if (hx < 0) {\n if (iy >= 0x43400000) yisint = 2;\n else if (iy >= 0x3FF00000) {\n k = (iy >> 20) - 0x3FF;\n let kcond = k > 20;\n let offset = select(52, 20, kcond) - k;\n let Ly = select(ly, iy, kcond);\n let jj = Ly >> offset;\n if ((jj << offset) == Ly) yisint = 2 - (jj & 1);\n }\n }\n if (ly == 0) {\n if (iy == 0x7FF00000) { // y is +-inf\n if (((ix - 0x3FF00000) | lx) == 0) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix >= 0x3FF00000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3FF00000) {\n if (hy >= 0) return x;\n return 1 / x;\n }\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3FE00000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n }\n var ax = builtin_abs(x), z: f64;\n if (lx == 0) {\n if (ix == 0 || ix == 0x7FF00000 || ix == 0x3FF00000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3FF00000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n } else if (yisint == 1) z = -z;\n }\n return z;\n }\n }\n var s = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) s = -1.0;\n }\n var t1: f64, t2: f64, p_h: f64, p_l: f64, r: f64, t: f64, u: f64, v: f64, w: f64;\n var j: i32, n: i32;\n if (iy > 0x41E00000) {\n if (iy > 0x43F00000) {\n if (ix <= 0x3FEFFFFF) return hy < 0 ? huge * huge : tiny * tiny;\n if (ix >= 0x3FF00000) return hy > 0 ? huge * huge : tiny * tiny;\n }\n if (ix < 0x3FEFFFFF) return hy < 0 ? s * huge * huge : s * tiny * tiny;\n if (ix > 0x3FF00000) return hy > 0 ? s * huge * huge : s * tiny * tiny;\n t = ax - 1.0;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = v - (t1 - u);\n } else {\n let ss: f64, s2: f64, s_h: f64, s_l: f64, t_h: f64, t_l: f64;\n n = 0;\n if (ix < 0x00100000) {\n ax *= two53;\n n -= 53;\n ix = (reinterpret(ax) >> 32);\n }\n n += (ix >> 20) - 0x3FF;\n j = ix & 0x000FFFFF;\n ix = j | 0x3FF00000;\n if (j <= 0x3988E) k = 0;\n else if (j < 0xBB67A) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00100000;\n }\n ax = reinterpret(reinterpret(ax) & 0xFFFFFFFF | (ix << 32));\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n ss = u * v;\n s_h = ss;\n s_h = reinterpret(reinterpret(s_h) & 0xFFFFFFFF00000000);\n t_h = reinterpret((((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18)) << 32);\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = ss * ss;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + ss);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n t_h = reinterpret(reinterpret(t_h) & 0xFFFFFFFF00000000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * ss;\n p_h = u + v;\n p_h = reinterpret(reinterpret(p_h) & 0xFFFFFFFF00000000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = ((z_h + z_l) + dp_h) + t;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n var y1 = y;\n y1 = reinterpret(reinterpret(y1) & 0xFFFFFFFF00000000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n u_ = reinterpret(z);\n j = (u_ >> 32);\n var i = u_;\n if (j >= 0x40900000) {\n if (((j - 0x40900000) | i) != 0) return s * huge * huge;\n if (p_l + ovt > z - p_h) return s * huge * huge;\n } else if ((j & 0x7FFFFFFF) >= 0x4090CC00) {\n if (((j - 0xC090CC00) | i) != 0) return s * tiny * tiny;\n if (p_l <= z - p_h) return s * tiny * tiny;\n }\n i = j & 0x7FFFFFFF;\n k = (i >> 20) - 0x3FF;\n n = 0;\n if (i > 0x3FE00000) {\n n = j + (0x00100000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 20) - 0x3FF;\n t = 0.0;\n t = reinterpret((n & ~(0x000FFFFF >> k)) << 32);\n n = ((n & 0x000FFFFF) | 0x00100000) >> (20 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n t = reinterpret(reinterpret(t) & 0xFFFFFFFF00000000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = (reinterpret(z) >> 32);\n j += n << 20;\n if ((j >> 20) <= 0) z = scalbn(z, n);\n else z = reinterpret(reinterpret(z) & 0xFFFFFFFF | (j << 32));\n return s * z;\n }\n\n export function seedRandom(value: i64): void {\n assert(value);\n random_seeded = true;\n random_state0_64 = murmurHash3(value);\n random_state1_64 = murmurHash3(~random_state0_64);\n random_state0_32 = splitMix32(value);\n random_state1_32 = splitMix32(random_state0_32);\n }\n\n export function random(): f64 { // see: v8/src/base/random-number-generator.cc\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n var s1 = random_state0_64;\n var s0 = random_state1_64;\n random_state0_64 = s0;\n s1 ^= s1 << 23;\n s1 ^= s1 >> 17;\n s1 ^= s0;\n s1 ^= s0 >> 26;\n random_state1_64 = s1;\n var r = ((s0 + s1) & 0x000FFFFFFFFFFFFF) | 0x3FF0000000000000;\n return reinterpret(r) - 1;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f64): f64 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f64): f64 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f64): bool {\n // In ECMAScript all NaN values are indistinguishable from each other\n // so we need handle NaN and negative NaN in similar way\n return ((reinterpret(x) >>> 63) & i32(x == x));\n }\n\n export function sin(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function sinh(x: f64): f64 { // see: musl/src/math/sinh.c\n var u = reinterpret(x) & 0x7FFFFFFFFFFFFFFF;\n var absx = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n var h = builtin_copysign(0.5, x);\n if (w < 0x40862E42) {\n t = expm1(absx);\n if (w < 0x3FF00000) {\n if (w < 0x3FF00000 - (26 << 20)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f64): f64 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function tanh(x: f64): f64 { // see: musl/src/math/tanh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w > 0x3FE193EA) {\n if (w > 0x40340000) {\n t = 1 - 0 / y;\n } else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (w > 0x3FD058AE) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (w >= 0x00100000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f64): f64 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f64, n: i32): f64 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbn.c\n const\n Ox1p53 = reinterpret(0x4340000000000000),\n Ox1p1023 = reinterpret(0x7FE0000000000000),\n Ox1p_1022 = reinterpret(0x0010000000000000);\n var y = x;\n if (n > 1023) {\n y *= Ox1p1023;\n n -= 1023;\n if (n > 1023) {\n y *= Ox1p1023;\n n = builtin_min(n - 1023, 1023);\n }\n } else if (n < -1022) {\n /* make sure final n < -53 to avoid double\n rounding in the subnormal range */\n y *= Ox1p_1022 * Ox1p53;\n n += 1022 - 53;\n if (n < -1022) {\n y *= Ox1p_1022 * Ox1p53;\n n = builtin_max(n + 1022 - 53, -1022);\n }\n }\n return y * reinterpret((0x3FF + n) << 52);\n }\n\n export function mod(x: f64, y: f64): f64 { // see: musl/src/math/fmod.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = ux >> 63;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 12);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 12;\n ux |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 52); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 11);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 52;\n ux |= ex << 52;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx << 63;\n return reinterpret(ux);\n }\n\n export function rem(x: f64, y: f64): f64 { // see: musl/src/math/remquo.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = (ux >> 63);\n if (uy << 1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n if (ux << 1 == 0) return x;\n var uxi = ux;\n if (!ex) {\n ex -= builtin_clz(uxi << 12);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 12;\n uxi |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n var q: u32 = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -60;\n else {\n let shift = builtin_clz(uxi << 11);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end:\n if (ex > 0) {\n uxi -= 1 << 52;\n uxi |= ex << 52;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // ++q;\n }\n return sx ? -x : x;\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar rempio2f_y: f64;\n\n// @ts-ignore: decorator\n@lazy\nconst PIO2_TABLE: u64[] = [\n 0xA2F9836E4E441529,\n 0xFC2757D1F534DDC0,\n 0xDB6295993C439041,\n 0xFE5163ABDEBBC561\n];\n\nfunction Rf(z: f32): f32 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3E2AAA75), // 1.6666586697e-01f\n pS1 = reinterpret(0xBD2F13BA), // -4.2743422091e-02f\n pS2 = reinterpret(0xBC0DD36B), // -8.6563630030e-03f\n qS1 = reinterpret(0xBF34E5AE); // -7.0662963390e-01f\n var p = z * (pS0 + z * (pS1 + z * pS2));\n var q: f32 = 1 + z * qS1;\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2f.c\n k = 235,\n kln2 = reinterpret(0x4322E3BC); // 0x1.45c778p+7f\n var scale = reinterpret((0x7F + (k >> 1)) << 23);\n return NativeMathf.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction pio2_large_quot(x: f32, u: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const coeff = reinterpret(0x3BF921FB54442D18); // π * 0x1p-65 = 8.51530395021638647334e-20\n const bits = PIO2_TABLE;\n\n var offset = (u >> 23) - 152;\n var index = offset >> 6;\n var shift = offset & 63;\n\n var b0 = unchecked(bits[index + 0]);\n var b1 = unchecked(bits[index + 1]);\n var lo: u64;\n\n if (shift > 32) {\n let b2 = unchecked(bits[index + 2]);\n lo = b2 >> (96 - shift);\n lo |= b1 << (shift - 32);\n } else {\n lo = b1 >> (32 - shift);\n }\n\n var hi = (b1 >> (64 - shift)) | (b0 << shift);\n var mantissa: u64 = (u & 0x007FFFFF) | 0x00800000;\n var product: u64 = mantissa * hi + (mantissa * lo >> 32);\n var r: i64 = product << 2;\n var q: i32 = ((product >> 62) + (r >>> 63));\n rempio2f_y = copysign(coeff, x) * r;\n return q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction rempio2f(x: f32, u: u32, sign: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const pi2hi = reinterpret(0x3FF921FB50000000); // 1.57079631090164184570\n const pi2lo = reinterpret(0x3E5110B4611A6263); // 1.58932547735281966916e-8\n const _2_pi = reinterpret(0x3FE45F306DC9C883); // 0.63661977236758134308\n\n if (u < 0x4DC90FDB) { /* π * 0x1p28 */\n let q = nearest(x * _2_pi);\n rempio2f_y = x - q * pi2hi - q * pi2lo;\n return q;\n }\n\n var q = pio2_large_quot(x, u);\n return select(-q, q, sign);\n}\n\n/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */\n// @ts-ignore: decorator\n@inline\nfunction sin_kernf(x: f64): f32 { // see: musl/tree/src/math/__sindf.c\n const S1 = reinterpret(0xBFC5555554CBAC77); // -0x15555554cbac77.0p-55\n const S2 = reinterpret(0x3F811110896EFBB2); // 0x111110896efbb2.0p-59\n const S3 = reinterpret(0xBF2A00F9E2CAE774); // -0x1a00f9e2cae774.0p-65\n const S4 = reinterpret(0x3EC6CD878C3B46A7); // 0x16cd878c3b46a7.0p-71\n\n var z = x * x;\n var w = z * z;\n var r = S3 + z * S4;\n var s = z * x;\n return ((x + s * (S1 + z * S2)) + s * w * r);\n}\n\n/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */\n// @ts-ignore: decorator\n@inline\nfunction cos_kernf(x: f64): f32 { // see: musl/tree/src/math/__cosdf.c\n const C0 = reinterpret(0xBFDFFFFFFD0C5E81); // -0x1ffffffd0c5e81.0p-54\n const C1 = reinterpret(0x3FA55553E1053A42); // 0x155553e1053a42.0p-57\n const C2 = reinterpret(0xBF56C087E80F1E27); // -0x16c087e80f1e27.0p-62\n const C3 = reinterpret(0x3EF99342E0EE5069); // 0x199342e0ee5069.0p-68\n\n var z = x * x;\n var w = z * z;\n var r = C2 + z * C3;\n return (((1 + z * C0) + w * C1) + (w * z) * r);\n}\n\n/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */\n// @ts-ignore: decorator\n@inline\nfunction tan_kernf(x: f64, odd: i32): f32 { // see: musl/tree/src/math/__tandf.c\n\n const T0 = reinterpret(0x3FD5554D3418C99F); /* 0x15554d3418c99f.0p-54 */\n const T1 = reinterpret(0x3FC112FD38999F72); /* 0x1112fd38999f72.0p-55 */\n const T2 = reinterpret(0x3FAB54C91D865AFE); /* 0x1b54c91d865afe.0p-57 */\n const T3 = reinterpret(0x3F991DF3908C33CE); /* 0x191df3908c33ce.0p-58 */\n const T4 = reinterpret(0x3F685DADFCECF44E); /* 0x185dadfcecf44e.0p-61 */\n const T5 = reinterpret(0x3F8362B9BF971BCD); /* 0x1362b9bf971bcd.0p-59 */\n\n var z = x * x;\n var r = T4 + z * T5;\n var t = T2 + z * T3;\n var w = z * z;\n var s = z * x;\n var u = T0 + z * T1;\n\n r = (x + s * u) + (s * w) * (t + w * r);\n return (odd ? -1 / r : r);\n}\n\nexport namespace NativeMathf {\n\n // @ts-ignore: decorator\n @lazy\n export const E = NativeMath.E;\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = NativeMath.LN2;\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = NativeMath.LN10;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = NativeMath.LOG2E;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = NativeMath.LOG10E;\n\n // @ts-ignore: decorator\n @lazy\n export const PI = NativeMath.PI;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = NativeMath.SQRT1_2;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = NativeMath.SQRT2;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_sin: f32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_cos: f32 = 0;\n\n // @ts-ignore: decorator\n @inline\n export function abs(x: f32): f32 {\n return builtin_abs(x);\n }\n\n export function acos(x: f32): f32 { // see: musl/src/math/acosf.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n pio2_lo = reinterpret(0x33A22168), // 7.5497894159e-08f\n Ox1p_120f = reinterpret(0x03800000);\n var hx = reinterpret(x);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3F800000) {\n if (ix == 0x3F800000) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3F000000) {\n if (ix <= 0x32800000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * Rf(x * x)));\n }\n var z: f32, w: f32, s: f32;\n if (hx >> 31) {\n // z = (1 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = Rf(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n hx = reinterpret(s);\n var df = reinterpret(hx & 0xFFFFF000);\n var c = (z - df * df) / (s + df);\n w = Rf(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f32): f32 { // see: musl/src/math/acoshf.c\n const s = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x);\n var a = u & 0x7FFFFFFF;\n if (a < 0x3F800000 + (1 << 23)) {\n let xm1 = x - 1;\n return log1p(xm1 + builtin_sqrt(xm1 * (xm1 + 2)));\n }\n if (a < 0x3F800000 + (12 << 23)) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f32): f32 { // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n const\n pio2 = reinterpret(0x3FC90FDB), // 1.570796326794896558e+00f\n Ox1p_120f = reinterpret(0x03800000);\n var sx = x;\n var hx = reinterpret(x) & 0x7FFFFFFF;\n if (hx >= 0x3F800000) {\n if (hx == 0x3F800000) return x * pio2 + Ox1p_120f;\n return 0 / (x - x);\n }\n if (hx < 0x3F000000) {\n if (hx < 0x39800000 && hx >= 0x00800000) return x;\n return x + x * Rf(x * x);\n }\n // var z: f32 = (1 - builtin_abs(x)) * 0.5;\n var z: f32 = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z); // sic\n x = (pio2 - 2 * (s + s * Rf(z)));\n return builtin_copysign(x, sx);\n }\n\n export function asinh(x: f32): f32 { // see: musl/src/math/asinhf.c\n const c = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x) & 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u >= 0x3F800000 + (12 << 23)) y = log(y) + c;\n else if (u >= 0x3F800000 + (1 << 23)) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (u >= 0x3F800000 - (12 << 23)) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f32): f32 { // see: musl/src/math/atanf.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3EED6338), // 4.6364760399e-01f\n atanhi1 = reinterpret(0x3F490FDA), // 7.8539812565e-01f\n atanhi2 = reinterpret(0x3F7B985E), // 9.8279368877e-01f\n atanhi3 = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n atanlo0 = reinterpret(0x31AC3769), // 5.0121582440e-09f\n atanlo1 = reinterpret(0x33222168), // 3.7748947079e-08f\n atanlo2 = reinterpret(0x33140FB4), // 3.4473217170e-08f\n atanlo3 = reinterpret(0x33A22168), // 7.5497894159e-08f\n aT0 = reinterpret(0x3EAAAAA9), // 3.3333328366e-01f\n aT1 = reinterpret(0xBE4CCA98), // -1.9999158382e-01f\n aT2 = reinterpret(0x3E11F50D), // 1.4253635705e-01f\n aT3 = reinterpret(0xBDDA1247), // -1.0648017377e-01f\n aT4 = reinterpret(0x3D7CAC25), // 6.1687607318e-02f\n Ox1p_120f = reinterpret(0x03800000);\n var ix = reinterpret(x);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f32;\n if (ix >= 0x4C800000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3EE00000) {\n if (ix < 0x39800000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3F980000) {\n if (ix < 0x3F300000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x401C0000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * aT4));\n var s2 = w * (aT1 + w * aT3);\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f32): f32 { // see: musl/src/math/atanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u < 0x3F800000 - (1 << 23)) {\n if (u >= 0x3F800000 - (32 << 23)) y = 0.5 * log1p(2 * y * (1.0 + y / (1 - y)));\n } else y = 0.5 * log1p(2 * (y / (1 - y)));\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f32, x: f32): f32 { // see: musl/src/math/atan2f.c and SUN COPYRIGHT NOTICE above\n const\n pi = reinterpret(0x40490FDB), // 3.1415927410e+00f\n pi_lo = reinterpret(0xB3BBBD2E); // -8.7422776573e-08f\n if (isNaN(x) || isNaN(y)) return x + y;\n var ix = reinterpret(x);\n var iy = reinterpret(y);\n if (ix == 0x3F800000) return atan(y);\n var m = (((iy >> 31) & 1) | ((ix >> 30) & 2));\n ix &= 0x7FFFFFFF;\n iy &= 0x7FFFFFFF;\n if (iy == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n if (ix == 0) return m & 1 ? -pi / 2 : pi / 2;\n if (ix == 0x7F800000) {\n if (iy == 0x7F800000) {\n switch (m) {\n case 0: return pi / 4;\n case 1: return -pi / 4;\n case 2: return 3 * pi / 4;\n case 3: return -3 * pi / 4;\n }\n } else {\n switch (m) {\n case 0: return 0;\n case 1: return -0;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n }\n if (ix + (26 << 23) < iy || iy == 0x7F800000) return m & 1 ? -pi / 2 : pi / 2;\n var z: f32;\n if ((m & 2) && iy + (26 << 23) < ix) z = 0.0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return pi - (z - pi_lo);\n case 3: return (z - pi_lo) - pi;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f32): f32 { // see: musl/src/math/cbrtf.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 709958130,\n B2 = 642849266,\n Ox1p24f = reinterpret(0x4B800000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n if (hx >= 0x7F800000) return x + x;\n if (hx < 0x00800000) {\n if (hx == 0) return x;\n u = reinterpret(x * Ox1p24f);\n hx = u & 0x7FFFFFFF;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 0x80000000;\n u |= hx;\n var t = reinterpret(u);\n var r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f32): f32 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f32): f32 {\n if (!isFinite(x)) return 32;\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f32): f32 { // see: musl/src/math/cosf.c\n const c1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const c2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const c3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const c4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n /* raise inexact if x != 0 */\n return 1;\n }\n return cos_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix > 0x4016cbe3) { /* |x| ~> 3π/4 */\n return -cos_kernf(sign ? x + c2pio2 : x - c2pio2);\n } else {\n return sign ? sin_kernf(x + c1pio2) : sin_kernf(c1pio2 - x);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix > 0x40afeddf) { /* |x| ~> 7π/4 */\n return cos_kernf(sign ? x + c4pio2 : x - c4pio2);\n } else {\n return sign ? sin_kernf(-x - c3pio2) : sin_kernf(x - c3pio2);\n }\n }\n }\n\n /* cos(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? sin_kernf(y) : cos_kernf(y);\n return (n + 1) & 2 ? -t : t;\n }\n\n export function cosh(x: f32): f32 { // see: musl/src/math/coshf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n x = reinterpret(u);\n if (u < 0x3F317217) {\n if (u < 0x3F800000 - (12 << 23)) return 1;\n let t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (u < 0x42B17217) {\n let t = exp(x);\n // return 0.5 * (t + 1 / t);\n return 0.5 * t + 0.5 / t;\n }\n return expo2f(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f32): f32 {\n return builtin_floor(x);\n }\n\n export function exp(x: f32): f32 { // see: musl/src/math/expf.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3F317200), // 6.9314575195e-1f\n ln2lo = reinterpret(0x35BFBE8E), // 1.4286067653e-6f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+0f\n P1 = reinterpret(0x3E2AAA8F), // 1.6666625440e-1f\n P2 = reinterpret(0xBB355215), // -2.7667332906e-3f\n Ox1p127f = reinterpret(0x7F000000);\n var hx = reinterpret(x);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x42AEAC50) {\n if (hx >= 0x42B17218) {\n if (!sign_) return x * Ox1p127f;\n else if (hx >= 0x42CFF1B5) return 0;\n }\n }\n var hi: f32, lo: f32;\n var k: i32;\n if (hx > 0x3EB17218) {\n if (hx > 0x3F851592) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x39000000) {\n k = 0;\n hi = x;\n lo = 0;\n } else {\n return 1 + x;\n }\n var xx = x * x;\n var c = x - xx * (P1 + xx * P2);\n var y: f32 = 1 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f32): f32 { // see: musl/src/math/expm1f.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x42B17180), // 8.8721679688e+01f\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00f\n Q1 = reinterpret(0xBD088868), // -3.3333212137e-02f\n Q2 = reinterpret(0x3ACF3010), // 1.5807170421e-03f\n Ox1p127f = reinterpret(0x7F000000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n var sign_ = (u >> 31);\n if (hx >= 0x4195B844) {\n if (hx > 0x7F800000) return x;\n if (sign_) return -1;\n if (x > o_threshold) {\n x *= Ox1p127f;\n return x;\n }\n }\n var c: f32 = 0.0, t: f32, k: i32;\n if (hx > 0x3EB17218) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3F851592\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x33000000) {\n return x;\n } else k = 0;\n var hfx: f32 = 0.5 * x;\n var hxs: f32 = x * hfx;\n var r1: f32 = 1.0 + hxs * (Q1 + hxs * Q2);\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x7F + k) << 23;\n var twopk = reinterpret(u);\n var y: f32;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 128) y = y * 2.0 * Ox1p127f;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x7F - k) << 23;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f32): f32 {\n return x;\n }\n\n export function hypot(x: f32, y: f32): f32 { // see: musl/src/math/hypotf.c\n const\n Ox1p90f = reinterpret(0x6C800000),\n Ox1p_90f = reinterpret(0x12800000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFF;\n uy &= 0x7FFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n x = reinterpret(ux);\n y = reinterpret(uy);\n if (uy == 0xFF << 23) return y;\n if (ux >= 0xFF << 23 || uy == 0 || ux - uy >= 25 << 23) return x + y;\n var z: f32 = 1;\n if (ux >= (0x7F + 60) << 23) {\n z = Ox1p90f;\n x *= Ox1p_90f;\n y *= Ox1p_90f;\n } else if (uy < (0x7F - 60) << 23) {\n z = Ox1p_90f;\n x *= Ox1p90f;\n y *= Ox1p90f;\n }\n return z * builtin_sqrt((x * x + y * y));\n }\n\n // @ts-ignore: decorator\n @inline\n export function imul(x: f32, y: f32): f32 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f32): f32 { // see: musl/src/math/logf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f\n Ox1p25f = reinterpret(0x4C000000);\n var u = reinterpret(x);\n var k = 0;\n if (u < 0x00800000 || (u >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (u >> 31) return (x - x) / 0;\n k -= 25;\n x *= Ox1p25f;\n u = reinterpret(x);\n } else if (u >= 0x7F800000) return x;\n else if (u == 0x3F800000) return 0;\n u += 0x3F800000 - 0x3F3504F3;\n k += (u >> 23) - 0x7F;\n u = (u & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(u);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f32): f32 { // see: musl/src/math/log10f.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3EDE6000), // 4.3432617188e-01f\n ivln10lo = reinterpret(0xB804EAD9), // -3.1689971365e-05f\n log10_2hi = reinterpret(0x3E9A2080), // 3.0102920532e-01f\n log10_2lo = reinterpret(0x355427DB), // 7.9034151668e-07f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n ix = reinterpret(hi);\n ix &= 0xFFFFF000;\n hi = reinterpret(ix);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;\n }\n\n export function log1p(x: f32): f32 { // see: musl/src/math/log1pf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26); // 0xf89e26.0p-26f, 0.24279078841f\n var ix = reinterpret(x);\n var c: f32 = 0, f: f32 = 0;\n var k: i32 = 1;\n if (ix < 0x3ED413D0 || (ix >> 31)) {\n if (ix >= 0xBF800000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (ix << 1 < 0x33800000 << 1) return x;\n if (ix <= 0xBE95F619) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (ix >= 0x7F800000) return x;\n if (k) {\n let uf: f32 = 1 + x;\n let iu = reinterpret(uf);\n iu += 0x3F800000 - 0x3F3504F3;\n k = (iu >> 23) - 0x7F;\n if (k < 25) {\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n iu = (iu & 0x007FFFFF) + 0x3F3504F3;\n f = reinterpret(iu) - 1;\n }\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f32): f32 { // see: musl/src/math/log2f.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FB8B000), // 1.4428710938e+00f\n ivln2lo = reinterpret(0xB9389AD4), // -1.7605285393e-04\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k: i32 = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n var u = reinterpret(hi);\n u &= 0xFFFFF000;\n hi = reinterpret(u);\n var lo: f32 = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + dk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f32, value2: f32): f32 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f32, value2: f32): f32 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f32, y: f32): f32 { // see: musl/src/math/powf.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3F15C000), // 5.84960938e-01f\n dp_l1 = reinterpret(0x35D1CFDC), // 1.56322085e-06f\n two24 = reinterpret(0x4B800000), // 16777216f\n huge = reinterpret(0x7149F2CA), // 1.0e+30f\n tiny = reinterpret(0x0DA24260), // 1.0e-30f\n L1 = reinterpret(0x3F19999A), // 6.0000002384e-01f\n L2 = reinterpret(0x3EDB6DB7), // 4.2857143283e-01f\n L3 = reinterpret(0x3EAAAAAB), // 3.3333334327e-01f\n L4 = reinterpret(0x3E8BA305), // 2.7272811532e-01f\n L5 = reinterpret(0x3E6C3255), // 2.3066075146e-01f\n L6 = reinterpret(0x3E53F142), // 2.0697501302e-01f\n P1 = reinterpret(0x3E2AAAAB), // 1.6666667163e-01f\n P2 = reinterpret(0xBB360B61), // -2.7777778450e-03f\n P3 = reinterpret(0x388AB355), // 6.6137559770e-05f\n P4 = reinterpret(0xB5DDEA0E), // -1.6533901999e-06f\n P5 = reinterpret(0x3331BB4C), // 4.1381369442e-08f\n lg2 = reinterpret(0x3F317218), // 6.9314718246e-01f\n lg2_h = reinterpret(0x3F317200), // 6.93145752e-01f\n lg2_l = reinterpret(0x35BFBE8C), // 1.42860654e-06f\n ovt = reinterpret(0x3338AA3C), // 4.2995665694e-08f\n cp = reinterpret(0x3F76384F), // 9.6179670095e-01\n cp_h = reinterpret(0x3F764000), // 9.6191406250e-01\n cp_l = reinterpret(0xB8F623C6), // -1.1736857402e-04\n ivln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00\n ivln2_h = reinterpret(0x3FB8AA00), // 1.4426879883e+00\n ivln2_l = reinterpret(0x36ECA570), // 7.0526075433e-06\n inv3 = reinterpret(0x3EAAAAAB); // 0.333333333333\n var hx = reinterpret(x);\n var hy = reinterpret(y);\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if (iy == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3F800000) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if (ix > 0x7F800000 || iy > 0x7F800000) return x + y; // NaN if either arg is NaN\n var yisint = 0, j: i32, k: i32;\n if (hx < 0) {\n if (iy >= 0x4B800000) yisint = 2;\n else if (iy >= 0x3F800000) {\n k = (iy >> 23) - 0x7F;\n let ki = 23 - k;\n j = iy >> ki;\n if ((j << ki) == iy) yisint = 2 - (j & 1);\n }\n }\n if (iy == 0x7F800000) { // y is +-inf\n if (ix == 0x3F800000) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix > 0x3F800000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3F800000) return hy >= 0 ? x : 1.0 / x;\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3F000000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n var ax = builtin_abs(x);\n var z: f32;\n if (ix == 0x7F800000 || ix == 0 || ix == 0x3F800000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3F800000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n }\n else if (yisint == 1) z = -z;\n }\n return z;\n }\n var sn = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) sn = -1.0;\n }\n var t1: f32, t2: f32, r: f32, s: f32, t: f32, u: f32, v: f32, w: f32, p_h: f32, p_l: f32;\n var n: i32, is: i32;\n if (iy > 0x4D000000) {\n if (ix < 0x3F7FFFF8) return hy < 0 ? sn * huge * huge : sn * tiny * tiny;\n if (ix > 0x3F800007) return hy > 0 ? sn * huge * huge : sn * tiny * tiny;\n t = ax - 1;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = v - (t1 - u);\n } else {\n let s2: f32, s_h: f32, s_l: f32, t_h: f32, t_l: f32;\n n = 0;\n if (ix < 0x00800000) {\n ax *= two24;\n n -= 24;\n ix = reinterpret(ax);\n }\n n += (ix >> 23) - 0x7F;\n j = ix & 0x007FFFFF;\n ix = j | 0x3F800000;\n if (j <= 0x1CC471) k = 0;\n else if (j < 0x5DB3D7) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00800000;\n }\n ax = reinterpret(ix);\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n s = u * v;\n s_h = s;\n is = reinterpret(s_h);\n s_h = reinterpret(is & 0xFFFFF000);\n is = ((ix >> 1) & 0xFFFFF000) | 0x20000000;\n t_h = reinterpret(is + 0x00400000 + (k << 21));\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = s * s;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + s);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n is = reinterpret(t_h);\n t_h = reinterpret(is & 0xFFFFF000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * s;\n p_h = u + v;\n is = reinterpret(p_h);\n p_h = reinterpret(is & 0xFFFFF000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = (((z_h + z_l) + dp_h) + t);\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n is = reinterpret(y);\n var y1 = reinterpret(is & 0xFFFFF000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n j = reinterpret(z);\n if (j > 0x43000000) {\n return sn * huge * huge;\n } else if (j == 0x43000000) {\n if (p_l + ovt > z - p_h) return sn * huge * huge;\n } else if ((j & 0x7FFFFFFF) > 0x43160000) {\n return sn * tiny * tiny;\n } else if (j == 0xC3160000) {\n if (p_l <= z - p_h) return sn * tiny * tiny;\n }\n var i = j & 0x7FFFFFFF;\n k = (i >> 23) - 0x7F;\n n = 0;\n if (i > 0x3F000000) {\n n = j + (0x00800000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 23) - 0x7F;\n t = reinterpret(n & ~(0x007FFFFF >> k));\n n = ((n & 0x007FFFFF) | 0x00800000) >> (23 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n is = reinterpret(t);\n t = reinterpret(is & 0xFFFF8000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = reinterpret(z);\n j += n << 23;\n if ((j >> 23) <= 0) z = scalbn(z, n);\n else z = reinterpret(j);\n return sn * z;\n }\n\n // @ts-ignore: decorator\n @inline\n export function seedRandom(value: i64): void {\n NativeMath.seedRandom(value);\n }\n\n // Using xoroshiro64starstar from http://xoshiro.di.unimi.it/xoroshiro64starstar.c\n export function random(): f32 {\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n\n var s0 = random_state0_32;\n var s1 = random_state1_32;\n var r = rotl(s0 * 0x9E3779BB, 5) * 5;\n\n s1 ^= s0;\n random_state0_32 = rotl(s0, 26) ^ s1 ^ (s1 << 9);\n random_state1_32 = rotl(s1, 13);\n\n return reinterpret((r >> 9) | (127 << 23)) - 1.0;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f32): f32 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f32): f32 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f32): bool {\n // @ts-ignore: type\n return ((reinterpret(x) >>> 31) & (x == x));\n }\n\n export function sin(x: f32): f32 { // see: musl/src/math/sinf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const s2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const s4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return sin_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return sign ? -cos_kernf(x + s1pio2) : cos_kernf(x - s1pio2);\n }\n return sin_kernf(-(sign ? x + s2pio2 : x - s2pio2));\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return sign ? cos_kernf(x + s3pio2) : -cos_kernf(x - s3pio2);\n }\n return sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? cos_kernf(y) : sin_kernf(y);\n return n & 2 ? -t : t;\n }\n\n export function sinh(x: f32): f32 { // see: musl/src/math/sinhf.c\n var u = reinterpret(x) & 0x7FFFFFFF;\n var absx = reinterpret(u);\n var t: f32;\n var h = builtin_copysign(0.5, x);\n if (u < 0x42B17217) {\n t = expm1(absx);\n if (u < 0x3F800000) {\n if (u < 0x3F800000 - (12 << 23)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2f(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f32): f32 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f32): f32 { // see: musl/src/math/tanf.c\n const t1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const t2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const t3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const t4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return tan_kernf(x, 0);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return tan_kernf((sign ? x + t1pio2 : x - t1pio2), 1);\n } else {\n return tan_kernf((sign ? x + t2pio2 : x - t2pio2), 0);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return tan_kernf((sign ? x + t3pio2 : x - t3pio2), 1);\n } else {\n return tan_kernf((sign ? x + t4pio2 : x - t4pio2), 0);\n }\n }\n }\n\n /* tan(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* argument reduction */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n return tan_kernf(y, n & 1);\n }\n\n export function tanh(x: f32): f32 { // see: musl/src/math/tanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n var t: f32;\n if (u > 0x3F0C9F54) {\n if (u > 0x41200000) t = 1 + 0 / y;\n else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (u > 0x3E82C578) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (u >= 0x00800000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f32): f32 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f32, n: i32): f32 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbnf.c\n const\n Ox1p24f = reinterpret(0x4B800000),\n Ox1p127f = reinterpret(0x7F000000),\n Ox1p_126f = reinterpret(0x00800000);\n var y = x;\n if (n > 127) {\n y *= Ox1p127f;\n n -= 127;\n if (n > 127) {\n y *= Ox1p127f;\n n = builtin_min(n - 127, 127);\n }\n } else if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n += 126 - 24;\n if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n = builtin_max(n + 126 - 24, -126);\n }\n }\n return y * reinterpret((0x7F + n) << 23);\n }\n\n export function mod(x: f32, y: f32): f32 { // see: musl/src/math/fmodf.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = ux & 0x80000000;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0xFF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 9);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 9;\n ux |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 23); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 8);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 23;\n ux |= ex << 23;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx;\n return reinterpret(ux);\n }\n\n export function rem(x: f32, y: f32): f32 { // see: musl/src/math/remquof.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = (ux >> 31);\n var uxi = ux;\n if (uy << 1 == 0 || ex == 0xFF || isNaN(y)) return (x * y) / (x * y);\n if (ux << 1 == 0) return x;\n if (!ex) {\n ex -= builtin_clz(uxi << 9);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 9;\n uxi |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n var q = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -30;\n else {\n let shift = builtin_clz(uxi << 8);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end\n if (ex > 0) {\n uxi -= 1 << 23;\n uxi |= ex << 23;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // q++;\n }\n return sx ? -x : x;\n }\n\n export function sincos(x: f32): void { // see: musl/tree/src/math/sincosf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const s2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const s4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7fffffff;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n sincos_sin = x;\n sincos_cos = 1;\n return;\n }\n sincos_sin = sin_kernf(x);\n sincos_cos = cos_kernf(x);\n return;\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n if (sign) {\n sincos_sin = -cos_kernf(x + s1pio2);\n sincos_cos = sin_kernf(x + s1pio2);\n } else {\n sincos_sin = cos_kernf(s1pio2 - x);\n sincos_cos = sin_kernf(s1pio2 - x);\n }\n return;\n }\n /* -sin(x + c) is not correct if x+c could be 0: -0 vs +0 */\n sincos_sin = -sin_kernf(sign ? x + s2pio2 : x - s2pio2);\n sincos_cos = -cos_kernf(sign ? x + s2pio2 : x - s2pio2);\n return;\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n if (sign) {\n sincos_sin = cos_kernf(x + s3pio2);\n sincos_cos = -sin_kernf(x + s3pio2);\n } else {\n sincos_sin = -cos_kernf(x - s3pio2);\n sincos_cos = sin_kernf(x - s3pio2);\n }\n return;\n }\n sincos_sin = sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n sincos_cos = cos_kernf(sign ? x + s4pio2 : x - s4pio2);\n return;\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) {\n let xx = x - x;\n sincos_sin = xx;\n sincos_cos = xx;\n return;\n }\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n var s = sin_kernf(y);\n var c = cos_kernf(y);\n\n switch (n & 3) {\n case 0: {\n sincos_sin = s;\n sincos_cos = c;\n break;\n }\n case 1: {\n sincos_sin = c;\n sincos_cos = -s;\n break;\n }\n case 2: {\n sincos_sin = -s;\n sincos_cos = -c;\n break;\n }\n case 3:\n default: {\n sincos_sin = -c;\n sincos_cos = s;\n break;\n }\n }\n }\n}\n\nexport function ipow32(x: i32, e: i32): i32 {\n var out = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 5) {\n // 32 = 2 ^ 5, so need only five cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow64(x: i64, e: i32): i64 {\n var out: i64 = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 6) {\n // 64 = 2 ^ 6, so need only six cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 6: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow32f(x: f32, e: i32): f32 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out: f32 = 1;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n\nexport function ipow64f(x: f64, e: i32): f64 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out = 1.0;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n',memory:'import { memcmp, memmove, memset } from "./util/memory";\nimport { E_NOTIMPLEMENTED } from "./util/error";\n\n/** Memory manager interface. */\nexport namespace memory {\n\n /** Gets the size of the memory in pages. */\n // @ts-ignore: decorator\n @builtin\n export declare function size(): i32;\n\n /** Grows the memory by the given size in pages and returns the previous size in pages. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function grow(pages: i32): i32;\n\n /** Fills a section in memory with the specified byte value. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function fill(dst: usize, c: u8, n: usize): void {\n memset(dst, c, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Copies a section of memory to another. Has move semantics. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function copy(dst: usize, src: usize, n: usize): void {\n memmove(dst, src, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Initializes a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Drops a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function drop(segmentIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Repeats a section of memory at a specific address. */\n // @ts-ignore: decorator\n @unsafe\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void {\n var index: usize = 0;\n var total = srcLength * count;\n while (index < total) {\n memory.copy(dst + index, src, srcLength);\n index += srcLength;\n }\n }\n\n /** Compares a section of memory to another. */\n // @ts-ignore: decorator\n @inline\n export function compare(vl: usize, vr: usize, n: usize): i32 {\n return memcmp(vl, vr, n);\n }\n}\n',number:'import { itoa, dtoa } from "./util/number";\nimport { isNaN as builtin_isNaN, isFinite as builtin_isFinite } from "./builtins";\n\n@sealed @unmanaged\nexport abstract class I8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i8 = i8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i8 = i8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i8 {\n return parseI32(value, radix);\n }\n\n toString(this: i8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i16 = i16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i16 = i16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i16 {\n return parseI32(value, radix);\n }\n\n toString(this: i16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i32 = i32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i32 = i32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i32 {\n return parseI32(value, radix);\n }\n\n toString(this: i32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i64 = i64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i64 = i64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i64 {\n return parseI64(value, radix);\n }\n\n toString(this: i64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Isize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: isize = isize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: isize = isize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): isize {\n return parseI64(value, radix);\n }\n\n toString(this: isize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u8 = u8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u8 = u8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u8 {\n return parseI32(value, radix);\n }\n\n toString(this: u8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u16 = u16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u16 = u16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u16 {\n return parseI32(value, radix);\n }\n\n toString(this: u16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u32 = u32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u32 = u32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u32 {\n return parseI32(value, radix);\n }\n\n toString(this: u32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u64 = u64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u64 = u64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u64 {\n return parseI64(value, radix);\n }\n\n toString(this: u64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Usize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: usize = usize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: usize = usize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): usize {\n return parseI64(value, radix);\n }\n\n toString(this: usize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Bool {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: bool = bool.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: bool = bool.MAX_VALUE;\n\n toString(this: bool): String {\n // TODO: radix?\n return this ? "true" : "false";\n }\n}\n\nexport { Bool as Boolean };\n\n@sealed @unmanaged\nexport abstract class F32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f32 = f32.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f32 = f32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f32 = f32.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f32 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f32 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f32 = NaN;\n\n static isNaN(value: f32): bool {\n return isNaN(value);\n }\n\n static isFinite(value: f32): bool {\n return isFinite(value);\n }\n\n static isSafeInteger(value: f32): bool {\n return abs(value) <= f32.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f32): bool {\n return isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f32 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f32 {\n return parseFloat(value);\n }\n\n toString(this: f32): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class F64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f64 = f64.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f64 = f64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f64 = f64.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f64 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f64 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f64 = NaN;\n\n static isNaN(value: f64): bool {\n return builtin_isNaN(value);\n }\n\n static isFinite(value: f64): bool {\n return builtin_isFinite(value);\n }\n\n static isSafeInteger(value: f64): bool {\n return abs(value) <= f64.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f64): bool {\n return builtin_isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f64 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f64 {\n return parseFloat(value);\n }\n\n toString(this: f64): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\nexport { F64 as Number };\n',polyfills:"export function bswap(value: T): T {\n if (isInteger()) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n }\n if (sizeof() == 4) {\n return (\n rotl(value & 0xFF00FF00, 8) |\n rotr(value & 0x00FF00FF, 8)\n );\n }\n if (sizeof() == 8) {\n let a = (value >> 8) & 0x00FF00FF00FF00FF;\n let b = (value & 0x00FF00FF00FF00FF) << 8;\n let v = a | b;\n\n a = (v >> 16) & 0x0000FFFF0000FFFF;\n b = (v & 0x0000FFFF0000FFFF) << 16;\n\n return rotr(a | b, 32);\n }\n return value;\n }\n assert(false);\n return value;\n}\n\nexport function bswap16(value: T): T {\n if (isInteger() && sizeof() <= 4) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n } else if (sizeof() == 4) {\n return (((value << 8) & 0xFF00) | ((value >> 8) & 0x00FF) | (value & 0xFFFF0000));\n }\n return value;\n }\n assert(false);\n return value;\n}\n",regexp:'export class RegExp {\n\n // @binding(CALL_NEW, [ STRING, STRING], OBJECT_HANDLE)\n constructor(pattern: string, flags: string = "") { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [ STRING ], PASS_THRU)\n test(search: string): bool { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [], STRING)\n toString(): string { throw new Error("unreachable"); }\n\n}\n',rt:'import { Typeinfo, TypeinfoFlags } from "./shared/typeinfo";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { BLOCK, BLOCK_OVERHEAD } from "./rt/common";\nimport { ArrayBufferView } from "./arraybuffer";\n\n// @ts-ignore: decorator\n@builtin\nexport declare const RTTI_BASE: usize;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_globals(cookie: u32): void;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_members(ref: usize, cookie: u32): void;\n\n// @ts-ignore: decorator\n@unsafe\nexport function __typeinfo(id: u32): TypeinfoFlags {\n var ptr = RTTI_BASE;\n if (id > load(ptr)) throw new Error(E_INDEXOUTOFRANGE);\n return changetype(ptr + sizeof() + id * offsetof()).flags;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __instanceof(ref: usize, superId: u32): bool { // keyword\n var id = changetype(ref - BLOCK_OVERHEAD).rtId;\n var ptr = RTTI_BASE;\n if (id <= load(ptr)) {\n do if (id == superId) return true;\n while (id = changetype(ptr + sizeof() + id * offsetof()).base);\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize {\n var array = __alloc(offsetof(), id);\n var bufferSize = length << alignLog2;\n var buffer = __alloc(bufferSize, idof());\n store(array, __retain(buffer), offsetof("data"));\n changetype(array).dataStart = buffer;\n changetype(array).dataLength = bufferSize;\n store(changetype(array), length, offsetof("length_"));\n if (data) memory.copy(buffer, data, bufferSize);\n return array;\n}\n\n// These are provided by the respective implementation, included as another entry file by asc:\n\n// @builtin @unsafe\n// export declare function __alloc(size: usize, id: u32): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __realloc(ref: usize, size: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __free(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __retain(ref: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __release(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __collect(): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __visit(ref: usize, cookie: u32): void;\n',"rt/common":"// Alignment guarantees\n\n// @ts-ignore: decorator\n@inline export const AL_BITS: u32 = 4; // 16 bytes to fit up to v128\n// @ts-ignore: decorator\n@inline export const AL_SIZE: usize = 1 << AL_BITS;\n// @ts-ignore: decorator\n@inline export const AL_MASK: usize = AL_SIZE - 1;\n\n// Extra debugging\n\n// @ts-ignore: decorator\n@inline export const DEBUG = true;\n\n// ╒════════════════ Common block layout (32-bit) ═════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │ MM info │ -16\n// ├───────────────────────────────────────────────────────────────┤\n// │ GC info │ -12\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime id │ -8\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime size │ -4\n// ╞═══════════════════════════════════════════════════════════════╡\n// │ ... │ ref\n@unmanaged export class BLOCK {\n /** Memory manager info. */\n mmInfo: usize; // WASM64 needs adaption\n /** Garbage collector info. */\n gcInfo: u32;\n /** Runtime class id. */\n rtId: u32;\n /** Runtime object size. */\n rtSize: u32;\n}\n\n// @ts-ignore: decorator\n@inline export const BLOCK_OVERHEAD = (offsetof() + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@inline export const BLOCK_MAXSIZE: usize = (1 << 30) - BLOCK_OVERHEAD;\n","rt/index-full":'export { __alloc } from "rt/tlsf";\nexport { __retain, __release, __collect } from "rt/pure";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/index-half":'import "rt/index-full";\n',"rt/index-none":'import "rt/index-stub";\n',"rt/index-stub":'export { __alloc, __retain, __release, __collect } from "rt/stub";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/pure":'import { DEBUG, BLOCK_OVERHEAD } from "rt/common";\nimport { Block, freeBlock, ROOT } from "rt/tlsf";\nimport { TypeinfoFlags } from "shared/typeinfo";\nimport { onincrement, ondecrement, onfree, onalloc } from "./rtrace";\n\n/////////////////////////// A Pure Reference Counting Garbage Collector ///////////////////////////\n// see: https://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon03Pure.pdf\n\n// ╒══════════════════════ GC Info structure ══════════════════════╕\n// │ 3 2 1 │\n// │1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0│\n// ├─┼─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │B│color│ refCount │\n// └─┴─────┴───────────────────────────────────────────────────────┘\n// B: buffered\n\n// @ts-ignore: decorator\n@inline const BUFFERED_MASK: u32 = 1 << (sizeof() * 8 - 1);\n// @ts-ignore: decorator\n@inline const COLOR_BITS = 3;\n// @ts-ignore: decorator\n@inline const COLOR_SHIFT: u32 = ctz(BUFFERED_MASK) - COLOR_BITS;\n// @ts-ignore: decorator\n@inline const COLOR_MASK: u32 = ((1 << COLOR_BITS) - 1) << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const REFCOUNT_MASK: u32 = (1 << COLOR_SHIFT) - 1;\n\n// ╒════════╤═══════════════════ Colors ═══════════════════════════╕\n// │ Color │ Meaning │\n// ├────────┼──────────────────────────────────────────────────────┤\n// │ BLACK │ In use or free │\n// │ GRAY │ Possible member of cycle │\n// │ WHITE │ Member of garbage cycle │\n// │ PURPLE │ Possible root of cycle │\n// │ RED │ Candidate cycle undergoing Σ-computation *concurrent │\n// │ ORANGE │ Candidate cycle awaiting epoch boundary *concurrent │\n// └────────┴──────────────────────────────────────────────────────┘\n// Acyclic detection has been decoupled, hence no GREEN.\n\n// @ts-ignore: decorator\n@inline const COLOR_BLACK: u32 = 0 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_GRAY: u32 = 1 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_WHITE: u32 = 2 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_PURPLE: u32 = 3 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_RED: u32 = 4 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_ORANGE: u32 = 5 << COLOR_SHIFT;\n\n// @ts-ignore: decorator\n@inline const VISIT_DECREMENT = 1; // guard 0\n// @ts-ignore: decorator\n@inline const VISIT_MARKGRAY = 2;\n// @ts-ignore: decorator\n@inline const VISIT_SCAN = 3;\n// @ts-ignore: decorator\n@inline const VISIT_SCANBLACK = 4;\n// @ts-ignore: decorator\n@inline const VISIT_COLLECTWHITE = 5;\n\n// @ts-ignore: decorator\n@global @unsafe\nfunction __visit(ref: usize, cookie: i32): void {\n if (ref < HEAP_BASE) return;\n var s = changetype(ref - BLOCK_OVERHEAD);\n switch (cookie) {\n case VISIT_DECREMENT: {\n decrement(s);\n break;\n }\n case VISIT_MARKGRAY: {\n if (DEBUG) assert((s.gcInfo & REFCOUNT_MASK) > 0);\n s.gcInfo = s.gcInfo - 1;\n markGray(s);\n break;\n }\n case VISIT_SCAN: {\n scan(s);\n break;\n }\n case VISIT_SCANBLACK: {\n let info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if ((info & COLOR_MASK) != COLOR_BLACK) {\n scanBlack(s);\n }\n break;\n }\n case VISIT_COLLECTWHITE: {\n collectWhite(s);\n break;\n }\n default: if (DEBUG) assert(false);\n }\n}\n\n/** Increments the reference count of the specified block by one.*/\nfunction increment(s: Block): void {\n var info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if (isDefined(ASC_RTRACE)) onincrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n}\n\n/** Decrements the reference count of the specified block by one, possibly freeing it. */\nfunction decrement(s: Block): void {\n var info = s.gcInfo;\n var rc = info & REFCOUNT_MASK;\n if (isDefined(ASC_RTRACE)) ondecrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n if (rc == 1) {\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_DECREMENT);\n if (!(info & BUFFERED_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = BUFFERED_MASK | COLOR_BLACK | 0;\n }\n } else {\n if (DEBUG) assert(rc > 0);\n if (!(__typeinfo(s.rtId) & TypeinfoFlags.ACYCLIC)) {\n s.gcInfo = BUFFERED_MASK | COLOR_PURPLE | (rc - 1);\n if (!(info & BUFFERED_MASK)) {\n appendRoot(s);\n }\n } else {\n s.gcInfo = (info & ~REFCOUNT_MASK) | (rc - 1);\n }\n }\n}\n\n/** Buffer of possible roots. */\n// @ts-ignore: decorator\n@lazy var ROOTS: usize;\n/** Current absolute offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var CUR: usize = 0;\n/** Current absolute end offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var END: usize = 0;\n\n/** Appends a block to possible roots. */\nfunction appendRoot(s: Block): void {\n var cur = CUR;\n if (cur >= END) {\n growRoots(); // TBD: either that or pick a default and force collection on overflow\n cur = CUR;\n }\n store(cur, s);\n CUR = cur + sizeof();\n}\n\n/** Grows the roots buffer if it ran full. */\nfunction growRoots(): void {\n var oldRoots = ROOTS;\n var oldSize = CUR - oldRoots;\n var newSize = max(oldSize * 2, 64 << alignof());\n var newRoots = __alloc(newSize, 0);\n if (isDefined(ASC_RTRACE)) onfree(changetype(newRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n memory.copy(newRoots, oldRoots, oldSize);\n if (oldRoots) {\n if (isDefined(ASC_RTRACE)) onalloc(changetype(oldRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n __free(oldRoots);\n }\n ROOTS = newRoots;\n CUR = newRoots + oldSize;\n END = newRoots + newSize;\n}\n\n/** Collects cyclic garbage. */\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n\n // markRoots\n var roots = ROOTS;\n var cur = roots;\n for (let pos = cur, end = CUR; pos < end; pos += sizeof()) {\n let s = load(pos);\n let info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_PURPLE && (info & REFCOUNT_MASK) > 0) {\n markGray(s);\n store(cur, s);\n cur += sizeof();\n } else {\n if ((info & COLOR_MASK) == COLOR_BLACK && !(info & REFCOUNT_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = info & ~BUFFERED_MASK;\n }\n }\n }\n CUR = cur;\n\n // scanRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n scan(load(pos));\n }\n\n // collectRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n let s = load(pos);\n s.gcInfo = s.gcInfo & ~BUFFERED_MASK;\n collectWhite(s);\n }\n CUR = roots;\n}\n\n/** Marks a block as gray (possible member of cycle) during the collection phase. */\nfunction markGray(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) != COLOR_GRAY) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_GRAY;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_MARKGRAY);\n }\n}\n\n/** Scans a block during the collection phase, determining whether it is garbage or not. */\nfunction scan(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_GRAY) {\n if ((info & REFCOUNT_MASK) > 0) {\n scanBlack(s);\n } else {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_WHITE;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCAN);\n }\n }\n}\n\n/** Marks a block as black (in use) if it was found to be reachable during the collection phase. */\nfunction scanBlack(s: Block): void {\n s.gcInfo = (s.gcInfo & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCANBLACK);\n}\n\n/** Collects all white (member of a garbage cycle) nodes when completing the collection phase. */\nfunction collectWhite(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_WHITE && !(info & BUFFERED_MASK)) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_COLLECTWHITE);\n freeBlock(ROOT, s);\n }\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n if (ref > HEAP_BASE) increment(changetype(ref - BLOCK_OVERHEAD));\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n if (ref > HEAP_BASE) decrement(changetype(ref - BLOCK_OVERHEAD));\n}\n',"rt/rtrace":'import { BLOCK } from "./common";\n\nexport declare function onalloc(s: BLOCK): void;\nexport declare function onincrement(s: BLOCK): void;\nexport declare function ondecrement(s: BLOCK): void;\nexport declare function onfree(s: BLOCK): void;\n',"rt/stub":'import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common";\n\n// @ts-ignore: decorator\n@lazy\nvar startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@lazy\nvar offset: usize = startOffset;\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __alloc(size: usize, id: u32): usize {\n if (size > BLOCK_MAXSIZE) unreachable();\n var ptr = offset + BLOCK_OVERHEAD;\n var newPtr = (ptr + max(size, 1) + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n if (newPtr > pagesBefore << 16) {\n let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;\n let pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable(); // out of memory\n }\n }\n offset = newPtr;\n var block = changetype(ptr - BLOCK_OVERHEAD);\n block.rtId = id;\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __realloc(ref: usize, size: usize): usize {\n var block = changetype(ref - BLOCK_OVERHEAD);\n var oldSize = block.rtSize;\n if (size > oldSize) {\n let newRef = __alloc(size, block.rtId);\n memory.copy(newRef, ref, oldSize);\n ref = newRef;\n } else {\n block.rtSize = size;\n }\n return ref;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __free(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nfunction __reset(): void { // special\n offset = startOffset;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __visit(ref: usize, cookie: u32): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n}\n',"rt/tlsf":"import { AL_BITS, AL_MASK, DEBUG, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from \"rt/common\";\nimport { onfree, onalloc } from \"./rtrace\";\n\n/////////////////////// The TLSF (Two-Level Segregate Fit) memory allocator ///////////////////////\n// see: http://www.gii.upv.es/tlsf/\n\n// - `ffs(x)` is equivalent to `ctz(x)` with x != 0\n// - `fls(x)` is equivalent to `sizeof(x) * 8 - clz(x) - 1`\n\n// ╒══════════════ Block size interpretation (32-bit) ═════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─╫─┴─┴─┴─┤\n// │ | FL │ SB = SL + AL │ ◄─ usize\n// └───────────────────────────────────────────────┴───────╨───────┘\n// FL: first level, SL: second level, AL: alignment, SB: small block\n\n// @ts-ignore: decorator\n@inline const SL_BITS: u32 = 4;\n// @ts-ignore: decorator\n@inline const SL_SIZE: usize = 1 << SL_BITS;\n\n// @ts-ignore: decorator\n@inline const SB_BITS: usize = (SL_BITS + AL_BITS);\n// @ts-ignore: decorator\n@inline const SB_SIZE: usize = 1 << SB_BITS;\n\n// @ts-ignore: decorator\n@inline const FL_BITS: u32 = 31 - SB_BITS;\n\n// [00]: < 256B (SB) [12]: < 1M\n// [01]: < 512B [13]: < 2M\n// [02]: < 1K [14]: < 4M\n// [03]: < 2K [15]: < 8M\n// [04]: < 4K [16]: < 16M\n// [05]: < 8K [17]: < 32M\n// [06]: < 16K [18]: < 64M\n// [07]: < 32K [19]: < 128M\n// [08]: < 64K [20]: < 256M\n// [09]: < 128K [21]: < 512M\n// [10]: < 256K [22]: <= 1G - OVERHEAD\n// [11]: < 512K\n// VMs limit to 2GB total (currently), making one 1G block max (or three 512M etc.) due to block overhead\n\n// Tags stored in otherwise unused alignment bits\n\n// @ts-ignore: decorator\n@inline const FREE: usize = 1 << 0;\n// @ts-ignore: decorator\n@inline const LEFTFREE: usize = 1 << 1;\n// @ts-ignore: decorator\n@inline const TAGS_MASK: usize = FREE | LEFTFREE; // <= AL_MASK\n\n// ╒════════════════════ Block layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┼─┤ overhead ┐\n// │ size │0│L│F│ ◄─┐ info\n// ├─────────────────────────────────────────────────────────┴─┴─┴─┤ │\n// │ │ │\n// │ ... additional runtime overhead ... │ │\n// │ │ │\n// ╞═══════════════════════════════════════════════════════════════╡ │ ┐ ┘\n// │ if free: ◄ prev │ ◄─┤ usize\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: next ► │ ◄─┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ │ = 0\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: back ▲ │ ◄─┘\n// └───────────────────────────────────────────────────────────────┘ payload ┘ >= MIN SIZE\n// F: FREE, L: LEFTFREE\n@unmanaged export class Block extends BLOCK {\n\n /** Previous free block, if any. Only valid if free, otherwise part of payload. */\n prev: Block | null;\n /** Next free block, if any. Only valid if free, otherwise part of payload. */\n next: Block | null;\n\n // If the block is free, there is a 'back'reference at its end pointing at its start.\n}\n\n// Block constants. A block must have a minimum size of three pointers so it can hold `prev`,\n// `next` and `back` if free.\n\n// @ts-ignore: decorator\n@inline const BLOCK_MINSIZE: usize = (3 * sizeof() + AL_MASK) & ~AL_MASK; // prev + next + back\n// @ts-ignore: decorator\n// @inline const BLOCK_MAXSIZE: usize = 1 << (FL_BITS + SB_BITS - 1); // exclusive, lives in common.ts\n\n/** Gets the left block of a block. Only valid if the left block is free. */\n// @ts-ignore: decorator\n@inline function GETFREELEFT(block: Block): Block {\n return load(changetype(block) - sizeof());\n}\n\n/** Gets the right block of of a block by advancing to the right by its size. */\n// @ts-ignore: decorator\n@inline function GETRIGHT(block: Block): Block {\n return changetype(changetype(block) + BLOCK_OVERHEAD + (block.mmInfo & ~TAGS_MASK));\n}\n\n// ╒═════════════════════ Root layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ┐\n// │ 0 | flMap S│ ◄────┐\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ slMap[0] S │ ◄─┐ │\n// ├───────────────────────────────────────────────────────────────┤ │ │\n// │ slMap[1] │ ◄─┤ │\n// ├───────────────────────────────────────────────────────────────┤ u32 │\n// │ slMap[22] │ ◄─┘ │\n// ╞═══════════════════════════════════════════════════════════════╡ usize\n// │ head[0] │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ head[367] │ ◄────┤\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ tail │ ◄────┘\n// └───────────────────────────────────────────────────────────────┘ SIZE ┘\n// S: Small blocks map\n@unmanaged class Root {\n /** First level bitmap. */\n flMap: usize;\n}\n\n// Root constants. Where stuff is stored inside of the root structure.\n\n// @ts-ignore: decorator\n@inline const SL_START = sizeof();\n// @ts-ignore: decorator\n@inline const SL_END = SL_START + (FL_BITS << alignof());\n// @ts-ignore: decorator\n@inline const HL_START = (SL_END + AL_MASK) & ~AL_MASK;\n// @ts-ignore: decorator\n@inline const HL_END = HL_START + FL_BITS * SL_SIZE * sizeof();\n// @ts-ignore: decorator\n@inline const ROOT_SIZE = HL_END + sizeof();\n\n// @ts-ignore: decorator\n@lazy export var ROOT: Root;\n\n/** Gets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function GETSL(root: Root, fl: usize): u32 {\n return load(\n changetype(root) + (fl << alignof()),\n SL_START\n );\n}\n\n/** Sets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function SETSL(root: Root, fl: usize, slMap: u32): void {\n store(\n changetype(root) + (fl << alignof()),\n slMap,\n SL_START\n );\n}\n\n/** Gets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function GETHEAD(root: Root, fl: usize, sl: u32): Block | null {\n return load(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n HL_START\n );\n}\n\n/** Sets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function SETHEAD(root: Root, fl: usize, sl: u32, head: Block | null): void {\n store(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n head,\n HL_START\n );\n}\n\n/** Gets the tail block.. */\n// @ts-ignore: decorator\n@inline function GETTAIL(root: Root): Block {\n return load(\n changetype(root),\n HL_END\n );\n}\n\n/** Sets the tail block. */\n// @ts-ignore: decorator\n@inline function SETTAIL(root: Root, tail: Block): void {\n store(\n changetype(root),\n tail,\n HL_END\n );\n}\n\n/** Inserts a previously used block back into the free list. */\nfunction insertBlock(root: Root, block: Block): void {\n if (DEBUG) assert(block); // cannot be null\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n\n // merge with right block if also free\n if (rightInfo & FREE) {\n let newSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, right);\n block.mmInfo = blockInfo = (blockInfo & TAGS_MASK) | newSize;\n right = GETRIGHT(block);\n rightInfo = right.mmInfo;\n // 'back' is set below\n }\n }\n\n // merge with left block if also free\n if (blockInfo & LEFTFREE) {\n let left = GETFREELEFT(block);\n let leftInfo = left.mmInfo;\n if (DEBUG) assert(leftInfo & FREE); // must be free according to right tags\n let newSize = (leftInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (blockInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, left);\n left.mmInfo = blockInfo = (leftInfo & TAGS_MASK) | newSize;\n block = left;\n // 'back' is set below\n }\n }\n\n right.mmInfo = rightInfo | LEFTFREE;\n // right is no longer used now, hence rightInfo is not synced\n\n // we now know the size of the block\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be a valid size\n if (DEBUG) assert(changetype(block) + BLOCK_OVERHEAD + size == changetype(right)); // must match\n\n // set 'back' to itself at the end of block\n store(changetype(right) - sizeof(), block);\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // perform insertion\n var head = GETHEAD(root, fl, sl);\n block.prev = null;\n block.next = head;\n if (head) head.prev = block;\n SETHEAD(root, fl, sl, block);\n\n // update first and second level maps\n root.flMap |= (1 << fl);\n SETSL(root, fl, GETSL(root, fl) | (1 << sl));\n}\n\n/** Removes a free block from internal lists. */\nfunction removeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be valid\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // link previous and next free block\n var prev = block.prev;\n var next = block.next;\n if (prev) prev.next = next;\n if (next) next.prev = prev;\n\n // update head if we are removing it\n if (block == GETHEAD(root, fl, sl)) {\n SETHEAD(root, fl, sl, next);\n\n // clear second level map if head is empty now\n if (!next) {\n let slMap = GETSL(root, fl);\n SETSL(root, fl, slMap &= ~(1 << sl));\n\n // clear first level map if second level is empty now\n if (!slMap) root.flMap &= ~(1 << fl);\n }\n }\n // note: does not alter left/back because it is likely that splitting\n // is performed afterwards, invalidating those changes. so, the caller\n // must perform those updates.\n}\n\n/** Searches for a free block of at least the specified size. */\nfunction searchBlock(root: Root, size: usize): Block | null {\n // size was already asserted by caller\n\n // mapping_search\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const halfMaxSize = BLOCK_MAXSIZE >> 1; // don't round last fl\n const inv: usize = sizeof() * 8 - 1;\n const invRound = inv - SL_BITS;\n let requestSize = size < halfMaxSize\n ? size + (1 << (invRound - clz(size))) - 1\n : size;\n fl = inv - clz(requestSize);\n sl = ((requestSize >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // search second level\n var slMap = GETSL(root, fl) & (~0 << sl);\n var head: Block | null = null;\n if (!slMap) {\n // search next larger first level\n let flMap = root.flMap & (~0 << (fl + 1));\n if (!flMap) {\n head = null;\n } else {\n fl = ctz(flMap);\n slMap = GETSL(root, fl);\n if (DEBUG) assert(slMap); // can't be zero if fl points here\n head = GETHEAD(root, fl, ctz(slMap));\n }\n } else {\n head = GETHEAD(root, fl, ctz(slMap));\n }\n return head;\n}\n\n/** Prepares the specified block before (re-)use, possibly splitting it. */\nfunction prepareBlock(root: Root, block: Block, size: usize): void {\n // size was already asserted by caller\n\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(size & AL_MASK)); // size must be aligned so the new block is\n\n // split if the block can hold another MINSIZE block incl. overhead\n var remaining = (blockInfo & ~TAGS_MASK) - size;\n if (remaining >= BLOCK_OVERHEAD + BLOCK_MINSIZE) {\n block.mmInfo = size | (blockInfo & LEFTFREE); // also discards FREE\n\n let spare = changetype(changetype(block) + BLOCK_OVERHEAD + size);\n spare.mmInfo = (remaining - BLOCK_OVERHEAD) | FREE; // not LEFTFREE\n insertBlock(root, spare); // also sets 'back'\n\n // otherwise tag block as no longer FREE and right as no longer LEFTFREE\n } else {\n block.mmInfo = blockInfo & ~FREE;\n GETRIGHT(block).mmInfo &= ~LEFTFREE;\n }\n}\n\n/** Adds more memory to the pool. */\nfunction addMemory(root: Root, start: usize, end: usize): bool {\n if (DEBUG) {\n assert(\n start <= end && // must be valid\n !(start & AL_MASK) && // must be aligned\n !(end & AL_MASK) // must be aligned\n );\n }\n\n var tail = GETTAIL(root);\n var tailInfo: usize = 0;\n if (tail) { // more memory\n if (DEBUG) assert(start >= changetype(tail) + BLOCK_OVERHEAD);\n\n // merge with current tail if adjacent\n if (start - BLOCK_OVERHEAD == changetype(tail)) {\n start -= BLOCK_OVERHEAD;\n tailInfo = tail.mmInfo;\n } else {\n // We don't do this, but a user might `memory.grow` manually\n // leading to non-adjacent pages managed by TLSF.\n }\n\n } else if (DEBUG) { // first memory\n assert(start >= changetype(root) + ROOT_SIZE); // starts after root\n }\n\n // check if size is large enough for a free block and the tail block\n var size = end - start;\n if (size < BLOCK_OVERHEAD + BLOCK_MINSIZE + BLOCK_OVERHEAD) {\n return false;\n }\n\n // left size is total minus its own and the zero-length tail's header\n var leftSize = size - 2 * BLOCK_OVERHEAD;\n var left = changetype(start);\n left.mmInfo = leftSize | FREE | (tailInfo & LEFTFREE);\n left.prev = null;\n left.next = null;\n\n // tail is a zero-length used block\n tail = changetype(start + size - BLOCK_OVERHEAD);\n tail.mmInfo = 0 | LEFTFREE;\n SETTAIL(root, tail);\n\n insertBlock(root, left); // also merges with free left before tail / sets 'back'\n\n return true;\n}\n\n/** Grows memory to fit at least another block of the specified size. */\nfunction growMemory(root: Root, size: usize): void {\n var pagesBefore = memory.size();\n var pagesNeeded = (((size + 0xffff) & ~0xffff) >>> 16);\n var pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable();\n }\n var pagesAfter = memory.size();\n addMemory(root, pagesBefore << 16, pagesAfter << 16);\n}\n\n/** Prepares and checks an allocation size. */\nfunction prepareSize(size: usize): usize {\n if (size >= BLOCK_MAXSIZE) throw new Error(\"allocation too large\");\n return max((size + AL_MASK) & ~AL_MASK, BLOCK_MINSIZE); // align and ensure min size\n}\n\n/** Initilizes the root structure. */\nexport function initializeRoot(): void {\n var rootOffset = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n var pagesNeeded = ((((rootOffset + ROOT_SIZE) + 0xffff) & ~0xffff) >>> 16);\n if (pagesNeeded > pagesBefore && memory.grow(pagesNeeded - pagesBefore) < 0) unreachable();\n var root = changetype(rootOffset);\n root.flMap = 0;\n SETTAIL(root, changetype(0));\n for (let fl: usize = 0; fl < FL_BITS; ++fl) {\n SETSL(root, fl, 0);\n for (let sl: u32 = 0; sl < SL_SIZE; ++sl) {\n SETHEAD(root, fl, sl, null);\n }\n }\n addMemory(root, (rootOffset + ROOT_SIZE + AL_MASK) & ~AL_MASK, memory.size() << 16);\n ROOT = root;\n}\n\n/** Allocates a block of the specified size. */\nexport function allocateBlock(root: Root, size: usize): Block {\n var payloadSize = prepareSize(size);\n var block = searchBlock(root, payloadSize);\n if (!block) {\n growMemory(root, payloadSize);\n block = searchBlock(root, payloadSize);\n if (DEBUG) assert(block); // must be found now\n }\n if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit\n block.gcInfo = 0; // RC=0\n // block.rtId = 0; // set by the caller (__alloc)\n block.rtSize = size;\n removeBlock(root, block);\n prepareBlock(root, block, payloadSize);\n if (isDefined(ASC_RTRACE)) onalloc(block);\n return block;\n}\n\n/** Reallocates a block to the specified size. */\nexport function reallocateBlock(root: Root, block: Block, size: usize): Block {\n var payloadSize = prepareSize(size);\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(blockInfo & FREE)); // must be used\n\n // possibly split and update runtime size if it still fits\n if (payloadSize <= (blockInfo & ~TAGS_MASK)) {\n prepareBlock(root, block, payloadSize);\n block.rtSize = size;\n return block;\n }\n\n // merge with right free block if merger is large enough\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n if (rightInfo & FREE) {\n let mergeSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (mergeSize >= payloadSize) {\n removeBlock(root, right);\n // TODO: this can yield an intermediate block larger than BLOCK_MAXSIZE, which\n // is immediately split though. does this trigger any assertions / issues?\n block.mmInfo = (blockInfo & TAGS_MASK) | mergeSize;\n block.rtSize = size;\n prepareBlock(root, block, payloadSize);\n return block;\n }\n }\n\n // otherwise move the block\n var newBlock = allocateBlock(root, size);\n newBlock.gcInfo = block.gcInfo;\n newBlock.rtId = block.rtId;\n memory.copy(changetype(newBlock) + BLOCK_OVERHEAD, changetype(block) + BLOCK_OVERHEAD, size);\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n return newBlock;\n}\n\n/** Frees a block. */\nexport function freeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n assert(!(blockInfo & FREE)); // must be used (user might call through to this)\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n if (isDefined(ASC_RTRACE)) onfree(block);\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __alloc(size: usize, id: u32): usize {\n var root = ROOT;\n if (!root) {\n initializeRoot();\n root = ROOT;\n }\n var block = allocateBlock(root, size);\n block.rtId = id;\n return changetype(block) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __realloc(ref: usize, size: usize): usize {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n return changetype(reallocateBlock(ROOT, changetype(ref - BLOCK_OVERHEAD), size)) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __free(ref: usize): void {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n freeBlock(ROOT, changetype(ref - BLOCK_OVERHEAD));\n}\n",set:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a set entry. */\n@unmanaged class SetEntry {\n key: K;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K is <= 32-bits\n const align = (sizeof() > sizeof() ? sizeof() : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Set {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // SetEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() { this.clear(); }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): SetEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n add(key: K): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (!entry) {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n entry = changetype>(changetype(this.entries) + this.entriesOffset++ * ENTRY_SIZE());\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key)); // unmanaged!\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key)); // exact \'key\'\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr); // unmanaged!\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr); // unmanaged!\n newEntry.key = oldEntry.key;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Set]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',"shared/feature":"// This file is shared with the compiler and must remain portable\n\n/** Indicates specific features to activate. */\nexport const enum Feature {\n /** No additional features. */\n NONE = 0,\n /** Sign extension operations. */\n SIGN_EXTENSION = 1 << 0, // see: https://github.com/WebAssembly/sign-extension-ops\n /** Mutable global imports and exports. */\n MUTABLE_GLOBAL = 1 << 1, // see: https://github.com/WebAssembly/mutable-global\n /** Bulk memory operations. */\n BULK_MEMORY = 1 << 2, // see: https://github.com/WebAssembly/bulk-memory-operations\n /** SIMD types and operations. */\n SIMD = 1 << 3, // see: https://github.com/WebAssembly/simd\n /** Threading and atomic operations. */\n THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads\n}\n","shared/target":"// This file is shared with the compiler and must remain portable\n\n/** Compilation target. */\nexport enum Target {\n /** WebAssembly with 32-bit pointers. */\n WASM32,\n /** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */\n WASM64,\n /** Portable. */\n JS\n}\n","shared/typeinfo":"// This file is shared with the compiler and must remain portable\n\n// ╒═══════════════════ Typeinfo interpretation ═══════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ◄─ RTTI_BASE\n// │ count │\n// ╞═══════════════════════════════════════════════════════════════╡ ┐\n// │ Typeinfo#flags [id=0] │ id < count\n// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤\n// │ Typeinfo#base [id=0] │\n// ├───────────────────────────────────────────────────────────────┤\n// │ ... │\n\n/** Runtime type information data structure. */\n@unmanaged\nexport class Typeinfo {\n /** Flags describing the shape of this class type. */\n flags: TypeinfoFlags;\n /** Base class id or `0` if none. */\n base: u32;\n}\n\n/** Runtime type information flags. */\nexport const enum TypeinfoFlags {\n /** No specific flags. */\n NONE = 0,\n /** Type is an `ArrayBufferView`. */\n ARRAYBUFFERVIEW = 1 << 0,\n /** Type is an `Array`. */\n ARRAY = 1 << 1,\n /** Type is a `Set`. */\n SET = 1 << 2,\n /** Type is a `Map`. */\n MAP = 1 << 3,\n /** Type is inherently acyclic. */\n ACYCLIC = 1 << 4,\n /** Value alignment of 1 byte. */\n VALUE_ALIGN_0 = 1 << 5,\n /** Value alignment of 2 bytes. */\n VALUE_ALIGN_1 = 1 << 6,\n /** Value alignment of 4 bytes. */\n VALUE_ALIGN_2 = 1 << 7,\n /** Value alignment of 8 bytes. */\n VALUE_ALIGN_3 = 1 << 8,\n /** Value alignment of 16 bytes. */\n VALUE_ALIGN_4 = 1 << 9,\n /** Value is a signed type. */\n VALUE_SIGNED = 1 << 10,\n /** Value is a float type. */\n VALUE_FLOAT = 1 << 11,\n /** Value type is nullable. */\n VALUE_NULLABLE = 1 << 12,\n /** Value type is managed. */\n VALUE_MANAGED = 1 << 13,\n /** Key alignment of 1 byte. */\n KEY_ALIGN_0 = 1 << 14,\n /** Key alignment of 2 bytes. */\n KEY_ALIGN_1 = 1 << 15,\n /** Key alignment of 4 bytes. */\n KEY_ALIGN_2 = 1 << 16,\n /** Key alignment of 8 bytes. */\n KEY_ALIGN_3 = 1 << 17,\n /** Key alignment of 16 bytes. */\n KEY_ALIGN_4 = 1 << 18,\n /** Value is a signed type. */\n KEY_SIGNED = 1 << 19,\n /** Value is a float type. */\n KEY_FLOAT = 1 << 20,\n /** Key type is nullable. */\n KEY_NULLABLE = 1 << 21,\n /** Key type is managed. */\n KEY_MANAGED = 1 << 22\n}\n",string:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./util/string";\nimport { E_INVALIDLENGTH } from "./util/error";\nimport { ArrayBufferView } from "./arraybuffer";\nimport { idof } from "./builtins";\n\n@sealed export abstract class String {\n\n @lazy static readonly MAX_LENGTH: i32 = BLOCK_MAXSIZE >>> alignof();\n\n // TODO Add and handle second argument\n static fromCharCode(code: i32): string {\n var out = __alloc(2, idof());\n store(out, code);\n return changetype(out); // retains\n }\n\n static fromCodePoint(code: i32): string {\n assert(code <= 0x10FFFF);\n var sur = code > 0xFFFF;\n var out = __alloc((i32(sur) + 1) << 1, idof());\n if (!sur) {\n store(out, code);\n } else {\n code -= 0x10000;\n let hi: u32 = (code >>> 10) + 0xD800;\n let lo: u32 = (code & 0x3FF) + 0xDC00;\n store(out, (hi << 16) | lo);\n }\n return changetype(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >> 1;\n }\n\n @operator("[]") charAt(pos: i32): String {\n assert(this !== null);\n if (pos >= this.length) return changetype("");\n var out = __alloc(2, idof());\n store(out, load(changetype(this) + (pos << 1)));\n return changetype(out); // retains\n }\n\n charCodeAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (NaN)\n return load(changetype(this) + (pos << 1));\n }\n\n codePointAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (undefined)\n var first = load(changetype(this) + (pos << 1));\n if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length) return first;\n var second = load(changetype(this) + ((pos + 1) << 1));\n if (second < 0xDC00 || second > 0xDFFF) return first;\n return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;\n }\n\n @operator("+") private static __concat(left: String, right: String): String {\n return select(left, changetype("null"), left !== null).concat(right);\n }\n\n concat(other: String): String {\n if (other === null) other = changetype("null");\n var thisSize: isize = this.length << 1;\n var otherSize: isize = other.length << 1;\n var outSize: usize = thisSize + otherSize;\n if (outSize == 0) return changetype("");\n var out = changetype(__alloc(outSize, idof())); // retains\n memory.copy(changetype(out), changetype(this), thisSize);\n memory.copy(changetype(out) + thisSize, changetype(other), otherSize);\n return out;\n }\n\n endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool {\n assert(this !== null);\n if (searchString === null) return false;\n var end = min(max(endPosition, 0), this.length);\n var searchLength: isize = searchString.length;\n var start: isize = end - searchLength;\n if (start < 0) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n @operator("==") private static __eq(left: String | null, right: String | null): bool {\n if (left === right) return true;\n if (left === null || right === null) return false;\n var leftLength = left.length;\n if (leftLength != right.length) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(left, 0, right, 0, leftLength);\n }\n\n @operator.prefix("!")\n private static __not(str: String | null): bool {\n return str === null || !str.length;\n }\n\n @operator("!=")\n private static __ne(left: String | null, right: String | null): bool {\n return !this.__eq(left, right);\n }\n\n @operator(">") private static __gt(left: String | null, right: String | null): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!leftLength) return false;\n if (!rightLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) > 0;\n }\n\n @operator(">=") private static __gte(left: String, right: String): bool {\n return !this.__lt(left, right);\n }\n\n @operator("<") private static __lt(left: String, right: String): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!rightLength) return false;\n if (!leftLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) < 0;\n }\n\n @operator("<=") private static __lte(left: String, right: String): bool {\n return !this.__gt(left, right);\n }\n\n @inline includes(searchString: String, position: i32 = 0): bool {\n return this.indexOf(searchString, position) != -1;\n }\n\n indexOf(searchString: String, fromIndex: i32 = 0): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var searchLen: isize = searchString.length;\n if (!searchLen) return 0;\n var len: isize = this.length;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len);\n len -= searchLen;\n for (let k: isize = start; k <= len; ++k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var len: isize = this.length;\n var searchLen: isize = searchString.length;\n if (!searchLen) return len;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len - searchLen);\n for (let k = start; k >= 0; --k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n startsWith(searchString: String, position: i32 = 0): bool {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var pos: isize = position;\n var len: isize = this.length;\n var start = min(max(pos, 0), len);\n var searchLength: isize = searchString.length;\n if (searchLength + start > len) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var intStart: isize = start;\n var end: isize = length;\n var size: isize = this.length;\n if (intStart < 0) intStart = max(size + intStart, 0);\n var resultLength = min(max(end, 0), size - intStart);\n if (resultLength <= 0) return changetype("");\n var out = __alloc(resultLength << 1, idof());\n memory.copy(out, changetype(this) + intStart, resultLength);\n return changetype(out); // retains\n }\n\n substring(start: i32, end: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var len: isize = this.length;\n var finalStart = min(max(start, 0), len);\n var finalEnd = min(max(end, 0), len);\n var fromPos = min(finalStart, finalEnd) << 1;\n var toPos = max(finalStart, finalEnd) << 1;\n len = toPos - fromPos;\n if (!len) return changetype("");\n if (!fromPos && toPos == this.length << 1) return this;\n var out = __alloc(len, idof());\n memory.copy(out, changetype(this) + fromPos, len);\n return changetype(out); // retains\n }\n\n trim(): String {\n assert(this !== null);\n var length = this.length;\n var size: usize = length << 1;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2; size -= 2;\n }\n if (!size) return changetype("");\n if (!start && size == length << 1) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n @inline\n trimLeft(): String {\n return this.trimStart();\n }\n\n @inline\n trimRight(): String {\n return this.trimEnd();\n }\n\n trimStart(): String {\n assert(this !== null);\n var size = this.length << 1;\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2;\n }\n if (!offset) return this;\n size -= offset;\n if (!size) return changetype("");\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n trimEnd(): String {\n assert(this !== null);\n var originalSize = this.length << 1;\n var size = originalSize;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n if (!size) return changetype("");\n if (size == originalSize) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this), size);\n return changetype(out); // retains\n }\n\n padStart(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var prependSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n if (prependSize > padSize) {\n let repeatCount = (prependSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = prependSize - restBase;\n memory.repeat(out, changetype(padString), padSize, repeatCount);\n memory.copy(out + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out, changetype(padString), prependSize);\n }\n memory.copy(out + prependSize, changetype(this), thisSize);\n return changetype(out); // retains\n }\n\n padEnd(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var appendSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n memory.copy(out, changetype(this), thisSize);\n if (appendSize > padSize) {\n let repeatCount = (appendSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = appendSize - restBase;\n memory.repeat(out + thisSize, changetype(padString), padSize, repeatCount);\n memory.copy(out + thisSize + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out + thisSize, changetype(padString), appendSize);\n }\n return changetype(out); // retains\n }\n\n repeat(count: i32 = 0): String {\n assert(this !== null);\n var length = this.length;\n\n // Most browsers can\'t handle strings 1 << 28 chars or longer\n if (count < 0 || length * count > (1 << 28)) {\n throw new RangeError(E_INVALIDLENGTH);\n }\n\n if (count == 0 || !length) return changetype("");\n if (count == 1) return this;\n var out = __alloc((length * count) << 1, idof());\n memory.repeat(out, changetype(this), length << 1, count);\n return changetype(out); // retains\n }\n\n slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {\n var len = this.length;\n var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len);\n var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);\n len = end - begin;\n if (len <= 0) return changetype("");\n var out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (begin << 1), len << 1);\n return changetype(out); // retains\n }\n\n split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {\n assert(this !== null);\n if (!limit) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n if (separator === null) return [this];\n var length: isize = this.length;\n var sepLen: isize = separator.length;\n if (limit < 0) limit = i32.MAX_VALUE;\n if (!sepLen) {\n if (!length) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n // split by chars\n length = min(length, limit);\n let result = __allocArray(length, alignof(), idof>());\n let resultStart = changetype(result).dataStart;\n for (let i: isize = 0; i < length; ++i) {\n let charStr = __alloc(2, idof());\n store(charStr, load(changetype(this) + (i << 1)));\n store(resultStart + (i << alignof()), charStr); // result[i] = charStr\n if (isManaged()) __retain(charStr);\n }\n return changetype>(result); // retains\n } else if (!length) {\n let result = __allocArray(1, alignof(), idof>());\n store(changetype(result).dataStart, changetype("")); // static ""\n return changetype>(result); // retains\n }\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n var end = 0, start = 0, i = 0;\n while ((end = this.indexOf(separator, start)) != -1) {\n let len = end - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out));\n } else {\n result.push(changetype(""));\n }\n if (++i == limit) return changetype>(result); // retains\n start = end + sepLen;\n }\n if (!start) { // also means: loop above didn\'t do anything\n result.push(this);\n return changetype>(result); // retains\n }\n var len = length - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out)); // retains\n } else {\n result.push(changetype("")); // static ""\n }\n return changetype>(result); // retains\n // releases result\n }\n\n toString(): String {\n return this;\n }\n\n get lengthUTF8(): i32 {\n var len = 1; // null terminated\n var pos: usize = 0;\n var end = this.length;\n while (pos < end) {\n let c = load(changetype(this) + (pos << 1));\n if (c < 128) {\n len += 1; ++pos;\n } else if (c < 2048) {\n len += 2; ++pos;\n } else {\n if (\n (c & 0xFC00) == 0xD800 && pos + 1 < end &&\n (load(changetype(this) + ((pos + 1) << 1)) & 0xFC00) == 0xDC00\n ) {\n len += 4; pos += 2;\n } else {\n len += 3; ++pos;\n }\n }\n }\n return len;\n }\n\n static fromUTF8(ptr: usize, len: usize): String {\n if (len < 1) return changetype("");\n var ptrPos = 0;\n var buf = __alloc(len << 1, 0);\n var bufPos = 0;\n while (ptrPos < len) {\n let cp = load(ptr + ptrPos++);\n if (cp < 128) {\n store(buf + bufPos, cp);\n bufPos += 2;\n } else if (cp > 191 && cp < 224) {\n assert(ptrPos + 1 <= len);\n store(buf + bufPos, (cp & 31) << 6 | load(ptr + ptrPos++) & 63);\n bufPos += 2;\n } else if (cp > 239 && cp < 365) {\n assert(ptrPos + 3 <= len);\n cp = (\n (cp & 7) << 18 |\n (load(ptr + ptrPos++) & 63) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n ) - 0x10000;\n store(buf + bufPos, 0xD800 + (cp >> 10));\n bufPos += 2;\n store(buf + bufPos, 0xDC00 + (cp & 1023));\n bufPos += 2;\n } else {\n assert(ptrPos + 2 <= len);\n store(buf + bufPos,\n (cp & 15) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n );\n bufPos += 2;\n }\n }\n assert(ptrPos == len);\n var out = __alloc(bufPos, idof());\n memory.copy(out, buf, bufPos);\n __free(buf);\n return changetype(out); // retains\n }\n\n toUTF8(): usize {\n var buf = __alloc(this.lengthUTF8, 0);\n var pos: usize = 0;\n var end = this.length;\n var off: usize = 0;\n while (pos < end) {\n let c1 = load(changetype(this) + (pos << 1));\n if (c1 < 128) {\n store(buf + off, c1);\n ++off; ++pos;\n } else if (c1 < 2048) {\n let ptr = buf + off;\n store(ptr, c1 >> 6 | 192);\n store(ptr, c1 & 63 | 128, 1);\n off += 2; ++pos;\n } else {\n let ptr = buf + off;\n if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) {\n let c2 = load(changetype(this) + ((pos + 1) << 1));\n if ((c2 & 0xFC00) == 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n store(ptr, c1 >> 18 | 240);\n store(ptr, c1 >> 12 & 63 | 128, 1);\n store(ptr, c1 >> 6 & 63 | 128, 2);\n store(ptr, c1 & 63 | 128, 3);\n off += 4; pos += 2;\n continue;\n }\n }\n store(ptr, c1 >> 12 | 224);\n store(ptr, c1 >> 6 & 63 | 128, 1);\n store(ptr, c1 & 63 | 128, 2);\n off += 3; ++pos;\n }\n }\n store(buf + off, 0);\n return buf;\n }\n}\n\n// @ts-ignore: nolib\nexport type string = String;\n\nexport function parseInt(str: String, radix: i32 = 0): f64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI32(str: String, radix: i32 = 0): i32 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI64(str: String, radix: i32 = 0): i64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\n// FIXME: naive implementation\nexport function parseFloat(str: String): f64 {\n var len: i32 = str.length;\n if (!len) return NaN;\n\n var ptr = changetype(str);\n var code = load(ptr);\n\n // determine sign\n var sign: f64;\n if (code == CharCode.MINUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = 1;\n } else {\n sign = 1;\n }\n\n // calculate value\n var num: f64 = 0;\n while (len--) {\n code = load(ptr);\n if (code == CharCode.DOT) {\n ptr += 2;\n let fac: f64 = 0.1; // precision :(\n while (len--) {\n code = load(ptr);\n if (code == CharCode.E || code == CharCode.e) {\n assert(false); // TODO\n }\n code -= CharCode._0;\n if (code > 9) break;\n num += code * fac;\n fac *= 0.1;\n ptr += 2;\n }\n break;\n }\n code -= CharCode._0;\n if (code >= 10) break;\n num = (num * 10) + code;\n ptr += 2;\n }\n return sign * num;\n}\n',symbol:'import { Map } from "./map";\n\n// @ts-ignore: decorator\n@lazy\nvar stringToId: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar idToString: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar nextId: usize = 12; // Symbol.unscopables + 1\n\n@unmanaged @sealed abstract class _Symbol {\n\n // TODO: all of the following default symbols are unused currently yet add to\n // binary size if #toString becomes compiled. Ultimately we\'ll most likely want\n // to remove the unsupported ones and only keep what\'s actually supported.\n\n // @ts-ignore: decorator\n @lazy\n static readonly hasInstance: symbol = changetype(1);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isConcatSpreadable: symbol = changetype(2);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isRegExp: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly iterator: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly match: symbol = changetype(4);\n\n // @ts-ignore: decorator\n @lazy\n static readonly replace: symbol = changetype(5);\n\n // @ts-ignore: decorator\n @lazy\n static readonly search: symbol = changetype(6);\n\n // @ts-ignore: decorator\n @lazy\n static readonly species: symbol = changetype(7);\n\n // @ts-ignore: decorator\n @lazy\n static readonly split: symbol = changetype(8);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toPrimitive: symbol = changetype(9);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toStringTag: symbol = changetype(10);\n\n // @ts-ignore: decorator\n @lazy\n static readonly unscopables: symbol = changetype(11);\n\n static for(key: string): symbol {\n if (!stringToId) { stringToId = new Map(); idToString = new Map(); }\n else if (stringToId.has(key)) return changetype(stringToId.get(key));\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n stringToId.set(key, id);\n idToString.set(id, key);\n return changetype(id);\n }\n\n static keyFor(sym: symbol): string | null {\n return idToString !== null && idToString.has(changetype(sym))\n ? idToString.get(changetype(sym))\n : null;\n }\n\n toString(): string {\n var id = changetype(this);\n var str = "";\n switch (id) {\n case 1: { str = "hasInstance"; break; }\n case 2: { str = "isConcatSpreadable"; break; }\n case 3: { str = "isRegExp"; break; }\n case 4: { str = "match"; break; }\n case 5: { str = "replace"; break; }\n case 6: { str = "search"; break; }\n case 7: { str = "species"; break; }\n case 8: { str = "split"; break; }\n case 9: { str = "toPrimitive"; break; }\n case 10: { str = "toStringTag"; break; }\n case 11: { str = "unscopables"; break; }\n default: {\n if (idToString !== null && idToString.has(id)) str = idToString.get(id);\n break;\n }\n }\n return "Symbol(" + str + ")";\n }\n}\n\nexport function Symbol(description: string | null = null): symbol {\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n return changetype(id);\n}\n\nexport type Symbol = _Symbol;\n\n// @ts-ignore: nolib\nexport type symbol = _Symbol;\n',table:'import { E_NOTIMPLEMENTED } from "./util/error";\n\nexport namespace table {\n\n export function copy(dst: u32, src: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function drop(elementIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n}\n',typedarray:'import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { idof } from "./builtins";\nimport { ArrayBufferView } from "./arraybuffer";\n\nexport class Int8Array extends ArrayBufferView {\n [key: number]: i8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i8, b: i8) => i32 = COMPARATOR()): Int8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i8, index: i32, self: Int8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8Array extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8ClampedArray extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8ClampedArray {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8ClampedArray {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int16Array extends ArrayBufferView {\n [key: number]: i16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i16, b: i16) => i32 = COMPARATOR()): Int16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i16, index: i32, self: Int16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint16Array extends ArrayBufferView {\n [key: number]: u16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u16, b: u16) => i32 = COMPARATOR()): Uint16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u16, index: i32, self: Uint16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int32Array extends ArrayBufferView {\n [key: number]: i32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i32, b: i32) => i32 = COMPARATOR()): Int32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i32, index: i32, self: Int32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint32Array extends ArrayBufferView {\n [key: number]: u32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u32, b: u32) => i32 = COMPARATOR()): Uint32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u32, index: i32, self: Uint32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int64Array extends ArrayBufferView {\n [key: number]: i64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i64, b: i64) => i32 = COMPARATOR()): Int64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i64, index: i32, self: Int64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint64Array extends ArrayBufferView {\n [key: number]: u64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u64, b: u64) => i32 = COMPARATOR()): Uint64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u64, index: i32, self: Uint64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float32Array extends ArrayBufferView {\n [key: number]: f32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f32, b: f32) => i32 = COMPARATOR()): Float32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f32, index: i32, self: Float32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float64Array extends ArrayBufferView {\n [key: number]: f64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f64, b: f64) => i32 = COMPARATOR()): Float64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f64, index: i32, self: Float64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FILL(\n array: TArray,\n value: native,\n start: i32,\n end: i32\n): TArray {\n var dataStart = array.dataStart;\n var length = array.length;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) memory.fill(dataStart + start, value, (end - start));\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SORT(\n array: TArray,\n comparator: (a: T, b: T) => i32\n): TArray {\n var length = array.length;\n if (length <= 1) return array;\n var base = array.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b\n store(base, a); // arr[0] = a\n }\n return array;\n }\n SORT_IMPL(base, length, comparator);\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SUBARRAY(\n array: TArray,\n begin: i32,\n end: i32\n): TArray {\n var len = array.length;\n begin = begin < 0 ? max(len + begin, 0) : min(begin, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\n end = max(end, begin);\n var out = changetype(__alloc(offsetof(), idof())); // retains\n out.data = array.data; // retains\n out.dataStart = array.dataStart + (begin << alignof());\n out.dataLength = (end - begin) << alignof();\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE_RIGHT(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = array.length - 1; i >= 0; i--) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction MAP(\n array: TArray,\n callbackfn: (value: T, index: i32, self: TArray) => T,\n): TArray {\n var length = array.length;\n var dataStart = array.dataStart;\n var out = instantiate(length);\n var outDataStart = out.dataStart;\n for (let i = 0; i < length; i++) {\n store(\n outDataStart + (i << alignof()),\n callbackfn(load(dataStart + (i << alignof())), i, array)\n );\n }\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FIND_INDEX(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): i32 {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return i;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SOME(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return true;\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction EVERY(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) continue;\n return false;\n }\n return true;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FOREACH(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => void,\n): void {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n callbackfn(load(dataStart + (i << alignof())), i, array);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function REVERSE(array: TArray): TArray {\n var dataStart = array.dataStart;\n for (let front = 0, back = array.length - 1; front < back; ++front, --back) {\n let frontPtr = dataStart + (front << alignof());\n let backPtr = dataStart + (back << alignof());\n let temp = load(frontPtr);\n store(frontPtr, load(backPtr));\n store(backPtr, temp);\n }\n return array;\n}\n',"util/error":'// Common error messages for use accross the standard library. Keeping error messages compact\n// and reusing them where possible ensures minimal static data in binaries.\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INDEXOUTOFRANGE: string = "Index out of range";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INVALIDLENGTH: string = "Invalid length";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_EMPTYARRAY: string = "Array is empty";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_HOLEYARRAY: string = "Element type must be nullable if array is holey";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_NOTIMPLEMENTED: string = "Not implemented";\n',"util/hash":"// @ts-ignore: decorator\n@inline\nexport function HASH(key: T): u32 {\n if (isString()) {\n return hashStr(changetype(key));\n } else if (isReference()) {\n if (sizeof() == 4) return hash32(changetype(key));\n if (sizeof() == 8) return hash64(changetype(key));\n } else if (isFloat()) {\n if (sizeof() == 4) return hash32(reinterpret(f32(key)));\n if (sizeof() == 8) return hash64(reinterpret(f64(key)));\n } else {\n if (sizeof() == 1) return hash8 (u32(key));\n if (sizeof() == 2) return hash16(u32(key));\n if (sizeof() == 4) return hash32(u32(key));\n if (sizeof() == 8) return hash64(u64(key));\n }\n return unreachable();\n}\n\n// FNV-1a 32-bit as a starting point, see: http://isthe.com/chongo/tech/comp/fnv/\n\n// @ts-ignore: decorator\n@inline\nconst FNV_OFFSET: u32 = 2166136261;\n\n// @ts-ignore: decorator\n@inline\nconst FNV_PRIME: u32 = 16777619;\n\nfunction hash8(key: u32): u32 {\n return (FNV_OFFSET ^ key) * FNV_PRIME;\n}\n\nfunction hash16(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 8 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash32(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash64(key: u64): u32 {\n var l = key;\n var h = (key >>> 32);\n var v = FNV_OFFSET;\n v = (v ^ ( l & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( l >> 24 )) * FNV_PRIME;\n v = (v ^ ( h & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( h >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hashStr(key: string): u32 {\n var v = FNV_OFFSET;\n if (key !== null) {\n for (let i: usize = 0, k: usize = key.length << 1; i < k; ++i) {\n v = (v ^ load(changetype(key) + i)) * FNV_PRIME;\n }\n }\n return v;\n}\n","util/memory":"export function memcpy(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memcpy.c\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n let w: u32, x: u32;\n\n // copy 1 byte each until src is aligned to 4 bytes\n while (n && (src & 3)) {\n store(dest++, load(src++));\n n--;\n }\n\n // if dst is aligned to 4 bytes as well, copy 4 bytes each\n if ((dest & 3) == 0) {\n while (n >= 16) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n store(dest + 8, load(src + 8));\n store(dest + 12, load(src + 12));\n src += 16; dest += 16; n -= 16;\n }\n if (n & 8) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n dest += 8; src += 8;\n }\n if (n & 4) {\n store(dest, load(src));\n dest += 4; src += 4;\n }\n if (n & 2) { // drop to 2 bytes each\n store(dest, load(src));\n dest += 2; src += 2;\n }\n if (n & 1) { // drop to 1 byte\n store(dest++, load(src++));\n }\n return;\n }\n\n // if dst is not aligned to 4 bytes, use alternating shifts to copy 4 bytes each\n // doing shifts if faster when copying enough bytes (here: 32 or more)\n if (n >= 32) {\n switch (dest & 3) {\n // known to be != 0\n case 1: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 3;\n while (n >= 17) {\n x = load(src + 1);\n store(dest, w >> 24 | x << 8);\n w = load(src + 5);\n store(dest + 4, x >> 24 | w << 8);\n x = load(src + 9);\n store(dest + 8, w >> 24 | x << 8);\n w = load(src + 13);\n store(dest + 12, x >> 24 | w << 8);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 2: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 2;\n while (n >= 18) {\n x = load(src + 2);\n store(dest, w >> 16 | x << 16);\n w = load(src + 6);\n store(dest + 4, x >> 16 | w << 16);\n x = load(src + 10);\n store(dest + 8, w >> 16 | x << 16);\n w = load(src + 14);\n store(dest + 12, x >> 16 | w << 16);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 3: {\n w = load(src);\n store(dest++, load(src++));\n n -= 1;\n while (n >= 19) {\n x = load(src + 3);\n store(dest, w >> 8 | x << 24);\n w = load(src + 7);\n store(dest + 4, x >> 8 | w << 24);\n x = load(src + 11);\n store(dest + 8, w >> 8 | x << 24);\n w = load(src + 15);\n store(dest + 12, x >> 8 | w << 24);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n }\n }\n\n // copy remaining bytes one by one\n if (n & 16) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 8) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 4) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 2) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 1) {\n store(dest++, load(src++));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memmove(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memmove.c\n if (dest === src) return;\n if (ASC_SHRINK_LEVEL < 1) {\n if (src + n <= dest || dest + n <= src) {\n memcpy(dest, src, n);\n return;\n }\n }\n if (dest < src) {\n if ((src & 7) == (dest & 7)) {\n while (dest & 7) {\n if (!n) return;\n --n;\n store(dest++, load(src++));\n }\n while (n >= 8) {\n store(dest, load(src));\n n -= 8;\n dest += 8;\n src += 8;\n }\n }\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n if ((src & 7) == (dest & 7)) {\n while ((dest + n) & 7) {\n if (!n) return;\n store(dest + --n, load(src + n));\n }\n while (n >= 8) {\n n -= 8;\n store(dest + n, load(src + n));\n }\n }\n while (n) {\n store(dest + --n, load(src + n));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/string/memset\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, c);\n --n;\n }\n } else {\n // fill head and tail with minimal branching\n if (!n) return;\n store(dest, c);\n store(dest + n - 1, c);\n if (n <= 2) return;\n\n store(dest + 1, c);\n store(dest + 2, c);\n store(dest + n - 2, c);\n store(dest + n - 3, c);\n if (n <= 6) return;\n store(dest + 3, c);\n store(dest + n - 4, c);\n if (n <= 8) return;\n\n // advance pointer to align it at 4-byte boundary\n let k: usize = -dest & 3;\n dest += k;\n n -= k;\n n &= -4;\n\n let c32: u32 = -1 / 255 * c;\n\n // fill head/tail up to 28 bytes each in preparation\n store(dest, c32);\n store(dest + n - 4, c32);\n if (n <= 8) return;\n store(dest + 4, c32);\n store(dest + 8, c32);\n store(dest + n - 12, c32);\n store(dest + n - 8, c32);\n if (n <= 24) return;\n store(dest + 12, c32);\n store(dest + 16, c32);\n store(dest + 20, c32);\n store(dest + 24, c32);\n store(dest + n - 28, c32);\n store(dest + n - 24, c32);\n store(dest + n - 20, c32);\n store(dest + n - 16, c32);\n\n // align to a multiple of 8\n k = 24 + (dest & 4);\n dest += k;\n n -= k;\n\n // copy 32 bytes each\n let c64: u64 = c32 | (c32 << 32);\n while (n >= 32) {\n store(dest, c64);\n store(dest + 8, c64);\n store(dest + 16, c64);\n store(dest + 24, c64);\n n -= 32;\n dest += 32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memcmp(vl: usize, vr: usize, n: usize): i32 { // see: musl/src/string/memcmp.c\n if (vl == vr) return 0;\n while (n != 0 && load(vl) == load(vr)) {\n n--; vl++; vr++;\n }\n return n ? load(vl) - load(vr) : 0;\n}\n","util/number":'/// \n\nimport { idof } from "../builtins";\nimport { CharCode } from "./string";\nimport { ArrayBufferView } from "../arraybuffer";\n\n// @ts-ignore: decorator\n@inline\nexport const MAX_DOUBLE_LENGTH = 28;\n\n// @ts-ignore: decorator\n@lazy @inline\nconst POWERS10: u32[] = [\n 1,\n 10,\n 100,\n 1000,\n 10000,\n 100000,\n 1000000,\n 10000000,\n 100000000,\n 1000000000\n];\n\n/*\n Lookup table for pairwise char codes in range [0-99]\n\n "00", "01", "02", "03", "04", "05", "06", "07", "08", "09",\n "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",\n "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",\n "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",\n "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",\n "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",\n "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",\n "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",\n "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",\n "90", "91", "92", "93", "94", "95", "96", "97", "98", "99"\n*/\n// @ts-ignore: decorator\n@lazy @inline\nconst DIGITS: u32[] = [\n 0x00300030, 0x00310030, 0x00320030, 0x00330030, 0x00340030,\n 0x00350030, 0x00360030, 0x00370030, 0x00380030, 0x00390030,\n 0x00300031, 0x00310031, 0x00320031, 0x00330031, 0x00340031,\n 0x00350031, 0x00360031, 0x00370031, 0x00380031, 0x00390031,\n 0x00300032, 0x00310032, 0x00320032, 0x00330032, 0x00340032,\n 0x00350032, 0x00360032, 0x00370032, 0x00380032, 0x00390032,\n 0x00300033, 0x00310033, 0x00320033, 0x00330033, 0x00340033,\n 0x00350033, 0x00360033, 0x00370033, 0x00380033, 0x00390033,\n 0x00300034, 0x00310034, 0x00320034, 0x00330034, 0x00340034,\n 0x00350034, 0x00360034, 0x00370034, 0x00380034, 0x00390034,\n 0x00300035, 0x00310035, 0x00320035, 0x00330035, 0x00340035,\n 0x00350035, 0x00360035, 0x00370035, 0x00380035, 0x00390035,\n 0x00300036, 0x00310036, 0x00320036, 0x00330036, 0x00340036,\n 0x00350036, 0x00360036, 0x00370036, 0x00380036, 0x00390036,\n 0x00300037, 0x00310037, 0x00320037, 0x00330037, 0x00340037,\n 0x00350037, 0x00360037, 0x00370037, 0x00380037, 0x00390037,\n 0x00300038, 0x00310038, 0x00320038, 0x00330038, 0x00340038,\n 0x00350038, 0x00360038, 0x00370038, 0x00380038, 0x00390038,\n 0x00300039, 0x00310039, 0x00320039, 0x00330039, 0x00340039,\n 0x00350039, 0x00360039, 0x00370039, 0x00380039, 0x00390039\n];\n\n// @ts-ignore: decorator\n@lazy @inline\nconst EXP_POWERS: i16[] = [\n -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980,\n -954, -927, -901, -874, -847, -821, -794, -768, -741, -715,\n -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,\n -422, -396, -369, -343, -316, -289, -263, -236, -210, -183,\n -157, -130, -103, -77, -50, -24, 3, 30, 56, 83,\n 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,\n 375, 402, 428, 455, 481, 508, 534, 561, 588, 614,\n 641, 667, 694, 720, 747, 774, 800, 827, 853, 880,\n 907, 933, 960, 986, 1013, 1039, 1066\n];\n\n// 1e-348, 1e-340, ..., 1e340\n// @ts-ignore: decorator\n@lazy @inline\nconst FRC_POWERS: u64[] = [\n 0xFA8FD5A0081C0288, 0xBAAEE17FA23EBF76, 0x8B16FB203055AC76, 0xCF42894A5DCE35EA,\n 0x9A6BB0AA55653B2D, 0xE61ACF033D1A45DF, 0xAB70FE17C79AC6CA, 0xFF77B1FCBEBCDC4F,\n 0xBE5691EF416BD60C, 0x8DD01FAD907FFC3C, 0xD3515C2831559A83, 0x9D71AC8FADA6C9B5,\n 0xEA9C227723EE8BCB, 0xAECC49914078536D, 0x823C12795DB6CE57, 0xC21094364DFB5637,\n 0x9096EA6F3848984F, 0xD77485CB25823AC7, 0xA086CFCD97BF97F4, 0xEF340A98172AACE5,\n 0xB23867FB2A35B28E, 0x84C8D4DFD2C63F3B, 0xC5DD44271AD3CDBA, 0x936B9FCEBB25C996,\n 0xDBAC6C247D62A584, 0xA3AB66580D5FDAF6, 0xF3E2F893DEC3F126, 0xB5B5ADA8AAFF80B8,\n 0x87625F056C7C4A8B, 0xC9BCFF6034C13053, 0x964E858C91BA2655, 0xDFF9772470297EBD,\n 0xA6DFBD9FB8E5B88F, 0xF8A95FCF88747D94, 0xB94470938FA89BCF, 0x8A08F0F8BF0F156B,\n 0xCDB02555653131B6, 0x993FE2C6D07B7FAC, 0xE45C10C42A2B3B06, 0xAA242499697392D3,\n 0xFD87B5F28300CA0E, 0xBCE5086492111AEB, 0x8CBCCC096F5088CC, 0xD1B71758E219652C,\n 0x9C40000000000000, 0xE8D4A51000000000, 0xAD78EBC5AC620000, 0x813F3978F8940984,\n 0xC097CE7BC90715B3, 0x8F7E32CE7BEA5C70, 0xD5D238A4ABE98068, 0x9F4F2726179A2245,\n 0xED63A231D4C4FB27, 0xB0DE65388CC8ADA8, 0x83C7088E1AAB65DB, 0xC45D1DF942711D9A,\n 0x924D692CA61BE758, 0xDA01EE641A708DEA, 0xA26DA3999AEF774A, 0xF209787BB47D6B85,\n 0xB454E4A179DD1877, 0x865B86925B9BC5C2, 0xC83553C5C8965D3D, 0x952AB45CFA97A0B3,\n 0xDE469FBD99A05FE3, 0xA59BC234DB398C25, 0xF6C69A72A3989F5C, 0xB7DCBF5354E9BECE,\n 0x88FCF317F22241E2, 0xCC20CE9BD35C78A5, 0x98165AF37B2153DF, 0xE2A0B5DC971F303A,\n 0xA8D9D1535CE3B396, 0xFB9B7CD9A4A7443C, 0xBB764C4CA7A44410, 0x8BAB8EEFB6409C1A,\n 0xD01FEF10A657842C, 0x9B10A4E5E9913129, 0xE7109BFBA19C0C9D, 0xAC2820D9623BF429,\n 0x80444B5E7AA7CF85, 0xBF21E44003ACDD2D, 0x8E679C2F5E44FF8F, 0xD433179D9C8CB841,\n 0x9E19DB92B4E31BA9, 0xEB96BF6EBADF77D9, 0xAF87023B9BF0EE6B\n];\n\n// Count number of decimals for u32 values\n// In our case input value always non-zero so we can simplify some parts\nexport function decimalCount32(value: u32): u32 {\n if (value < 100000) {\n if (value < 100) {\n return select(1, 2, value < 10);\n } else {\n let m = select(4, 5, value < 10000);\n return select(3, m, value < 1000);\n }\n } else {\n if (value < 10000000) {\n return select(6, 7, value < 1000000);\n } else {\n let m = select(9, 10, value < 1000000000);\n return select(8, m, value < 100000000);\n }\n }\n}\n\n// Count number of decimals for u64 values\n// In our case input value always greater than 2^32-1 so we can skip some parts\nexport function decimalCount64(value: u64): u32 {\n if (value < 1000000000000000) {\n if (value < 1000000000000) {\n return select(11, 12, value < 100000000000);\n } else {\n let m = select(14, 15, value < 100000000000000);\n return select(13, m, value < 10000000000000);\n }\n } else {\n if (value < 100000000000000000) {\n return select(16, 17, value < 10000000000000000);\n } else {\n let m = select(19, 20, value < 10000000000000000000);\n return select(18, m, value < 1000000000000000000);\n }\n }\n}\n\nfunction utoa32_lut(buffer: usize, num: u32, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 10000) {\n // in most VMs i32/u32 div and modulo by constant can be shared and simplificate\n let t = num / 10000;\n let r = num % 10000;\n num = t;\n\n let d1 = r / 100;\n let d2 = r % 100;\n\n let digits1 = load(lut + (d1 << alignof()));\n let digits2 = load(lut + (d2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n if (num >= 100) {\n let t = num / 100;\n let d1 = num % 100;\n num = t;\n offset -= 2;\n let digits = load(lut + (d1 << alignof()));\n store(buffer + (offset << 1), digits);\n }\n\n if (num >= 10) {\n offset -= 2;\n let digits = load(lut + (num << alignof()));\n store(buffer + (offset << 1), digits);\n } else {\n offset -= 1;\n let digit = CharCode._0 + num;\n store(buffer + (offset << 1), digit);\n }\n}\n\nfunction utoa64_lut(buffer: usize, num: u64, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 100000000) {\n let t = num / 100000000;\n let r = (num - t * 100000000);\n num = t;\n\n let b = r / 10000;\n let c = r % 10000;\n\n let b1 = b / 100;\n let b2 = b % 100;\n let c1 = c / 100;\n let c2 = c % 100;\n\n let digits1 = load(lut + (c1 << alignof()));\n let digits2 = load(lut + (c2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n\n digits1 = load(lut + (b1 << alignof()));\n digits2 = load(lut + (b2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n utoa32_lut(buffer, num, offset);\n}\n\nfunction utoa_simple(buffer: usize, num: T, offset: usize): void {\n do {\n let t = num / 10;\n let r = (num % 10);\n num = changetype(t);\n offset -= 1;\n store(buffer + (offset << 1), CharCode._0 + r);\n } while (num);\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa32_core(buffer: usize, num: u32, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa32_lut(buffer, num, offset);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa64_core(buffer: usize, num: u64, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa64_lut(buffer, num, offset);\n }\n}\n\nexport function utoa32(value: u32): String {\n if (!value) return "0";\n\n var decimals = decimalCount32(value);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n return changetype(out); // retains\n}\n\nexport function itoa32(value: i32): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var decimals = decimalCount32(value) + u32(sign);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n if (sign) store(out, CharCode.MINUS);\n return changetype(out); // retains\n}\n\nexport function utoa64(value: u64): String {\n if (!value) return "0";\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n return changetype(out); // retains\n}\n\nexport function itoa64(value: i64): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n if (sign) store(out, CharCode.MINUS);\n\n return changetype(out); // retains\n}\n\nexport function itoa(value: T): String {\n if (!isInteger()) ERROR("integer type expected");\n if (isSigned()) {\n if (sizeof() <= 4) {\n return itoa32(value);\n } else {\n return itoa64(value);\n }\n } else {\n if (sizeof() <= 4) {\n return utoa32(value);\n } else {\n return utoa64(value);\n }\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar _K: i32 = 0;\n\n// // @ts-ignore: decorator\n// @lazy\n// var _frc: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp: i32 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_minus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_plus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_pow: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp_pow: i32 = 0;\n\n// @ts-ignore: decorator\n@inline\nfunction umul64f(u: u64, v: u64): u64 {\n var u0 = u & 0xFFFFFFFF;\n var v0 = v & 0xFFFFFFFF;\n\n var u1 = u >> 32;\n var v1 = v >> 32;\n\n var l = u0 * v0;\n var t = u1 * v0 + (l >> 32);\n var w = u0 * v1 + (t & 0xFFFFFFFF);\n\n w += 0x7FFFFFFF; // rounding\n\n t >>= 32;\n w >>= 32;\n\n return u1 * v1 + t + w;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction umul64e(e1: i32, e2: i32): i32 {\n return e1 + e2 + 64; // where 64 is significand size\n}\n\n// @ts-ignore: decorator\n@inline\nfunction normalizedBoundaries(f: u64, e: i32): void {\n var frc = (f << 1) + 1;\n var exp = e - 1;\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var m = 1 + i32(f == 0x0010000000000000);\n\n _frc_plus = frc;\n _frc_minus = ((f << m) - 1) << e - m - exp;\n _exp = exp;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisuRound(buffer: usize, len: i32, delta: u64, rest: u64, ten_kappa: u64, wp_w: u64): void {\n var lastp = buffer + ((len - 1) << 1);\n var digit = load(lastp);\n while (\n rest < wp_w &&\n delta - rest >= ten_kappa && (\n rest + ten_kappa < wp_w ||\n wp_w - rest > rest + ten_kappa - wp_w\n )\n ) {\n --digit;\n rest += ten_kappa;\n }\n store(lastp, digit);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction getCachedPower(minExp: i32): void {\n const c = reinterpret(0x3FD34413509F79FE); // 1 / lg(10) = 0.30102999566398114\n var dk = (-61 - minExp) * c + 347;\t // dk must be positive, so can do ceiling in positive\n var k = dk;\n k += i32(k != dk); // conversion with ceil\n\n var index = (k >> 3) + 1;\n _K = 348 - (index << 3);\t// decimal exponent no need lookup table\n _frc_pow = unchecked(FRC_POWERS[index]);\n _exp_pow = unchecked(EXP_POWERS[index]);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisu2(value: f64, buffer: usize, sign: i32): i32 {\n\n // frexp routine\n var uv = reinterpret(value);\n var exp = ((uv & 0x7FF0000000000000) >>> 52);\n var sid = uv & 0x000FFFFFFFFFFFFF;\n var frc = (u64(exp != 0) << 52) + sid;\n exp = select(exp, 1, exp != 0) - (0x3FF + 52);\n\n normalizedBoundaries(frc, exp);\n getCachedPower(_exp);\n\n // normalize\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var frc_pow = _frc_pow;\n var exp_pow = _exp_pow;\n\n var w_frc = umul64f(frc, frc_pow);\n var w_exp = umul64e(exp, exp_pow);\n\n var wp_frc = umul64f(_frc_plus, frc_pow) - 1;\n var wp_exp = umul64e(_exp, exp_pow);\n\n var wm_frc = umul64f(_frc_minus, frc_pow) + 1;\n var delta = wp_frc - wm_frc;\n\n return genDigits(buffer, w_frc, w_exp, wp_frc, wp_exp, delta, sign);\n}\n\nfunction genDigits(buffer: usize, w_frc: u64, w_exp: i32, mp_frc: u64, mp_exp: i32, delta: u64, sign: i32): i32 {\n var one_exp = -mp_exp;\n var one_frc = (1) << one_exp;\n var mask = one_frc - 1;\n\n var wp_w_frc = mp_frc - w_frc;\n var wp_w_exp = mp_exp;\n\n var p1 = (mp_frc >> one_exp);\n var p2 = mp_frc & mask;\n\n var kappa = decimalCount32(p1);\n var len = sign;\n\n var lut = changetype(POWERS10).dataStart;\n\n while (kappa > 0) {\n let d: u32;\n switch (kappa) {\n case 10: { d = p1 / 1000000000; p1 %= 1000000000; break; }\n case 9: { d = p1 / 100000000; p1 %= 100000000; break; }\n case 8: { d = p1 / 10000000; p1 %= 10000000; break; }\n case 7: { d = p1 / 1000000; p1 %= 1000000; break; }\n case 6: { d = p1 / 100000; p1 %= 100000; break; }\n case 5: { d = p1 / 10000; p1 %= 10000; break; }\n case 4: { d = p1 / 1000; p1 %= 1000; break; }\n case 3: { d = p1 / 100; p1 %= 100; break; }\n case 2: { d = p1 / 10; p1 %= 10; break; }\n case 1: { d = p1; p1 = 0; break; }\n default: { d = 0; break; }\n }\n\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n --kappa;\n let tmp = ((p1) << one_exp) + p2;\n if (tmp <= delta) {\n _K += kappa;\n grisuRound(buffer, len, delta, tmp, load(lut + (kappa << alignof())) << one_exp, wp_w_frc);\n return len;\n }\n }\n\n while (1) {\n p2 *= 10;\n delta *= 10;\n\n let d = p2 >> one_exp;\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n p2 &= mask;\n --kappa;\n if (p2 < delta) {\n _K += kappa;\n wp_w_frc *= load(lut + (-kappa << alignof()));\n grisuRound(buffer, len, delta, p2, one_frc, wp_w_frc);\n return len;\n }\n }\n\n return len;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction genExponent(buffer: usize, k: i32): i32 {\n var sign = k < 0;\n if (sign) k = -k;\n var decimals = decimalCount32(k) + 1;\n utoa32_core(buffer, k, decimals);\n store(buffer, select(CharCode.MINUS, CharCode.PLUS, sign));\n return decimals;\n}\n\nfunction prettify(buffer: usize, length: i32, k: i32): i32 {\n if (!k) {\n store(buffer + (length << 1), CharCode.DOT | (CharCode._0 << 16));\n return length + 2;\n }\n\n var kk = length + k;\n if (length <= kk && kk <= 21) {\n // 1234e7 -> 12340000000\n for (let i = length; i < kk; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n store(buffer + (kk << 1), CharCode.DOT | (CharCode._0 << 16));\n return kk + 2;\n } else if (kk > 0 && kk <= 21) {\n // 1234e-2 -> 12.34\n let ptr = buffer + (kk << 1);\n memory.copy(\n ptr + 2,\n ptr,\n -k << 1\n );\n store(buffer + (kk << 1), CharCode.DOT);\n return length + 1;\n } else if (-6 < kk && kk <= 0) {\n // 1234e-6 -> 0.001234\n let offset = 2 - kk;\n memory.copy(\n buffer + (offset << 1),\n buffer,\n length << 1\n );\n store(buffer, CharCode._0 | (CharCode.DOT << 16));\n for (let i = 2; i < offset; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n return length + offset;\n } else if (length == 1) {\n // 1e30\n store(buffer, CharCode.e, 2);\n length = genExponent(buffer + 4, kk - 1);\n return length + 2;\n } else {\n let len = length << 1;\n memory.copy(\n buffer + 4,\n buffer + 2,\n len - 2\n );\n store(buffer, CharCode.DOT, 2);\n store(buffer + len, CharCode.e, 2);\n length += genExponent(buffer + len + 4, kk - 1);\n return length + 2;\n }\n}\n\nexport function dtoa_core(buffer: usize, value: f64): i32 {\n var sign = i32(value < 0);\n if (sign) {\n value = -value;\n store(buffer, CharCode.MINUS);\n }\n // assert(value > 0 && value <= 1.7976931348623157e308);\n var len = grisu2(value, buffer, sign);\n len = prettify(buffer + (sign << 1), len - sign, _K);\n return len + sign;\n}\n\nexport function dtoa(value: f64): String {\n if (value == 0) return "0.0";\n if (!isFinite(value)) {\n if (isNaN(value)) return "NaN";\n return select("-Infinity", "Infinity", value < 0);\n }\n var buffer = __alloc(MAX_DOUBLE_LENGTH << 1, idof());\n var length = dtoa_core(buffer, value);\n if (length == MAX_DOUBLE_LENGTH) return changetype(buffer);\n var result = changetype(buffer).substring(0, length);\n __free(buffer);\n return result;\n}\n\nexport function itoa_stream(buffer: usize, offset: usize, value: T): u32 {\n buffer += (offset << 1);\n if (!value) {\n store(buffer, CharCode._0);\n return 1;\n }\n var decimals: u32 = 0;\n if (isSigned()) {\n let sign = i32(value < 0);\n if (sign) value = changetype(-value);\n if (sizeof() <= 4) {\n decimals = decimalCount32(value) + sign;\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32) + sign;\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value) + sign;\n utoa64_core(buffer, value, decimals);\n }\n }\n if (sign) store(buffer, CharCode.MINUS);\n } else {\n if (sizeof() <= 4) {\n decimals = decimalCount32(value);\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32);\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value);\n utoa64_core(buffer, value, decimals);\n }\n }\n }\n return decimals;\n}\n\nexport function dtoa_stream(buffer: usize, offset: usize, value: f64): u32 {\n buffer += (offset << 1);\n if (value == 0.0) {\n store(buffer, CharCode._0);\n store(buffer, CharCode.DOT, 2);\n store(buffer, CharCode._0, 4);\n return 3;\n }\n if (!isFinite(value)) {\n if (isNaN(value)) {\n store(buffer, CharCode.N);\n store(buffer, CharCode.a, 2);\n store(buffer, CharCode.N, 4);\n return 3;\n } else {\n let sign = i32(value < 0);\n let len = 8 + sign;\n memory.copy(buffer, changetype(select("-Infinity", "Infinity", sign)), len << 1);\n return len;\n }\n }\n return dtoa_core(buffer, value);\n}\n',"util/sort":'import { compareImpl } from "./string";\n\n// @ts-ignore: decorator\n@inline\nexport function COMPARATOR(): (a: T, b: T) => i32 {\n if (isInteger()) {\n if (isSigned() && sizeof() <= 4) {\n return (a: T, b: T): i32 => (i32(a) - i32(b));\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n } else if (isFloat()) {\n if (sizeof() == 4) {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f32(a));\n var ib = reinterpret(f32(b));\n ia ^= (ia >> 31) >>> 1;\n ib ^= (ib >> 31) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n } else {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f64(a));\n var ib = reinterpret(f64(b));\n ia ^= (ia >> 63) >>> 1;\n ib ^= (ib >> 63) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n }\n } else if (isString()) {\n return (a: T, b: T): i32 => {\n if (a === b || a === null || b === null) return 0;\n var alen = changetype(a).length;\n var blen = changetype(b).length;\n if (!alen && !blen) return 0;\n if (!alen) return -1;\n if (!blen) return 1;\n return compareImpl(changetype(a), 0, changetype(b), 0, min(alen, blen));\n };\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function SORT(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n if (isReference()) {\n // TODO replace this to faster stable sort (TimSort) when it implemented\n insertionSort(dataStart, length, comparator);\n } else {\n if (length < 256) {\n insertionSort(dataStart, length, comparator);\n } else {\n weakHeapSort(dataStart, length, comparator);\n }\n }\n}\n\nfunction insertionSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n for (let i = 0; i < length; i++) {\n let a: T = load(dataStart + (i << alignof())); // a = arr[i]\n let j = i - 1;\n while (j >= 0) {\n let b: T = load(dataStart + (j << alignof())); // b = arr[j]\n if (comparator(a, b) < 0) {\n store(dataStart + ((j-- + 1) << alignof()), b); // arr[j + 1] = b\n } else break;\n }\n store(dataStart + ((j + 1) << alignof()), a); // arr[j + 1] = a\n }\n}\n\nfunction weakHeapSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n const shift32 = alignof();\n\n var bitsetSize = (length + 31) >> 5 << shift32;\n var bitset = __alloc(bitsetSize, 0); // indexed in 32-bit chunks below\n memory.fill(bitset, 0, bitsetSize);\n\n // see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf\n\n for (let i = length - 1; i > 0; i--) {\n let j = i;\n while ((j & 1) == (load(bitset + (j >> 6 << shift32)) >> (j >> 1 & 31) & 1)) j >>= 1;\n\n let p = j >> 1;\n let a: T = load(dataStart + (p << alignof())); // a = arr[p]\n let b: T = load(dataStart + (i << alignof())); // b = arr[i]\n if (comparator(a, b) < 0) {\n store(\n bitset + (i >> 5 << shift32),\n load(bitset + (i >> 5 << shift32)) ^ (1 << (i & 31))\n );\n store(dataStart + (i << alignof()), a); // arr[i] = a\n store(dataStart + (p << alignof()), b); // arr[p] = b\n }\n }\n\n for (let i = length - 1; i >= 2; i--) {\n let a: T = load(dataStart); // a = arr[0]\n store(dataStart, load(dataStart + (i << alignof()))); // arr[0] = arr[i]\n store(dataStart + (i << alignof()), a); // arr[i] = a\n\n let x = 1, y: i32;\n while ((y = (x << 1) + ((load(bitset + (x >> 5 << shift32)) >> (x & 31)) & 1)) < i) x = y;\n\n while (x > 0) {\n a = load(dataStart); // a = arr[0]\n let b: T = load(dataStart + (x << alignof())); // b = arr[x]\n\n if (comparator(a, b) < 0) {\n store(\n bitset + (x >> 5 << shift32),\n load(bitset + (x >> 5 << shift32)) ^ (1 << (x & 31))\n );\n store(dataStart + (x << alignof()), a); // arr[x] = a\n store(dataStart, b); // arr[0] = b\n }\n x >>= 1;\n }\n }\n\n __free(bitset);\n\n var t: T = load(dataStart, sizeof()); // t = arr[1]\n store(dataStart, load(dataStart), sizeof()); // arr[1] = arr[0]\n store(dataStart, t); // arr[0] = t\n}\n',"util/string":"export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {\n var result: i32 = 0;\n var ptr1 = changetype(str1) + (index1 << 1);\n var ptr2 = changetype(str2) + (index2 << 1);\n while (len && !(result = load(ptr1) - load(ptr2))) {\n --len, ptr1 += 2, ptr2 += 2;\n }\n return result;\n}\n\n// @ts-ignore: decorator\n@inline\nexport const enum CharCode {\n PLUS = 0x2B,\n MINUS = 0x2D,\n DOT = 0x2E,\n _0 = 0x30,\n _1 = 0x31,\n _2 = 0x32,\n _3 = 0x33,\n _4 = 0x34,\n _5 = 0x35,\n _6 = 0x36,\n _7 = 0x37,\n _8 = 0x38,\n _9 = 0x39,\n A = 0x41,\n B = 0x42,\n E = 0x45,\n N = 0x4E,\n O = 0x4F,\n X = 0x58,\n Z = 0x5a,\n a = 0x61,\n b = 0x62,\n e = 0x65,\n n = 0x6E,\n o = 0x6F,\n x = 0x78,\n z = 0x7A\n}\n\nexport function isWhiteSpaceOrLineTerminator(c: u16): bool {\n switch (c) {\n case 9: // \n case 10: // \n case 13: // \n case 11: // \n case 12: // \n case 32: // \n case 160: // \n case 8232: // \n case 8233: // \n case 65279: return true; // \n default: return false;\n }\n}\n\n/** Parses a string to an integer (usually), using the specified radix. */\nexport function parse(str: string, radix: i32 = 0): T {\n var len: i32 = str.length;\n // @ts-ignore: cast\n if (!len) return NaN;\n\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr);\n\n // determine sign\n var sign: T;\n if (code == CharCode.MINUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = -1;\n } else if (code == CharCode.PLUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = 1;\n } else {\n // @ts-ignore: type\n sign = 1;\n }\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2)) {\n case CharCode.B:\n case CharCode.b: {\n ptr += 4; len -= 2;\n radix = 2;\n break;\n }\n case CharCode.O:\n case CharCode.o: {\n ptr += 4; len -= 2;\n radix = 8;\n break;\n }\n case CharCode.X:\n case CharCode.x: {\n ptr += 4; len -= 2;\n radix = 16;\n break;\n }\n default: radix = 10;\n }\n } else radix = 10;\n } else if (radix < 2 || radix > 36) {\n // @ts-ignore: cast\n return NaN;\n }\n\n // calculate value\n // @ts-ignore: type\n var num: T = 0;\n while (len--) {\n code = load(ptr);\n if (code >= CharCode._0 && code <= CharCode._9) {\n code -= CharCode._0;\n } else if (code >= CharCode.A && code <= CharCode.Z) {\n code -= CharCode.A - 10;\n } else if (code >= CharCode.a && code <= CharCode.z) {\n code -= CharCode.a - 10;\n } else break;\n if (code >= radix) break;\n // @ts-ignore: type\n num = (num * radix) + code;\n ptr += 2;\n }\n // @ts-ignore: type\n return sign * num;\n}\n",vector:"/** Vector abstraction. */\n@sealed export class V128 {\n}\n"}):(()=>{const n=path.join(".","..","std","assembly"),e=__webpack_require__(!function(){var n=new Error("Cannot find module 'glob'");throw n.code="MODULE_NOT_FOUND",n}()).sync("**/!(*.d).ts",{cwd:n}),t={};return e.forEach(e=>t[e.replace(/\.ts$/,"")]=fs.readFileSync(path.join(n,e),"utf8")),t})(),exports.definitionFiles=exports.isBundle?Object({assembly:'/**\n * Environment definitions for compiling AssemblyScript to WebAssembly using asc.\n * @module std/assembly\n *//***/\n\n/// \n\n// Types\n\n/** An 8-bit signed integer. */\ndeclare type i8 = number;\n/** A 16-bit signed integer. */\ndeclare type i16 = number;\n/** A 32-bit signed integer. */\ndeclare type i32 = number;\n/** A 64-bit signed integer. */\ndeclare type i64 = number;\n/** A 32-bit signed integer when targeting 32-bit WebAssembly or a 64-bit signed integer when targeting 64-bit WebAssembly. */\ndeclare type isize = number;\n/** An 8-bit unsigned integer. */\ndeclare type u8 = number;\n/** A 16-bit unsigned integer. */\ndeclare type u16 = number;\n/** A 32-bit unsigned integer. */\ndeclare type u32 = number;\n/** A 64-bit unsigned integer. */\ndeclare type u64 = number;\n/** A 32-bit unsigned integer when targeting 32-bit WebAssembly or a 64-bit unsigned integer when targeting 64-bit WebAssembly. */\ndeclare type usize = number;\n/** A 1-bit unsigned integer. */\ndeclare type bool = boolean | number;\n/** A 32-bit float. */\ndeclare type f32 = number;\n/** A 64-bit float. */\ndeclare type f64 = number;\n/** A 128-bit vector. */\ndeclare type v128 = object;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n/** Whether the bulk memory feature is enabled. */\ndeclare const ASC_FEATURE_BULK_MEMORY: bool;\n/** Whether the SIMD feature is enabled. */\ndeclare const ASC_FEATURE_SIMD: bool;\n/** Whether the threads feature is enabled. */\ndeclare const ASC_FEATURE_THREADS: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit or 64-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit or 64-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit or 64-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Reinterprets the bits of the specified value as type `T`. Valid reinterpretations are u32/i32 to/from f32 and u64/i64 to/from f64. */\ndeclare function reinterpret(value: number): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Equivalent to dereferncing a pointer in other languages. */\ndeclare function load(ptr: usize, immOffset?: usize, immAlign?: usize): T;\n/** Stores a value of the specified type to memory. Equivalent to dereferencing a pointer in other languages when assigning a value. */\ndeclare function store(ptr: usize, value: any, immOffset?: usize, immAlign?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. Both a statement and an expression of any type. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Heap base offset. */\ndeclare const HEAP_BASE: usize;\n/** Determines the byte size of the specified underlying core type. Compiles to a constant. */\ndeclare function sizeof(): usize;\n/** Determines the alignment (log2) of the specified underlying core type. Compiles to a constant. */\ndeclare function alignof(): usize;\n/** Determines the offset of the specified field within the given class type. Returns the class type\'s end offset if field name has been omitted. Compiles to a constant. */\ndeclare function offsetof(fieldName?: string): usize;\n/** Determines the unique runtime id of a class type. Compiles to a constant. */\ndeclare function idof(): u32;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Emits a `call_indirect` instruction, calling the specified function in the function table by index with the specified arguments. Does result in a runtime error if the arguments do not match the called function. */\ndeclare function call_indirect(target: Function | u32, ...args: any[]): T;\n/** Emits a `call` instruction, calling the specified function in the function table directly with the specified arguments. Function index must be a compile-time constant. */\ndeclare function call_direct(target: Function | u32, ...args: any[]): T;\n/** Instantiates a new instance of `T` using the specified constructor arguments. */\ndeclare function instantiate(...args: any[]): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified type *or* expression is of an integer type and not a reference. Compiles to a constant. */\ndeclare function isInteger(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a float type. Compiles to a constant. */\ndeclare function isFloat(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a boolean type. */\ndeclare function isBoolean(value?: any): value is number;\n/** Tests if the specified type *or* expression can represent negative numbers. Compiles to a constant. */\ndeclare function isSigned(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a reference type. Compiles to a constant. */\ndeclare function isReference(value?: any): value is object | string;\n/** Tests if the specified type *or* expression can be used as a string. Compiles to a constant. */\ndeclare function isString(value?: any): value is string | String;\n/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */\ndeclare function isArray(value?: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */\ndeclare function isArrayLike(value?: any): value is ArrayLike;\n/** Tests if the specified type *or* expression is of a function type. Compiles to a constant. */\ndeclare function isFunction(value?: any): value is (...args: any) => any;\n/** Tests if the specified type *or* expression is of a nullable reference type. Compiles to a constant. */\ndeclare function isNullable(value?: any): bool;\n/** Tests if the specified expression resolves to a defined element. Compiles to a constant. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. Compiles to a constant. */\ndeclare function isConstant(expression: any): bool;\n/** Tests if the specified type *or* expression is of a managed type. Compiles to a constant. */\ndeclare function isManaged(value?: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses an integer string to a 64-bit integer. */\ndeclare function parseI64(str: string, radix?: i32): i64;\n/** Parses a string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Atomic operations. */\ndeclare namespace atomic {\n /** Atomically loads an integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): T;\n /** Atomically stores an integer value to memory. */\n export function store(offset: usize, value: T, immOffset?: usize): void;\n /** Atomically adds an integer value in memory. */\n export function add(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically subtracts an integer value in memory. */\n export function sub(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise AND operation on an integer value in memory. */\n export function and(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise OR operation on an integer value in memory. */\n export function or(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise XOR operation on an integer value in memory. */\n export function xor(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically exchanges an integer value in memory. */\n export function xchg(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically compares and exchanges an integer value in memory if the condition is met. */\n export function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n /** Performs a wait operation on an address in memory suspending this agent if the integer condition is met. */\n export function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n /** Performs a notify operation on an address in memory waking up suspended agents. */\n export function notify(ptr: usize, count: i32): i32;\n}\n\n/** Describes the result of an atomic wait operation. */\ndeclare enum AtomicWaitResult {\n /** Woken by another agent. */\n OK,\n /** Loaded value did not match the expected value. */\n NOT_EQUAL,\n /** Not woken before the timeout expired. */\n TIMED_OUT\n}\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i8;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Loads an 8-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 32-bit integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 32-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 32-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i32;\n /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize): void;\n /** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n /** Atomic 32-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 32-bit integer value in memory. */\n export function add(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts a 32-bit integer value in memory. */\n export function sub(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */\n export function and(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */\n export function or(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */\n export function xor(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 32-bit integer value in memory. */\n export function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 32-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n/** Converts any other numeric value to a 64-bit signed integer. */\ndeclare function i64(value: any): i64;\ndeclare namespace i64 {\n /** Smallest representable value. */\n export const MIN_VALUE: i64;\n /** Largest representable value. */\n export const MAX_VALUE: i64;\n /** Loads an 8-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 64-bit unsigned integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 64-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 64-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i64;\n /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize): void;\n /** Performs a wait operation on a 64-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n /** Atomic 64-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 32-bit values. */\n export namespace rmw32 {\n /** Atomically adds a 32-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 32-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 32-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 32-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 32-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 32-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 32-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 64-bit integer value in memory. */\n export function add(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 64-bit integer value in memory. */\n export function sub(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 64-bit integer value in memory. */\n export function and(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 64-bit integer value in memory. */\n export function or(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 64-bit integer value in memory. */\n export function xor(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 64-bit integer value in memory. */\n export function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 64-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare var isize: typeof i32 | typeof i64;\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): i8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): i8;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): i32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n}\n/** Converts any other numeric value to a 64-bit unsigned integer. */\ndeclare function u64(value: any): i64;\ndeclare namespace u64 {\n /** Smallest representable value. */\n export const MIN_VALUE: u64;\n /** Largest representable value. */\n export const MAX_VALUE: u64;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare var usize: typeof u32 | typeof u64;\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Loads a 32-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n /** Stores a 32-bit float to memory. */\n export function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Loads a 64-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n /** Stores a 64-bit float to memory. */\n export function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function v128(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace v128 {\n /** Creates a 128-bit vector with identical lanes. */\n export function splat(x: T): v128;\n /** Extracts one lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): T;\n /** Replaces one lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: T): v128;\n /** Selects lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n /** Loads a 128-bit vector from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n /** Stores a 128-bit vector to memory. */\n export function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n /** Adds each lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128; // except i64\n /** Divides each lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each lane of a 128-bit vector */\n export function neg(a: v128): v128;\n /** Adds each lane of two 128-bit vectors using saturation. */\n export function add_saturate(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors using saturation. */\n export function sub_saturate(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise right shift on each lane of a 128-bit vector by a scalar. */\n export function shr(a: v128, b: i32): v128;\n /** Performs the bitwise AND operation on each lane of two 128-bit vectors. */\n export function and(a: v128, b: v128): v128;\n /** Performs the bitwise OR operation on each lane of two 128-bit vectors. */\n export function or(a: v128, b: v128): v128;\n /** Performs the bitwise XOR operation on each lane of two 128-bit vectors. */\n export function xor(a: v128, b: v128): v128;\n /** Performs the bitwise NOT operation on each lane of a 128-bit vector. */\n export function not(a: v128): v128;\n /** Selects bits of either 128-bit vector according to the specified mask. */\n export function bitselect(v1: v128, v2: v128, mask: v128): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes the minimum of each lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each lane of a 128-bit vector from integer to floating point. */\n export function convert(a: v128): v128;\n /** Truncates each lane of a 128-bit vector from floating point to integer with saturation. */\n export function trunc(a: v128): v128;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function i8x16(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace i8x16 {\n /** Creates a vector with sixteen identical 8-bit integer lanes. */\n export function splat(x: i8): v128;\n /** Extracts one 8-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i8;\n /** Extracts one 8-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u8;\n /** Replaces one 8-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i8): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 8-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 8-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 8-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 8-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from eight 16-bit integer values. Arguments must be compile-time constants. */\ndeclare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\ndeclare namespace i16x8 {\n /** Creates a vector with eight identical 16-bit integer lanes. */\n export function splat(x: i16): v128;\n /** Extracts one 16-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i16;\n /** Extracts one 16-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u16;\n /** Replaces one 16-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i16): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 16-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 16-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 16-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 16-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit integer values. Arguments must be compile-time constants. */\ndeclare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\ndeclare namespace i32x4 {\n /** Creates a 128-bit vector with four identical 32-bit integer lanes. */\n export function splat(x: i32): v128;\n /** Extracts one 32-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i32;\n /** Replaces one 32-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i32): v128;\n /** Adds each 32-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 32-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 32-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 32-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f32x4_sat(a: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f32x4_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit integer values. Arguments must be compile-time constants. */\ndeclare function i64x2(a: i64, b: i64): v128;\ndeclare namespace i64x2 {\n /** Creates a 128-bit vector with two identical 64-bit integer lanes. */\n export function splat(x: i64): v128;\n /** Extracts one 64-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i64;\n /** Replaces one 64-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i64): v128;\n /** Adds each 64-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 64-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 64-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 64-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Truncates each 64-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f64x2_sat(a: v128): v128;\n /** Truncates each 64-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f64x2_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit float values. Arguments must be compile-time constants. */\ndeclare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\ndeclare namespace f32x4 {\n /** Creates a 128-bit vector with four identical 32-bit float lanes. */\n export function splat(x: f32): v128;\n /** Extracts one 32-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f32;\n /** Replaces one 32-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f32): v128;\n /** Adds each 32-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 32-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 32-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 32-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 32-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 32-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 32-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 32-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i32x4(a: v128): v128;\n /** Converts each 32-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i32x4(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit float values. Arguments must be compile-time constants. */\ndeclare function f64x2(a: f64, b: f64): v128;\ndeclare namespace f64x2 {\n /** Creates a 128-bit vector with two identical 64-bit float lanes. */\n export function splat(x: f64): v128;\n /** Extracts one 64-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f64;\n /** Replaces one 64-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f64): v128;\n /** Adds each 64-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 64-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 64-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 64-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 64-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 64-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 64-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 64-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i64x2(a: v128): v128;\n /** Converts each 64-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i64x2(a: v128): v128;\n}\ndeclare namespace v8x16 {\n /** Selects 8-bit lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8, l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8): v128;\n}\n/** Macro type evaluating to the underlying native WebAssembly type. */\ndeclare type native = T;\n\n/** Pseudo-class representing the backing class of integer types. */\ndeclare class _Integer {\n /** Smallest representable value. */\n static readonly MIN_VALUE: number;\n /** Largest representable value. */\n static readonly MAX_VALUE: number;\n /** Converts a string to an integer of this type. */\n static parseInt(value: string, radix?: number): number;\n /** Converts this integer to a string. */\n toString(): string;\n}\n\n/** Pseudo-class representing the backing class of floating-point types. */\ndeclare class _Float {\n /** Difference between 1 and the smallest representable value greater than 1. */\n static readonly EPSILON: f32 | f64;\n /** Smallest representable value. */\n static readonly MIN_VALUE: f32 | f64;\n /** Largest representable value. */\n static readonly MAX_VALUE: f32 | f64;\n /** Smallest safely representable integer value. */\n static readonly MIN_SAFE_INTEGER: f32 | f64;\n /** Largest safely representable integer value. */\n static readonly MAX_SAFE_INTEGER: f32 | f64;\n /** Value representing positive infinity. */\n static readonly POSITIVE_INFINITY: f32 | f64;\n /** Value representing negative infinity. */\n static readonly NEGATIVE_INFINITY: f32 | f64;\n /** Value representing \'not a number\'. */\n static readonly NaN: f32 | f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n static isNaN(value: f32 | f64): bool;\n /** Returns true if passed value is finite. */\n static isFinite(value: f32 | f64): bool;\n /** Returns true if the value passed is a safe integer. */\n static isSafeInteger(value: f32 | f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n static isInteger(value: f32 | f64): bool;\n /** Converts a string to an integer. */\n static parseInt(value: string, radix?: i32): f32 | f64;\n /** Converts a string to a floating-point number. */\n static parseFloat(value: string): f32 | f64;\n /** Converts this floating-point number to a string. */\n toString(this: f64): string;\n}\n\n/** Backing class of signed 8-bit integers. */\ndeclare const I8: typeof _Integer;\n/** Backing class of signed 16-bit integers. */\ndeclare const I16: typeof _Integer;\n/** Backing class of signed 32-bit integers. */\ndeclare const I32: typeof _Integer;\n/** Backing class of signed 64-bit integers. */\ndeclare const I64: typeof _Integer;\n/** Backing class of signed size integers. */\ndeclare const Isize: typeof _Integer;\n/** Backing class of unsigned 8-bit integers. */\ndeclare const U8: typeof _Integer;\n/** Backing class of unsigned 16-bit integers. */\ndeclare const U16: typeof _Integer;\n/** Backing class of unsigned 32-bit integers. */\ndeclare const U32: typeof _Integer;\n/** Backing class of unsigned 64-bit integers. */\ndeclare const U64: typeof _Integer;\n/** Backing class of unsigned size integers. */\ndeclare const Usize: typeof _Integer;\n/** Backing class of 32-bit floating-point values. */\ndeclare const F32: typeof _Float;\n/** Backing class of 64-bit floating-point values. */\ndeclare const F64: typeof _Float;\n\n// User-defined diagnostic macros\n\n/** Emits a user-defined diagnostic error when encountered. */\ndeclare function ERROR(message?: any): void;\n/** Emits a user-defined diagnostic warning when encountered. */\ndeclare function WARNING(message?: any): void;\n/** Emits a user-defined diagnostic info when encountered. */\ndeclare function INFO(message?: any): void;\n\n// Polyfills\n\n/** Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Whether the memory managed interface is implemented. */\n export const implemented: bool;\n /** Returns the current memory size in units of pages. One page is 64kb. */\n export function size(): i32;\n /** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */\n export function grow(value: i32): i32;\n /** Sets n bytes beginning at the specified destination in memory to the specified byte value. */\n export function fill(dst: usize, value: u8, count: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n export function copy(dst: usize, src: usize, n: usize): void;\n /** Repeats `src` of length `srcLength` `count` times at `dst`. */\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void;\n /** Copies elements from a passive element segment to a table. */\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void;\n /** Prevents further use of a passive element segment. */\n export function drop(segmentIndex: u32): void;\n /** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */\n export function compare(vl: usize, vr: usize, n: usize): i32;\n}\n\n/** Garbage collector operations. */\ndeclare namespace gc {\n /** Whether the garbage collector interface is implemented. */\n export const implemented: bool;\n /** Performs a full garbage collection cycle. */\n export function collect(): void;\n /** Retains a reference, making sure that it doesn\'t become collected. */\n export function retain(ref: usize): void;\n /** Releases a reference, allowing it to become collected. */\n export function release(ref: usize): void;\n}\n\n/** Table operations. */\ndeclare namespace table {\n /** Copies elements from a passive element segment to a table. */\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void;\n /** Prevents further use of a passive element segment. */\n export function drop(elementIndex: u32): void;\n /** Copies elements from one region of a table to another region. */\n export function copy(dest: u32, src: u32, n: u32): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer\'s bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform\'s endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getInt64()` method gets a signed 64-bit integer (long long) at the specified byte offset from the start of the `DataView`. */\n getInt64(byteOffset: i32, littleEndian?: boolean): i64;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `getUint64()` method gets an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the `DataView`. */\n getUint64(byteOffset: i32, littleEndian?: boolean): u64;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setInt64()` method stores a signed 64-bit integer (long long) value at the specified byte offset from the start of the `DataView`. */\n setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** The `setUint64()` method stores an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the `DataView`. */\n setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ninterface ArrayLike {\n length: i32;\n // [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\n/* @internal */\ndeclare abstract class TypedArray implements ArrayBufferView {\n [key: number]: T;\n /** Number of bytes per element. */\n static readonly BYTES_PER_ELEMENT: usize;\n /** Constructs a new typed array. */\n constructor(length: i32);\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n /** The length (in elements). */\n readonly length: i32;\n /** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */\n subarray(begin?: i32, end?: i32): this;\n /** The reduce() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value. This method has the same algorithm as Array.prototype.reduce(). */\n reduce(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The reduceRight() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value, starting from the end of the array. This method has the same algorithm as Array.prototype.reduceRight(). */\n reduceRight(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The some() method tests whether some element in the typed array passes the test implemented by the provided function. This method has the same algorithm as Array.prototype.some().*/\n some(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The map() method creates a new typed array with the results of calling a provided function on every element in this typed array. This method has the same algorithm as Array.prototype.map().*/\n map(callbackfn: (value: T, index: i32, self: this) => T): this;\n /** The sort() method sorts the elements of a typed array numerically in place and returns the typed array. This method has the same algorithm as Array.prototype.sort(), except that sorts the values numerically instead of as strings. TypedArray is one of the typed array types here. */\n sort(callback?: (a: T, b: T) => i32): this;\n /** The fill() method fills all the elements of a typed array from a start index to an end index with a static value. This method has the same algorithm as Array.prototype.fill(). */\n fill(value: T, start?: i32, end?: i32): this;\n /** The findIndex() method returns an index in the typed array, if an element in the typed array satisfies the provided testing function. Otherwise -1 is returned. See also the find() [not implemented] method, which returns the value of a found element in the typed array instead of its index. */\n findIndex(callbackfn: (value: T, index: i32, self: this) => bool): i32;\n /** The every() method tests whether all elements in the typed array pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.every(). */\n every(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The forEach() method executes a provided function once per array element. This method has the same algorithm as Array.prototype.forEach().*/\n forEach(callbackfn: (value: T, index: i32, self: this) => void): void;\n /** The reverse() method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as Array.prototype.reverse(). */\n reverse(): this;\n}\n\n/** An array of twos-complement 8-bit signed integers. */\ndeclare class Int8Array extends TypedArray {}\n/** An array of 8-bit unsigned integers. */\ndeclare class Uint8Array extends TypedArray {}\n/** A clamped array of 8-bit unsigned integers. */\ndeclare class Uint8ClampedArray extends TypedArray {}\n/** An array of twos-complement 16-bit signed integers. */\ndeclare class Int16Array extends TypedArray {}\n/** An array of 16-bit unsigned integers. */\ndeclare class Uint16Array extends TypedArray {}\n/** An array of twos-complement 32-bit signed integers. */\ndeclare class Int32Array extends TypedArray {}\n/** An array of 32-bit unsigned integers. */\ndeclare class Uint32Array extends TypedArray {}\n/** An array of twos-complement 64-bit signed integers. */\ndeclare class Int64Array extends TypedArray {}\n/** An array of 64-bit unsigned integers. */\ndeclare class Uint64Array extends TypedArray {}\n/** An array of 32-bit floating point numbers. */\ndeclare class Float32Array extends TypedArray {}\n/** An array of 64-bit floating point numbers. */\ndeclare class Float64Array extends TypedArray {}\n\n/** Class representing a sequence of values of type `T`. */\ndeclare class Array {\n\n /** Tests if a value is an array. */\n static isArray(value: any): value is Array;\n /** Creates a new array with at least the specified capacity and length zero. */\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. If length is greater than zero and T is a non-nullable reference, use `Array.create` instead.*/\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\n/** Class representing a fixed sequence of values of type `T`. */\ndeclare class FixedArray {\n [key: number]: T;\n readonly length: i32;\n constructor(capacity?: i32);\n}\n\n/** Class representing a sequence of characters. */\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n readonly lengthUTF8: i32;\n\n charAt(index: u32): string;\n charCodeAt(index: u32): u16;\n concat(other: string): string;\n endsWith(other: string): bool;\n indexOf(other: string, fromIndex?: i32): u32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(start: u32, end?: u32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n static fromUTF8(ptr: usize, len: usize): string;\n toUTF8(): usize;\n}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ninterface Boolean {}\ninterface Function {}\ninterface IArguments {}\ninterface Number {}\ninterface Object {}\ninterface RegExp {}\n\ndeclare class Map {\n readonly size: i32;\n has(key: K): bool;\n set(key: K, value: V): void;\n get(key: K): V;\n delete(key: K): bool;\n clear(): void;\n toString(): string;\n}\n\ndeclare class Set {\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\n\ndeclare const Symbol: SymbolConstructor;\n\ninterface IMath {\n /** The base of natural logarithms, e, approximately 2.718. */\n readonly E: T;\n /** The natural logarithm of 2, approximately 0.693. */\n readonly LN2: T;\n /** The natural logarithm of 10, approximately 2.302. */\n readonly LN10: T;\n /** The base 2 logarithm of e, approximately 1.442. */\n readonly LOG2E: T;\n /** The base 10 logarithm of e, approximately 0.434. */\n readonly LOG10E: T;\n /** The ratio of the circumference of a circle to its diameter, approximately 3.14159. */\n readonly PI: T;\n /** The square root of 1/2, approximately 0.707. */\n readonly SQRT1_2: T;\n /** The square root of 2, approximately 1.414. */\n readonly SQRT2: T;\n /** Returns the absolute value of `x`. */\n abs(x: T): T;\n /** Returns the arccosine (in radians) of `x`. */\n acos(x: T): T;\n /** Returns the hyperbolic arc-cosine of `x`. */\n acosh(x: T): T;\n /** Returns the arcsine (in radians) of `x` */\n asin(x: T): T;\n /** Returns the hyperbolic arcsine of `x`. */\n asinh(x: T): T;\n /** Returns the arctangent (in radians) of `x`. */\n atan(x: T): T;\n /** Returns the arctangent of the quotient of its arguments. */\n atan2(y: T, x: T): T;\n /** Returns the hyperbolic arctangent of `x`. */\n atanh(x: T): T;\n /** Returns the cube root of `x`. */\n cbrt(x: T): T;\n /** Returns the smallest integer greater than or equal to `x`. */\n ceil(x: T): T;\n /** Returns the number of leading zero bits in the 32-bit binary representation of `x`. */\n clz32(x: T): T;\n /** Returns the cosine (in radians) of `x`. */\n cos(x: T): T;\n /** Returns the hyperbolic cosine of `x`. */\n cosh(x: T): T;\n /** Returns e to the power of `x`. */\n exp(x: T): T;\n /** Returns e to the power of `x`, minus 1. */\n expm1(x: T): T;\n /** Returns the largest integer less than or equal to `x`. */\n floor(x: T): T;\n /** Returns the nearest 32-bit single precision float representation of `x`. */\n fround(x: T): f32;\n /** Returns the square root of the sum of squares of its arguments. */\n hypot(value1: T, value2: T): T; // TODO: rest\n /** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */\n imul(a: T, b: T): T;\n /** Returns the natural logarithm (base e) of `x`. */\n log(x: T): T;\n /** Returns the base 10 logarithm of `x`. */\n log10(x: T): T;\n /** Returns the natural logarithm (base e) of 1 + `x`. */\n log1p(x: T): T;\n /** Returns the base 2 logarithm of `x`. */\n log2(x: T): T;\n /** Returns the largest-valued number of its arguments. */\n max(value1: T, value2: T): T; // TODO: rest\n /** Returns the lowest-valued number of its arguments. */\n min(value1: T, value2: T): T; // TODO: rest\n /** Returns `base` to the power of `exponent`. */\n pow(base: T, exponent: T): T;\n /** Returns a pseudo-random number in the range from 0.0 inclusive up to but not including 1.0. */\n random(): T;\n /** Returns the value of `x` rounded to the nearest integer. */\n round(x: T): T;\n /** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */\n sign(x: T): T;\n /** Returns whether the sign bit of `x` is set */\n signbit(x: T): bool;\n /** Returns the sine of `x`. */\n sin(x: T): T;\n /** Returns the hyperbolic sine of `x`. */\n sinh(x: T): T;\n /** Returns the square root of `x`. */\n sqrt(x: T): T;\n /** Returns the tangent of `x`. */\n tan(x: T): T;\n /** Returns the hyperbolic tangent of `x`. */\n tanh(x: T): T;\n /** Returns the integer part of `x` by removing any fractional digits. */\n trunc(x: T): T;\n}\n\ninterface INativeMath extends IMath {\n /** Contains sin value produced after Math/Mathf.sincos */\n sincos_sin: T;\n /** Contains cos value produced after Math/Mathf.sincos */\n sincos_cos: T;\n /** Seeds the random number generator. */\n seedRandom(value: i64): void;\n /** Returns the floating-point remainder of `x / y` (rounded towards zero). */\n mod(x: T, y: T): T;\n /** Returns the floating-point remainder of `x / y` (rounded to nearest). */\n rem(x: T, y: T): T;\n /** Returns sin and cos simultaneously for same angle. Results stored to `sincos_s32/64` and `sincos_c32/64` globals */\n sincos(x: T): void;\n}\n\n/** Double precision math imported from JavaScript. */\ndeclare const JSMath: IMath;\n/** Double precision math implemented natively. */\ndeclare const NativeMath: INativeMath;\n/** Single precision math implemented natively. */\ndeclare const NativeMathf: INativeMath;\n/** Alias of {@link NativeMath} or {@link JSMath} respectively. Defaults to `NativeMath`. */\ndeclare const Math: IMath;\n/** Alias of {@link NativeMathf} or {@link JSMath} respectively. Defaults to `NativeMathf`. */\ndeclare const Mathf: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): i64;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): i64;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: i64);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): i64;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: i64): i64;\n}\n\n/** Environmental tracing function for debugging purposes. */\ndeclare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?: f64, a4?: f64): void;\n\n// Decorators\n\ninterface TypedPropertyDescriptor {\n configurable?: boolean;\n enumerable?: boolean;\n writable?: boolean;\n value?: T;\n get?(): T;\n set?(value: T): void;\n}\n\n/** Annotates a method as a binary operator overload for the specified `token`. */\ndeclare function operator(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n) => TypedPropertyDescriptor | void;\n\ndeclare namespace operator {\n /** Annotates a method as a binary operator overload for the specified `token`. */\n export function binary(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n ): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary prefix operator overload for the specified `token`. */\n export function prefix(token: "!" | "~" | "+" | "-" | "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary postfix operator overload for the specified `token`. */\n export function postfix(token: "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n}\n\n/** Annotates an element as a program global. */\ndeclare function global(...args: any[]): any;\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n\n/** Annotates a class as being sealed / non-derivable. */\ndeclare function sealed(constructor: Function): void;\n\n/** Annotates a method, function or constant global as always inlined. */\ndeclare function inline(...args: any[]): any;\n\n/** Annotates a method, function or constant global as unsafe. */\ndeclare function unsafe(...args: any[]): any;\n\n/** Annotates an explicit external name of a function or global. */\ndeclare function external(...args: any[]): any;\n\n/** Annotates a global for lazy compilation. */\ndeclare function lazy(...args: any[]): any;\n\n/** Annotates a function as the explicit start function. */\ndeclare function start(...args: any[]): any;\n',portable:"/**\n * Environment definitions for compiling AssemblyScript to JavaScript using tsc.\n *\n * Note that semantic differences require additional explicit conversions for full compatibility.\n * For example, when casting an i32 to an u8, doing `(someI32 & 0xff)` will yield the same\n * result when compiling to WebAssembly or JS while `someI32` alone does nothing in JS.\n *\n * Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer\n * value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example\n * {@link glue/js/i64} respectively {@link glue/wasm/i64}.\n *\n * @module std/portable\n *//***/\n\n/// \n\n// Types\n\ndeclare type bool = boolean;\ndeclare type i8 = number;\ndeclare type i16 = number;\ndeclare type i32 = number;\ndeclare type isize = number;\ndeclare type u8 = number;\ndeclare type u16 = number;\ndeclare type u32 = number;\ndeclare type usize = number;\ndeclare type f32 = number;\ndeclare type f64 = number;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Type must be `u8`. */\ndeclare function load(ptr: usize, constantOffset?: usize): T;\n/** Stores a value of the specified type to memory. Type must be `u8`. */\ndeclare function store(ptr: usize, value: T, constantOffset?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified value is a valid integer. Can't distinguish an integer from an integral float. */\ndeclare function isInteger(value: any): value is number;\n/** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */\ndeclare function isFloat(value: any): value is number;\n/** Tests if the specified value is of a nullable reference type. */\ndeclare function isNullable(value: any): bool;\n/** Tests if the specified value is of a reference type. */\ndeclare function isReference(value: any): value is object | string;\n/** Tests if the specified value is of a function type */\ndeclare function isFunction(value: any): value is Function;\n/** Tests if the specified value can be used as a string. */\ndeclare function isString(value: any): value is string | String;\n/** Tests if the specified value can be used as an array. */\ndeclare function isArray(value: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. */\ndeclare function isArrayLike(value: any): value is ArrayLike;\n/** Tests if the specified expression resolves to a defined element. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. */\ndeclare function isConstant(expression: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the value. */\ndeclare function assert(isTrueish: T | null, message?: string): T;\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses a floating point string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i16;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare function isize(value: any): isize;\ndeclare namespace isize {\n /** Smallest representable value. */\n export const MIN_VALUE: isize;\n /** Largest representable value. */\n export const MAX_VALUE: isize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): isize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): u8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): u16;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): u32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare function usize(value: any): isize;\ndeclare namespace usize {\n /** Smallest representable value. */\n export const MIN_VALUE: usize;\n /** Largest representable value. */\n export const MAX_VALUE: usize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): usize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f32): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f32): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f32;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f64): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f64;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f64;\n}\n\n// Polyfills\n\n/** [Polyfill] Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** [Polyfill] Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Allocates a chunk of memory of the specified size and returns a pointer to it. */\n function allocate(size: usize): usize;\n /** Disposes a chunk of memory by its pointer. */\n function free(ptr: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n function copy(dst: usize, src: usize, n: usize): void;\n /** Fills size bytes from from the specified destination by same value in memory. */\n function fill(dst: usize, value: u8, size: usize): void;\n /** Resets the allocator to its initial state, if supported. */\n function reset(): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer's bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform's endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ndeclare class Array {\n\n static isArray(value: any): value is Array;\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n length: i32;\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from?: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\ndeclare class Uint8Array extends Array {}\ndeclare class Uint8ClampedArray extends Array {}\ndeclare class Uint16Array extends Array {}\ndeclare class Uint32Array extends Array {}\ndeclare class Int8Array extends Array {}\ndeclare class Int16Array extends Array {}\ndeclare class Int32Array extends Array {}\ndeclare class Float32Array extends Array {}\ndeclare class Float64Array extends Array {}\n\ninterface ArrayLike {\n length: i32;\n [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n\n private constructor();\n\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n concat(other: string): string;\n indexOf(other: string, fromIndex?: i32): i32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n endsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(from: i32, to?: i32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n replace(search: string, replacement: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n}\n\ninterface Boolean {}\n\ndeclare class Number {\n private constructor();\n toString(radix?: i32): string;\n}\n\ninterface Object {}\n\ninterface Function {}\n\ninterface RegExp {}\n\ninterface IArguments {}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ndeclare class Set {\n constructor(entries?: T[]);\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n [Symbol.iterator](): Iterator;\n}\n\ndeclare class Map {\n constructor(entries?: [K, V][]);\n readonly size: i32;\n set(key: K, value: V): void;\n has(key: K): bool;\n get(key: K): V | null;\n clear(): void;\n entries(): Iterable<[K, V]>;\n keys(): Iterable;\n values(): Iterable;\n delete(key: K): bool;\n toString(): string;\n [Symbol.iterator](): Iterator<[K,V]>;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\ndeclare const Symbol: SymbolConstructor;\n\ninterface Iterable {\n [Symbol.iterator](): Iterator;\n}\n\ninterface Iterator {}\n\ninterface IMath {\n readonly E: f64;\n readonly LN2: f64;\n readonly LN10: f64;\n readonly LOG2E: f64;\n readonly LOG10E: f64;\n readonly PI: f64;\n readonly SQRT1_2: f64;\n readonly SQRT2: f64;\n\n sincos_sin: f64;\n sincos_cos: f64;\n\n abs(x: f64): f64;\n acos(x: f64): f64;\n acosh(x: f64): f64;\n asin(x: f64): f64;\n asinh(x: f64): f64;\n atan(x: f64): f64;\n atan2(y: f64, x: f64): f64;\n atanh(x: f64): f64;\n cbrt(x: f64): f64;\n ceil(x: f64): f64;\n clz32(x: f64): i32;\n cos(x: f64): f64;\n cosh(x: f64): f64;\n exp(x: f64): f64;\n expm1(x: f64): f64;\n floor(x: f64): f64;\n fround(x: f64): f32;\n hypot(value1: f64, value2: f64): f64; // TODO: see std/math\n imul(a: f64, b: f64): i32;\n log(x: f64): f64;\n log10(x: f64): f64;\n log1p(x: f64): f64;\n log2(x: f64): f64;\n max(value1: f64, value2: f64): f64; // TODO: see std/math\n min(value1: f64, value2: f64): f64; // TODO: see std/math\n pow(base: f64, exponent: f64): f64;\n random(): f64;\n round(x: f64): f64;\n sign(x: f64): f64;\n signbit(x: f64): bool;\n sin(x: f64): f64;\n sincos(x: f64): f64;\n sinh(x: f64): f64;\n sqrt(x: f64): f64;\n tan(x: f64): f64;\n tanh(x: f64): f64;\n trunc(x: f64): f64;\n}\n\ndeclare const Math: IMath;\ndeclare const Mathf: IMath;\ndeclare const JSMath: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): number;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): number;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: number);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): number;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: number): number;\n}\n\ndeclare namespace console {\n /** @deprecated */\n function log(message: string): void;\n}\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n"}):(()=>{const n=path.join(".","..","std");return{assembly:fs.readFileSync(path.join(n,"assembly","index.d.ts"),"utf8"),portable:fs.readFileSync(path.join(n,"portable","index.d.ts"),"utf8")}})(),exports.compileString=((n,e)=>{"string"==typeof n&&(n={"input.ts":n});const t=Object.create({stdout:createMemoryStream(),stderr:createMemoryStream()});var r=["--binaryFile","binary","--textFile","text"];return Object.keys(e||{}).forEach(n=>{var t=e[n];Array.isArray(t)?t.forEach(e=>r.push("--"+n,String(e))):r.push("--"+n,String(t))}),exports.main(r.concat(Object.keys(n)),{stdout:t.stdout,stderr:t.stderr,readFile:e=>n.hasOwnProperty(e)?n[e]:null,writeFile:(n,e)=>t[n]=e,listFiles:()=>[]}),t}),exports.main=function(n,e,t){"function"==typeof e?(t=e,e={}):e||(e={});const r=e.stdout||process.stdout,i=e.stderr||process.stderr,o=e.readFile||F,a=e.writeFile||z,s=e.listFiles||S,l=e.stats||createStats();if(!r)throw Error("'options.stdout' must be specified");if(!i)throw Error("'options.stderr' must be specified");const u=optionsUtil.parse(n,exports.options),f=u.options;if(n=u.arguments,f.noColors?colorsUtil.stdout.supported=colorsUtil.stderr.supported=!1:(colorsUtil.stdout=colorsUtil.from(r),colorsUtil.stderr=colorsUtil.from(i)),u.unknown.length&&u.unknown.forEach(n=>{i.write(colorsUtil.stderr.yellow("WARN: ")+"Unknown option '"+n+"'"+EOL)}),u.trailing.length&&i.write(colorsUtil.stderr.yellow("WARN: ")+"Unsupported trailing arguments: "+u.trailing.join(" ")+EOL),t||(t=function(n){var e=0;return n&&(i.write(colorsUtil.stderr.red("ERROR: ")+n.stack.replace(/^ERROR: /i,"")+EOL),e=1),e}),f.version)return r.write("Version "+exports.version+(isDev?"-dev":"")+EOL),t(null);if(f.help||!n.length){var c=f.help?r:i,d=f.help?colorsUtil.stdout:colorsUtil.stderr;return c.write([d.white("SYNTAX")," "+d.cyan("asc")+" [entryFile ...] [options]","",d.white("EXAMPLES")," "+d.cyan("asc")+" hello.ts"," "+d.cyan("asc")+" hello.ts -b hello.wasm -t hello.wat"," "+d.cyan("asc")+" hello1.ts hello2.ts -b -O > hello.wasm","",d.white("OPTIONS")].concat(optionsUtil.help(exports.options,24,EOL)).join(EOL)+EOL),t(null)}if(!fs.readFileSync){if(o===F)throw Error("'options.readFile' must be specified");if(a===z)throw Error("'options.writeFile' must be specified");if(s===S)throw Error("'options.listFiles' must be specified")}const p=f.baseDir?path.resolve(f.baseDir):".",h=[];f.transform&&f.transform.forEach(n=>h.push(__webpack_require__(12)(path.isAbsolute(n=n.trim())?n:path.join(process.cwd(),n))));var g=null;Object.keys(exports.libraryFiles).forEach(n=>{n.indexOf("/")>=0||(l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(exports.libraryFiles[n],exports.libraryPrefix+n+".ts",!1,g)}))});const x=[];if(f.lib){let n=f.lib;"string"==typeof n&&(n=n.split(",")),Array.prototype.push.apply(x,n.map(n=>n.trim()));for(let n=0,e=x.length;n{g=assemblyscript.parseFile(a,exports.libraryPrefix+i,!1,g)})}}}function v(){for(var n,e;null!=(n=g.nextFile());){if(n.startsWith(exports.libraryPrefix)){const t=n.substring(exports.libraryPrefix.length),r=n.substring(exports.libraryPrefix.length)+"/index";if(exports.libraryFiles.hasOwnProperty(t))e=exports.libraryFiles[t],n=exports.libraryPrefix+t+".ts";else if(exports.libraryFiles.hasOwnProperty(r))e=exports.libraryFiles[r],n=exports.libraryPrefix+r+".ts";else for(let i=0,a=x.length;i{assemblyscript.parseFile(e,n,!1,g)})}if(checkDiagnostics(g,i))return t(Error("Parse error"))}{let n=String(f.runtime),e=exports.libraryFiles["rt/index-"+n];if(null==e&&null==(e=o(n+".ts",p)))return t(Error("Runtime template '"+n+"' not found."));l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(e,n,!0,g)})}for(let e=0,r=n.length;e{g=assemblyscript.parseFile(a,i,!0,g)})}{let n=v();if(n)return n}!function(n,...e){h.forEach(t=>{"function"==typeof t[n]&&t[n](...e)})}("afterParse",g);{let n=v();if(n)return n}const m=assemblyscript.finishParsing(g);var b=0,y=0;f.optimize&&(b=exports.defaultOptimizeLevel,y=exports.defaultShrinkLevel),"number"==typeof f.optimizeLevel&&(b=f.optimizeLevel),"number"==typeof f.shrinkLevel&&(y=f.shrinkLevel),b=Math.min(Math.max(b,0),3),y=Math.min(Math.max(y,0),2);const _=assemblyscript.createOptions();if(assemblyscript.setTarget(_,0),assemblyscript.setNoAssert(_,f.noAssert),assemblyscript.setImportMemory(_,f.importMemory),assemblyscript.setSharedMemory(_,f.sharedMemory),assemblyscript.setImportTable(_,f.importTable),assemblyscript.setMemoryBase(_,f.memoryBase>>>0),assemblyscript.setSourceMap(_,null!=f.sourceMap),assemblyscript.setOptimizeLevelHints(_,b,y),assemblyscript.setGlobalAlias(_,"Math","NativeMath"),assemblyscript.setGlobalAlias(_,"Mathf","NativeMathf"),assemblyscript.setGlobalAlias(_,"abort","~lib/builtins/abort"),assemblyscript.setGlobalAlias(_,"trace","~lib/builtins/trace"),f.use){let n=f.use;for(let e=0,r=n.length;e{T=assemblyscript.compileProgram(m,_)})}catch(n){return t(n)}if(checkDiagnostics(g,i))return T&&T.dispose(),t(Error("Compile error"));if(f.validate&&(l.validateCount++,l.validateTime+=measure(()=>{if(!T.validate())return T.dispose(),t(Error("Validate error"))})),"clamp"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-clamp"])});else if("js"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-js"])});else if("allow"!==f.trapMode)return T.dispose(),t(Error("Unsupported trap mode"));(b>=3||y>=2)&&(b=4),T.setOptimizeLevel(b),T.setShrinkLevel(y),T.setDebugInfo(f.debug);var A=[];if(f.runPasses&&("string"==typeof f.runPasses&&(f.runPasses=f.runPasses.split(",")),f.runPasses.length&&f.runPasses.forEach(n=>{A.indexOf(n)<0&&A.push(n)})),(b>0||y>0)&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.optimize()})),A.length&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(A.map(n=>n.trim()))})),!f.noEmit){let n=!1,e=!1;if(null!=f.outFile&&(/\.was?t$/.test(f.outFile)&&null==f.textFile?f.textFile=f.outFile:/\.js$/.test(f.outFile)&&null==f.asmjsFile?f.asmjsFile=f.outFile:null==f.binaryFile&&(f.binaryFile=f.outFile)),null!=f.binaryFile){let r,s=null!=f.sourceMap?f.sourceMap.length?f.sourceMap:path.basename(f.binaryFile)+".map":null;if(l.emitCount++,l.emitTime+=measure(()=>{r=T.toBinary(s)}),f.binaryFile.length?a(f.binaryFile,r.output,p):(I(r.output),n=!0),e=!0,null!=r.sourceMap)if(f.binaryFile.length){let n=JSON.parse(r.sourceMap);n.sourceRoot=exports.sourceMapRoot,n.sources.forEach((e,r)=>{let i=null;if(e.startsWith(exports.libraryPrefix)){let n=e.substring(exports.libraryPrefix.length).replace(/\.ts$/,"");if(exports.libraryFiles.hasOwnProperty(n))i=exports.libraryFiles[n];else for(let n=0,t=x.length;n{t=T.toAsmjs()}),a(f.asmjsFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=T.toAsmjs()}),I(t),n=!0),e=!0}if(null!=f.idlFile){let t;f.idlFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),a(f.idlFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),I(t),n=!0),e=!0}if(null!=f.tsdFile){let t;f.tsdFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),a(f.tsdFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),I(t),n=!0),e=!0}if(null!=f.textFile||!e){let e;f.textFile&&f.textFile.length?(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),a(f.textFile,e,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),I(e))}}return T.dispose(),f.measure&&printStats(l,i),t(null);function F(n,e){try{let t;return l.readCount++,l.readTime+=measure(()=>{t=fs.readFileSync(path.join(e,n),{encoding:"utf8"})}),t}catch(n){return null}}function z(n,e,t){try{return l.writeCount++,l.writeTime+=measure(()=>{mkdirp(path.join(t,path.dirname(n))),"string"==typeof e?fs.writeFileSync(path.join(t,n),e,{encoding:"utf8"}):fs.writeFileSync(path.join(t,n),e)}),!0}catch(n){return!1}}function S(n,e){var t;try{return l.readTime+=measure(()=>{t=fs.readdirSync(path.join(e,n)).filter(n=>/^(?!.*\.d\.ts$).*\.ts$/.test(n))}),t}catch(n){return[]}}function I(n){I.used||(l.writeCount++,I.used=!0),l.writeTime+=measure(()=>{"string"==typeof n?r.write(n,{encoding:"utf8"}):r.write(n)})}},exports.checkDiagnostics=checkDiagnostics,exports.createStats=createStats,process.hrtime||(process.hrtime=__webpack_require__(13)),exports.measure=measure,exports.formatTime=formatTime,exports.printStats=printStats;var allocBuffer=void 0!==global&&global.Buffer?global.Buffer.allocUnsafe||function(n){return new global.Buffer(n)}:function(n){return new Uint8Array(n)};function createMemoryStream(n){var e=[];return e.write=function(e){if(n&&n(e),"string"==typeof e){let n=allocBuffer(utf8.length(e));utf8.write(e,n,0),e=n}this.push(e)},e.reset=function(){e.length=0},e.toBuffer=function(){for(var n=0,e=0,t=this.length;e191&&r<224?o[a++]=(31&r)<<6|63&n[e++]:r>239&&r<365?(r=((7&r)<<18|(63&n[e++])<<12|(63&n[e++])<<6|63&n[e++])-65536,o[a++]=55296+(r>>10),o[a++]=56320+(1023&r)):o[a++]=(15&r)<<12|(63&n[e++])<<6|63&n[e++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(n,e,t){for(var r,i,o=t,a=0;a>6|192,e[t++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=n.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&i),++a,e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=63&r|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=63&r|128);return t-o}},function(n,e,t){(function(n){var t=void 0!==n&&n||{},r=t.env&&"CI"in t.env;function i(n,t){var i=t||{};return i.supported=n&&!!n.isTTY||r,i.gray=(n=>i.supported?e.GRAY+n+e.RESET:n),i.red=(n=>i.supported?e.RED+n+e.RESET:n),i.green=(n=>i.supported?e.GREEN+n+e.RESET:n),i.yellow=(n=>i.supported?e.YELLOW+n+e.RESET:n),i.blue=(n=>i.supported?e.BLUE+n+e.RESET:n),i.magenta=(n=>i.supported?e.MAGENTA+n+e.RESET:n),i.cyan=(n=>i.supported?e.CYAN+n+e.RESET:n),i.white=(n=>i.supported?e.WHITE+n+e.RESET:n),i}e.stdout=i(t.stdout,e),e.stderr=i(t.stderr),e.from=i,e.GRAY="",e.RED="",e.GREEN="",e.YELLOW="",e.BLUE="",e.MAGENTA="",e.CYAN="",e.WHITE="",e.RESET=""}).call(this,t(0))},function(n,e){e.parse=function(n,e){var t={},r=[],arguments=[],i=[],o={};Object.keys(e).forEach(n=>{if(!n.startsWith(" ")){var r=e[n];null!=r.alias&&("string"==typeof r.alias?o[r.alias]=n:Array.isArray(r.alias)&&r.alias.forEach(e=>o[e]=n)),null!=r.default&&(t[n]=r.default)}});for(var a=0,s=(n=n.slice()).length;at[n]=s.value[n])}else r.push(i)}for(;a{var a=n[e];if(null!=a.description){for(var s="";s.length{for(let e=0;e=0;r--){var i=n[r];"."===i?n.splice(r,1):".."===i?(n.splice(r,1),t++):t&&(n.splice(r,1),t--)}if(e)for(;t--;t)n.unshift("..");return n}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(n){return r.exec(n).slice(1)};function o(n,e){if(n.filter)return n.filter(e);for(var t=[],r=0;r=-1&&!r;i--){var a=i>=0?arguments[i]:n.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,r="/"===a.charAt(0))}return(r?"/":"")+(e=t(o(e.split("/"),function(n){return!!n}),!r).join("/"))||"."},e.normalize=function(n){var r=e.isAbsolute(n),i="/"===a(n,-1);return(n=t(o(n.split("/"),function(n){return!!n}),!r).join("/"))||r||(n="."),n&&i&&(n+="/"),(r?"/":"")+n},e.isAbsolute=function(n){return"/"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(o(n,function(n,e){if("string"!=typeof n)throw new TypeError("Arguments to path.join must be strings");return n}).join("/"))},e.relative=function(n,t){function r(n){for(var e=0;e=0&&""===n[t];t--);return e>t?[]:n.slice(e,t-e+1)}n=e.resolve(n).substr(1),t=e.resolve(t).substr(1);for(var i=r(n.split("/")),o=r(t.split("/")),a=Math.min(i.length,o.length),s=a,l=0;l{try{assemblyscript=__webpack_require__(10)}catch(e){try{__webpack_require__(!function(){var n=new Error("Cannot find module 'ts-node'");throw n.code="MODULE_NOT_FOUND",n}()).register({project:path.join(".","..","src","tsconfig.json")}),__webpack_require__(!function(){var n=new Error("Cannot find module '../src/glue/js'");throw n.code="MODULE_NOT_FOUND",n}()),assemblyscript=__webpack_require__(!function(){var n=new Error("Cannot find module '../src'");throw n.code="MODULE_NOT_FOUND",n}()),isDev=!0}catch(e_ts){try{assemblyscript=eval("require('./assemblyscript')")}catch(n){throw n.stack=e_ts.stack+"\n---\n"+n.stack,n}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.7.0":__webpack_require__(!function(){var n=new Error("Cannot find module '../package.json'");throw n.code="MODULE_NOT_FOUND",n}()).version,exports.options=__webpack_require__(11),exports.sourceMapRoot="assemblyscript:///",exports.libraryPrefix=assemblyscript.LIBRARY_PREFIX,exports.defaultOptimizeLevel=3,exports.defaultShrinkLevel=1,exports.libraryFiles=exports.isBundle?Object({array:'/// \n\nimport { BLOCK_MAXSIZE } from "./rt/common";\nimport { COMPARATOR, SORT } from "./util/sort";\nimport { ArrayBuffer, ArrayBufferView } from "./arraybuffer";\nimport { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/number";\nimport { idof, isArray as builtin_isArray } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";\n\n/** Ensures that the given array has _at least_ the specified backing size. */\nfunction ensureSize(array: usize, minSize: usize, alignLog2: u32): void {\n var oldCapacity = changetype(array).dataLength;\n if (minSize > oldCapacity >>> alignLog2) {\n if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n let oldData = changetype(changetype(array).data);\n let newCapacity = minSize << alignLog2;\n let newData = __realloc(oldData, newCapacity);\n memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity);\n if (newData !== oldData) { // oldData has been free\'d\n store(changetype(array), __retain(newData), offsetof("data"));\n changetype(array).dataStart = newData;\n }\n changetype(array).dataLength = newCapacity;\n }\n}\n\nexport class Array extends ArrayBufferView {\n [key: number]: T;\n\n // Implementing ArrayBufferView isn\'t strictly necessary here but is done to allow glue code\n // to work with typed and normal arrays interchangeably. Technically, normal arrays do not need\n // `dataStart` (equals `data`) and `dataLength` (equals computed `data.byteLength`).\n\n // Also note that Array with non-nullable T must guard against implicit null values whenever\n // length is modified in a way that a null value would exist. Otherwise, the compiler wouldn\'t be\n // able to guarantee type-safety anymore. For lack of a better word, such an array is "holey".\n\n private length_: i32;\n\n static isArray(value: U): bool {\n return builtin_isArray(value) && value !== null;\n }\n\n static create(capacity: i32 = 0): Array {\n if (capacity > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n var array = changetype>(__allocArray(capacity, alignof(), idof())); // retains\n changetype>(array).length_ = 0; // safe even if T is a non-nullable reference\n memory.fill(array.dataStart, 0, array.dataLength);\n return array;\n }\n\n constructor(length: i32 = 0) {\n super(length, alignof());\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n this.length_ = length;\n }\n\n @unsafe get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.length_;\n }\n\n set length(length: i32) {\n if (isReference()) {\n if (!isNullable()) {\n if (length > this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), length, alignof());\n this.length_ = length;\n }\n\n every(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!callbackfn(load(this.dataStart + (index << alignof())), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (predicate(load(this.dataStart + (index << alignof())), index, this)) return index;\n }\n return -1;\n }\n\n @operator("[]") private __get(index: i32): T {\n if (isReference()) {\n if (!isNullable()) {\n if (index >= this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n var length = this.length_;\n if (isReference()) {\n if (!isNullable()) {\n if (index > length) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), index + 1, alignof());\n this.__unchecked_set(index, value);\n if (index >= length) this.length_ = index + 1;\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = this.dataStart + (index << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (index << alignof()), value);\n }\n }\n\n fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) {\n memory.fill(\n dataStart + start,\n u8(value),\n (end - start)\n );\n }\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return this;\n }\n\n includes(searchElement: T, fromIndex: i32 = 0): bool {\n return this.indexOf(searchElement, fromIndex) >= 0;\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n var length = this.length_;\n if (length == 0 || fromIndex >= length) return -1;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n var dataStart = this.dataStart;\n while (fromIndex < length) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = this.length_): i32 {\n var length = this.length_;\n if (length == 0) return -1;\n if (fromIndex < 0) fromIndex = length + fromIndex;\n else if (fromIndex >= length) fromIndex = length - 1;\n var dataStart = this.dataStart;\n while (fromIndex >= 0) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(value: T): i32 {\n var length = this.length_;\n var newLength = length + 1;\n ensureSize(changetype(this), newLength, alignof());\n if (isManaged()) {\n let offset = this.dataStart + (length << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (length << alignof()), value);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n concat(other: Array): Array {\n var thisLen = this.length_;\n var otherLen = select(0, other.length_, other === null);\n var outLen = thisLen + otherLen;\n if (outLen > BLOCK_MAXSIZE >>> alignof()) throw new Error(E_INVALIDLENGTH);\n var out = changetype>(__allocArray(outLen, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n var thisSize = thisLen << alignof();\n if (isManaged()) {\n let thisStart = this.dataStart;\n for (let offset: usize = 0; offset < thisSize; offset += sizeof()) {\n let ref = load(thisStart + offset);\n store(outStart + offset, __retain(ref));\n }\n outStart += thisSize;\n let otherStart = other.dataStart;\n let otherSize = otherLen << alignof();\n for (let offset: usize = 0; offset < otherSize; offset += sizeof()) {\n let ref = load(otherStart + offset);\n store(outStart + offset, __retain(ref));\n }\n } else {\n memory.copy(outStart, this.dataStart, thisSize);\n memory.copy(outStart + thisSize, other.dataStart, otherLen << alignof());\n }\n return out;\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var len = this.length_;\n\n end = min(end, len);\n var to = target < 0 ? max(len + target, 0) : min(target, len);\n var from = start < 0 ? max(len + start, 0) : min(start, len);\n var last = end < 0 ? max(len + end, 0) : min(end, len);\n var count = min(last - from, len - to);\n\n if (from < to && to < (from + count)) {\n from += count - 1;\n to += count - 1;\n while (count) {\n store(dataStart + (to << alignof()), load(dataStart + (from << alignof())));\n --from, --to, --count;\n }\n } else {\n memory.copy(\n dataStart + (to << alignof()),\n dataStart + (from << alignof()),\n count << alignof()\n );\n }\n return this;\n }\n\n pop(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var element = load(this.dataStart + ((--length) << alignof()));\n this.length_ = length;\n return element;\n }\n\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n callbackfn(load(this.dataStart + (index << alignof())), index, this);\n }\n }\n\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array {\n var length = this.length_;\n var out = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n for (let index = 0; index < min(length, this.length_); ++index) {\n let result = callbackfn(load(this.dataStart + (index << alignof())), index, this); // retains\n if (isManaged()) {\n store(outStart + (index << alignof()), __retain(changetype(result)));\n } else {\n store(outStart + (index << alignof()), result);\n }\n // releases result\n }\n return out;\n }\n\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array {\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n let value = load(this.dataStart + (index << alignof()));\n if (callbackfn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n reduceRight(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = this.length_ - 1; index >= 0; --index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n shift(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var base = this.dataStart;\n var element = load(base);\n var lastIndex = length - 1;\n memory.copy(\n base,\n base + sizeof(),\n lastIndex << alignof()\n );\n store(base + (lastIndex << alignof()),\n // @ts-ignore: cast\n null\n );\n this.length_ = lastIndex;\n return element;\n }\n\n some(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (callbackfn(load(this.dataStart + (index << alignof())), index, this)) return true;\n }\n return false;\n }\n\n unshift(element: T): i32 {\n var newLength = this.length_ + 1;\n ensureSize(changetype(this), newLength, alignof());\n var dataStart = this.dataStart;\n memory.copy(\n dataStart + sizeof(),\n dataStart,\n (newLength - 1) << alignof()\n );\n if (isManaged()) {\n store(dataStart, __retain(changetype(element)));\n } else {\n store(dataStart, element);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n begin = begin < 0 ? max(begin + length, 0) : min(begin, length);\n end = end < 0 ? max(end + length, 0) : min(end , length);\n length = max(end - begin, 0);\n var slice = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var sliceBase = slice.dataStart;\n var thisBase = this.dataStart + (begin << alignof());\n if (isManaged()) {\n let off = 0;\n let end = length << alignof();\n while (off < end) {\n let ref = load(thisBase + off);\n store(sliceBase + off, __retain(ref));\n off += sizeof();\n }\n } else {\n memory.copy(sliceBase, thisBase, length << alignof());\n }\n return slice;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n deleteCount = max(min(deleteCount, length - start), 0);\n var result = changetype>(__allocArray(deleteCount, alignof(), idof>())); // retains\n var resultStart = result.dataStart;\n var thisStart = this.dataStart;\n var thisBase = thisStart + (start << alignof());\n if (isManaged()) {\n for (let i = 0; i < deleteCount; ++i) {\n store(resultStart + (i << alignof()),\n load(thisBase + (i << alignof()))\n );\n // element is moved, so refcount doesn\'t change\n }\n } else {\n memory.copy(\n resultStart,\n thisBase,\n deleteCount << alignof()\n );\n }\n var offset = start + deleteCount;\n if (length != offset) {\n memory.copy(\n thisBase,\n thisStart + (offset << alignof()),\n (length - offset) << alignof()\n );\n }\n this.length_ = length - deleteCount;\n return result;\n }\n\n reverse(): Array {\n var length = this.length_;\n if (length) {\n let front = this.dataStart;\n let back = this.dataStart + ((length - 1) << alignof());\n while (front < back) {\n let temp = load(front);\n store(front, load(back));\n store(back, temp);\n front += sizeof();\n back -= sizeof();\n }\n }\n return this;\n }\n\n sort(comparator: (a: T, b: T) => i32 = COMPARATOR()): this {\n var length = this.length_;\n if (length <= 1) return this;\n var base = this.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b;\n store(base, a); // arr[0] = a;\n }\n return this;\n }\n SORT(base, length, comparator);\n return this;\n }\n\n join(separator: string = ","): string {\n if (isBoolean()) return this.join_bool(separator);\n if (isInteger()) return this.join_int(separator);\n if (isFloat()) return this.join_flt(separator);\n if (isString()) return this.join_str(separator);\n if (isArray()) return this.join_arr(separator);\n if (isReference()) return this.join_ref(separator);\n ERROR("unspported element type");\n return unreachable();\n }\n\n private join_bool(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return select("true", "false", load(dataStart));\n\n var sepLen = separator.length;\n var valueLen = 5; // max possible length of element len("false")\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: bool;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + i);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + lastIndex);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_int(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n // @ts-ignore: type\n if (!lastIndex) return changetype(itoa(load(dataStart))); // retains\n\n var sepLen = separator.length;\n const valueLen = (sizeof() <= 4 ? 10 : 20) + i32(isSigned());\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_flt(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) {\n return changetype(dtoa(\n // @ts-ignore: type\n load(dataStart))\n ); // retains\n }\n\n const valueLen = MAX_DOUBLE_LENGTH;\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_str(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return load(dataStart);\n\n var sepLen = separator.length;\n var estLen = 0;\n var value: string | null;\n for (let i = 0, len = lastIndex + 1; i < len; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) estLen += value.length;\n }\n var offset = 0;\n var result = changetype(__alloc((estLen + sepLen * lastIndex) << 1, idof())); // retains\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) {\n let valueLen = changetype(value).length;\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n if (value !== null) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n changetype(value).length << 1\n );\n }\n return result;\n }\n\n private join_arr(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n\n var result = "";\n var sepLen = separator.length;\n var base = this.dataStart;\n var value: T;\n if (!lastIndex) {\n value = load(base);\n // @ts-ignore: type\n return value ? value.join(separator) : "";\n }\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n if (sepLen) result += separator;\n }\n value = load(base + (lastIndex << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n return result; // registered by concatenation (FIXME: lots of garbage)\n }\n\n private join_ref(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var base = this.dataStart;\n if (!lastIndex) return "[object Object]";\n\n const valueLen = 15; // max possible length of element len("[object Object]")\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof()));\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n if (value) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n if (load(base + (lastIndex << alignof()))) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n toString(): string {\n return this.join();\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = this.dataStart;\n let end = cur + this.dataLength;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n // automatically visits ArrayBufferView (.data) next\n }\n}\n',arraybuffer:'/// \n\nimport { BLOCK, BLOCK_MAXSIZE, BLOCK_OVERHEAD } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INVALIDLENGTH } from "./util/error";\n\nexport abstract class ArrayBufferView {\n\n @unsafe data: ArrayBuffer;\n @unsafe dataStart: usize;\n @unsafe dataLength: u32;\n\n protected constructor(length: i32, alignLog2: i32) {\n if (length > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length = length << alignLog2, idof());\n this.data = changetype(buffer); // retains\n this.dataStart = buffer;\n this.dataLength = length;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n get length(): i32 {\n ERROR("missing implementation: subclasses must implement ArrayBufferView#length");\n return unreachable();\n }\n}\n\n@sealed export class ArrayBuffer {\n\n static isView(value: T): bool {\n if (value) {\n if (value instanceof Int8Array) return true;\n if (value instanceof Uint8Array) return true;\n if (value instanceof Uint8ClampedArray) return true;\n if (value instanceof Int16Array) return true;\n if (value instanceof Uint16Array) return true;\n if (value instanceof Int32Array) return true;\n if (value instanceof Uint32Array) return true;\n if (value instanceof Int64Array) return true;\n if (value instanceof Uint64Array) return true;\n if (value instanceof Float32Array) return true;\n if (value instanceof Float64Array) return true;\n if (value instanceof DataView) return true;\n }\n return false;\n }\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length, idof());\n memory.fill(buffer, 0, length);\n return changetype(buffer); // retains\n }\n\n get byteLength(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n }\n\n slice(begin: i32 = 0, end: i32 = BLOCK_MAXSIZE): ArrayBuffer {\n var length = this.byteLength;\n begin = begin < 0 ? max(length + begin, 0) : min(begin, length);\n end = end < 0 ? max(length + end , 0) : min(end , length);\n var outSize = max(end - begin, 0);\n var out = __alloc(outSize, idof());\n memory.copy(out, changetype(this) + begin, outSize);\n return changetype(out); // retains\n }\n\n toString(): string {\n return "[object ArrayBuffer]";\n }\n}\n',"bindings/Date":"export declare function UTC(\n // NOTE: Using i32 below saves us a f64.convert_s instruction and moves the responsibility for\n // converting the value to the WASM/JS boundary.\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: f64\n): f64;\nexport declare function now(): f64;\n","bindings/Math":"export declare const E: f64;\nexport declare const LN2: f64;\nexport declare const LN10: f64;\nexport declare const LOG2E: f64;\nexport declare const LOG10E: f64;\nexport declare const PI: f64;\nexport declare const SQRT1_2: f64;\nexport declare const SQRT2: f64;\n\nexport declare function abs(x: f64): f64;\nexport declare function acos(x: f64): f64;\nexport declare function acosh(x: f64): f64;\nexport declare function asin(x: f64): f64;\nexport declare function asinh(x: f64): f64;\nexport declare function atan(x: f64): f64;\nexport declare function atan2(y: f64, x: f64): f64;\nexport declare function atanh(x: f64): f64;\nexport declare function cbrt(x: f64): f64;\nexport declare function ceil(x: f64): f64;\nexport declare function clz32(x: f64): f64;\nexport declare function cos(x: f64): f64;\nexport declare function cosh(x: f64): f64;\nexport declare function exp(x: f64): f64;\nexport declare function expm1(x: f64): f64;\nexport declare function floor(x: f64): f64;\nexport declare function fround(x: f64): f32;\nexport declare function hypot(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function imul(a: f64, b: f64): f64;\nexport declare function log(x: f64): f64;\nexport declare function log10(x: f64): f64;\nexport declare function log1p(x: f64): f64;\nexport declare function log2(x: f64): f64;\nexport declare function max(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function min(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function pow(base: f64, exponent: f64): f64;\nexport declare function random(): f64;\nexport declare function round(x: f64): f64;\nexport declare function sign(x: f64): f64;\nexport declare function sin(x: f64): f64;\nexport declare function sinh(x: f64): f64;\nexport declare function sqrt(x: f64): f64;\nexport declare function tan(x: f64): f64;\nexport declare function tanh(x: f64): f64;\nexport declare function trunc(x: f64): f64;\n","bindings/wasi_unstable":"// see: https://wasi.dev\n\n/* tslint:disable:max-line-length */\n\n// helper types to be more explicit\ntype char = u8;\ntype ptr = usize; // all pointers are usize'd\ntype struct = T; // structs are references already in AS\n\n/** Read command-line argument data. */\nexport declare function args_get(\n /** Input: Pointer to a buffer to write the argument pointers. */\n argv: ptr>,\n /** Input: Pointer to a buffer to write the argument string data. */\n argv_buf: ptr\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function args_sizes_get(\n /** Output: Number of arguments. */\n argc: ptr,\n /** Output: Size of the argument string data. */\n argv_buf_size: ptr\n): errno;\n\n/** Return the resolution of a clock. */\nexport declare function clock_res_get(\n /** Input: The clock for which to return the resolution. */\n clock: clockid,\n /** Output: The resolution of the clock. */\n resolution: ptr\n): errno;\n\n/** Return the time value of a clock. */\nexport declare function clock_time_get(\n /** Input: Cock for which to return the time. */\n clock: clockid,\n /** Input: Maximum lag (exclusive) that the returned time value may have, compared to its actual value. */\n precision: timestamp,\n /** Output: Time value of the clock. */\n time: ptr\n): errno;\n\n/** Read environment variable data. */\nexport declare function environ_get(\n /** Input: Pointer to a buffer to write the environment variable pointers. */\n environ: ptr,\n /** Input: Pointer to a buffer to write the environment variable string data. */\n environ_buf: usize\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function environ_sizes_get(\n /** Output: The number of environment variables. */\n environ_count: ptr,\n /** Output: The size of the environment variable string data. */\n environ_buf_size: ptr\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_advise(\n /** Input: The file descriptor for the file for which to provide file advisory information. */\n fd: fd,\n /** Input: The offset within the file to which the advisory applies. */\n offset: filesize,\n /** Input: The length of the region to which the advisory applies. */\n len: filesize,\n /** Input: The advice. */\n advice: advice\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_allocate(\n /** Input: The file descriptor for the file in which to allocate space. */\n fd: fd,\n /** Input: The offset at which to start the allocation. */\n offset: filesize,\n /** Input: The length of the area that is allocated. */\n len: filesize\n): errno;\n\n/** Close a file descriptor. */\nexport declare function fd_close(\n /** Input: The file descriptor to close. */\n fd: fd\n): errno;\n\n/** Synchronize the data of a file to disk. */\nexport declare function fd_datasync(\n /** Input: The file descriptor of the file to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Get the attributes of a file descriptor. */\nexport declare function fd_fdstat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file descriptor's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the flags associated with a file descriptor. */\nexport declare function fd_fdstat_set_flags(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the file descriptor flags. */\n flags: fdflags\n): errno;\n\n/** Adjust the rights associated with a file descriptor. */\nexport declare function fd_fdstat_set_rights(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_base: rights,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_inheriting: rights\n): errno;\n\n/** Return the attributes of an open file. */\nexport declare function fd_filestat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros. */\nexport declare function fd_filestat_set_size(\n /** Input: A file descriptor for the file to adjust. */\n fd: fd,\n /** Input: The desired file size. */\n size: filesize\n): errno;\n\n/** Adjust the timestamps of an open file or directory. */\nexport declare function fd_filestat_set_times(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Read from a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pread(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors in which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors in which to store data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to read. */\n offset: filesize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_get(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: The buffer where the description is stored. */\n buf: struct\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_dir_name(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: Buffer into which to write the preopened directory name. */\n path: ptr,\n /** Input: Length of the buffer into which to write the preopened directory name. */\n path_len: usize\n): errno;\n\n/** Write to a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pwrite(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to write. */\n offset: filesize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/** Read from a file descriptor. */\nexport declare function fd_read(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors to which to store data. */\n iovs_len: usize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Read directory entries from a directory. */\nexport declare function fd_readdir(\n /** Input: Directory from which to read the directory entries. */\n fd: fd,\n /** Input: Buffer where directory entries are stored. */\n buf: ptr>,\n /** Input: Length of the buffer where directory entries are stored. */\n buf_len: usize,\n /** Input: Location within the directory to start reading. */\n cookie: dircookie,\n /** Output: Number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached. */\n buf_used: ptr\n): errno;\n\n/** Atomically replace a file descriptor by renumbering another file descriptor. */\nexport declare function fd_renumber(\n /** Input: The file descriptor to renumber. */\n from: fd,\n /** Input: The file descriptor to overwrite. */\n to: fd\n): errno;\n\n/** Move the offset of a file descriptor. */\nexport declare function fd_seek(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The number of bytes to move. */\n offset: filedelta,\n /** Input: The base from which the offset is relative. */\n whence: whence,\n /** Output: The new offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Synchronize the data and metadata of a file to disk. */\nexport declare function fd_sync(\n /** Input: The file descriptor of the file containing the data and metadata to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Return the current offset of a file descriptor. */\nexport declare function fd_tell(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Output: The current offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Write to a file descriptor. */\nexport declare function fd_write(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/* Create a directory. */\nexport declare function path_create_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path at which to create the directory. */\n path: ptr,\n /** Input: The path at which to create the directory. */\n path_len: usize\n): errno;\n\n/** Return the attributes of a file or directory. */\nexport declare function path_filestat_get(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to inspect. */\n path: ptr,\n /** Input: The path of the file or directory to inspect. */\n path_len: usize,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the timestamps of a file or directory. */\nexport declare function path_filestat_set_times(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to operate on. */\n path: ptr,\n /** Input: The path of the file or directory to operate on. */\n path_len: usize,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Create a hard link. */\nexport declare function path_link(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n old_flags: lookupflags,\n /** Input: The source path from which to link. */\n old_path: ptr,\n /** Input: The source path from which to link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path at which to create the hard link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the hard link. */\n new_path_len: usize\n): errno;\n\n/** Open a file or directory. */\nexport declare function path_open(\n /** Input: The working directory at which the resolution of the path starts. */\n dirfd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n dirflags: lookupflags,\n /** Input: The path of the file or directory to open. */\n path: ptr,\n /** Input: The length of the path of the file or directory to open. */\n path_len: usize,\n /** Input: The method by which to open the file. */\n oflags: oflags,\n /** Input: The initial base rights that apply to operations using the file descriptor itself. */\n fs_rights_base: rights,\n /** Input: The initial inheriting rights that apply to file descriptors derived from it. */\n fs_rights_inheriting: rights,\n /** Input: The initial flags of the file descriptor. */\n fs_flags: fdflags,\n /** Output: The file descriptor of the file that has been opened. */\n fd: ptr\n): errno;\n\n/** Read the contents of a symbolic link. */\nexport declare function path_readlink(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path of the symbolic link from which to read. */\n path: ptr,\n /** Input: The length of the path of the symbolic link from which to read. */\n path_len: usize,\n /** Input: The buffer to which to write the contents of the symbolic link. */\n buf: ptr,\n /** Input: The length of the buffer to which to write the contents of the symbolic link. */\n buf_len: usize,\n /** Output: The number of bytes placed in the buffer. */\n buf_used: ptr\n): errno;\n\n/** Remove a directory. */\nexport declare function path_remove_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a directory to remove. */\n path: ptr,\n /** Input: The length of the path to a directory to remove. */\n path_len: usize\n): errno;\n\n/** Rename a file or directory. */\nexport declare function path_rename(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: The source path of the file or directory to rename. */\n old_path: ptr,\n /** Input: The length of the source path of the file or directory to rename. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path to which to rename the file or directory. */\n new_path: ptr,\n /** Input: The length of the destination path to which to rename the file or directory. */\n new_path_len: usize\n): errno;\n\n/** Create a symbolic link. */\nexport declare function path_symlink(\n /** Input: The contents of the symbolic link. */\n old_path: ptr,\n /** Input: The length of the contents of the symbolic link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The destination path at which to create the symbolic link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the symbolic link. */\n new_path_len: usize\n): errno;\n\n/** Unlink a file. */\nexport declare function path_unlink_file(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a file to unlink. */\n path: ptr,\n /** Input: The length of the path to a file to unlink. */\n path_len: usize\n): errno;\n\n/** Concurrently poll for the occurrence of a set of events. */\nexport declare function poll_oneoff(\n /** Input: The events to which to subscribe. */\n in_: ptr>,\n /** Input: The events that have occurred. */\n out: ptr>,\n /** Input: Both the number of subscriptions and events. */\n nsubscriptions: usize,\n /** Output: The number of events stored. */\n nevents: ptr\n): errno;\n\n/** Terminate the process normally. An exit code of 0 indicates successful termination of the program. The meanings of other values is dependent on the environment. */\nexport declare function proc_exit(\n /** Input: The exit code returned by the process. */\n rval: u32\n): void;\n\n/** Send a signal to the process of the calling thread. */\nexport declare function proc_raise(\n /** Input: The signal condition to trigger. */\n sig: signal\n): errno;\n\n/** Write high-quality random data into a buffer. */\nexport declare function random_get(\n /** Input: The buffer to fill with random data. */\n buf: usize,\n /** Input: The length of the buffer to fill with random data. */\n buf_len: usize\n): errno;\n\n/** Temporarily yield execution of the calling thread. */\nexport declare function sched_yield(): errno;\n\n/** Receive a message from a socket. */\nexport declare function sock_recv(\n /** Input: The socket on which to receive data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n ri_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to store data. */\n ri_data_len: usize,\n /** Input: Message flags. */\n ri_flags: riflags,\n /** Output: Number of bytes stored in `ri_data`. */\n ro_datalen: ptr,\n /** Output: Message flags. */\n ro_flags: ptr\n): errno;\n\n/** Send a message on a socket. */\nexport declare function sock_send(\n /** Input: The socket on which to send data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to retrieve data */\n si_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to retrieve data */\n si_data_len: usize,\n /** Input: Message flags. */\n si_flags: siflags,\n /** Output: Number of bytes transmitted. */\n so_datalen: ptr\n): errno;\n\n/** Shut down socket send and receive channels. */\nexport declare function sock_shutdown(\n /** Input: The socket on which to shutdown channels. */\n sock: fd,\n /** Input: Which channels on the socket to shut down. */\n how: sdflags\n): errno;\n\n// === Types ======================================================================================\n\n/** File or memory access pattern advisory information. */\nexport namespace advice {\n /** The application has no advice to give on its behavior with respect to the specified data. */\n // @ts-ignore: decorator\n @inline\n export const NORMAL: advice = 0;\n /** The application expects to access the specified data sequentially from lower offsets to higher offsets. */\n // @ts-ignore: decorator\n @inline\n export const SEQUENTIAL : advice = 1;\n /** The application expects to access the specified data in a random order. */\n // @ts-ignore: decorator\n @inline\n export const RANDOM: advice = 2;\n /** The application expects to access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const WILLNEED: advice = 3;\n /** The application expects that it will not access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const DONTNEED: advice = 4;\n /** The application expects to access the specified data once and then not reuse it thereafter. */\n // @ts-ignore: decorator\n @inline\n export const NOREUSE: advice = 5;\n}\nexport type advice = u8;\n\n/** Identifiers for clocks. */\nexport namespace clockid {\n /** The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. */\n // @ts-ignore: decorator\n @inline\n export const REALTIME: clockid = 0;\n /** The store-wide monotonic clock. Absolute value has no meaning. */\n // @ts-ignore: decorator\n @inline\n export const MONOTONIC: clockid = 1;\n /** The CPU-time clock associated with the current process. */\n // @ts-ignore: decorator\n @inline\n export const PROCESS_CPUTIME_ID: clockid = 2;\n /** The CPU-time clock associated with the current thread. */\n // @ts-ignore: decorator\n @inline\n export const THREAD_CPUTIME_ID: clockid = 3;\n}\nexport type clockid = u32;\n\n/** Identifier for a device containing a file system. Can be used in combination with `inode` to uniquely identify a file or directory in the filesystem. */\nexport type device = u64;\n\n/** A reference to the offset of a directory entry. */\nexport type dircookie = u64;\n\n/** A directory entry. */\n@unmanaged export class dirent {\n /** The offset of the next directory entry stored in this directory. */\n next: dircookie;\n /** The serial number of the file referred to by this directory entry. */\n ino: inode;\n /** The length of the name of the directory entry. */\n namlen: u32;\n /** The type of the file referred to by this directory entry. */\n type: filetype;\n private __padding0: u16;\n}\n\n/** Error codes returned by functions. */\nexport namespace errno {\n /** No error occurred. System call completed successfully. */\n // @ts-ignore: decorator\n @inline\n export const SUCCESS: errno = 0;\n /** Argument list too long. */\n // @ts-ignore: decorator\n @inline\n export const TOOBIG: errno = 1;\n /** Permission denied. */\n // @ts-ignore: decorator\n @inline\n export const ACCES: errno = 2;\n /** Address in use. */\n // @ts-ignore: decorator\n @inline\n export const ADDRINUSE: errno = 3;\n /** Address not available. */\n // @ts-ignore: decorator\n @inline\n export const ADDRNOTAVAIL: errno = 4;\n /** Address family not supported. */\n // @ts-ignore: decorator\n @inline\n export const AFNOSUPPORT: errno = 5;\n /** Resource unavailable, or operation would block. */\n // @ts-ignore: decorator\n @inline\n export const AGAIN: errno = 6;\n /** Connection already in progress. */\n // @ts-ignore: decorator\n @inline\n export const ALREADY: errno = 7;\n /** Bad file descriptor. */\n // @ts-ignore: decorator\n @inline\n export const BADF: errno = 8;\n /** Bad message. */\n // @ts-ignore: decorator\n @inline\n export const BADMSG: errno = 9;\n /** Device or resource busy. */\n // @ts-ignore: decorator\n @inline\n export const BUSY: errno = 10;\n /** Operation canceled. */\n // @ts-ignore: decorator\n @inline\n export const CANCELED: errno = 11;\n /** No child processes. */\n // @ts-ignore: decorator\n @inline\n export const CHILD: errno = 12;\n /** Connection aborted. */\n // @ts-ignore: decorator\n @inline\n export const CONNABORTED: errno = 13;\n /** Connection refused. */\n // @ts-ignore: decorator\n @inline\n export const CONNREFUSED: errno = 14;\n /** Connection reset. */\n // @ts-ignore: decorator\n @inline\n export const CONNRESET: errno = 15;\n /** Resource deadlock would occur. */\n // @ts-ignore: decorator\n @inline\n export const DEADLK: errno = 16;\n /** Destination address required. */\n // @ts-ignore: decorator\n @inline\n export const DESTADDRREQ: errno = 17;\n /** Mathematics argument out of domain of function. */\n // @ts-ignore: decorator\n @inline\n export const DOM: errno = 18;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const DQUOT: errno = 19;\n /** File exists. */\n // @ts-ignore: decorator\n @inline\n export const EXIST: errno = 20;\n /** Bad address. */\n // @ts-ignore: decorator\n @inline\n export const FAULT: errno = 21;\n /** File too large. */\n // @ts-ignore: decorator\n @inline\n export const FBIG: errno = 22;\n /** Host is unreachable. */\n // @ts-ignore: decorator\n @inline\n export const HOSTUNREACH: errno = 23;\n /** Identifier removed. */\n // @ts-ignore: decorator\n @inline\n export const IDRM: errno = 24;\n /** Illegal byte sequence. */\n // @ts-ignore: decorator\n @inline\n export const ILSEQ: errno = 25;\n /** Operation in progress. */\n // @ts-ignore: decorator\n @inline\n export const INPROGRESS: errno = 26;\n /** Interrupted function. */\n // @ts-ignore: decorator\n @inline\n export const INTR: errno = 27;\n /** Invalid argument. */\n // @ts-ignore: decorator\n @inline\n export const INVAL: errno = 28;\n /** I/O error. */\n // @ts-ignore: decorator\n @inline\n export const IO: errno = 29;\n /** Socket is connected. */\n // @ts-ignore: decorator\n @inline\n export const ISCONN: errno = 30;\n /** Is a directory. */\n // @ts-ignore: decorator\n @inline\n export const ISDIR: errno = 31;\n /** Too many levels of symbolic links. */\n // @ts-ignore: decorator\n @inline\n export const LOOP: errno = 32;\n /** File descriptor value too large. */\n // @ts-ignore: decorator\n @inline\n export const MFILE: errno = 33;\n /** Too many links. */\n // @ts-ignore: decorator\n @inline\n export const MLINK: errno = 34;\n /** Message too large. */\n // @ts-ignore: decorator\n @inline\n export const MSGSIZE: errno = 35;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const MULTIHOP: errno = 36;\n /** Filename too long. */\n // @ts-ignore: decorator\n @inline\n export const NAMETOOLONG: errno = 37;\n /** Network is down. */\n // @ts-ignore: decorator\n @inline\n export const NETDOWN: errno = 38;\n /** Connection aborted by network. */\n // @ts-ignore: decorator\n @inline\n export const NETRESET: errno = 39;\n /** Network unreachable. */\n // @ts-ignore: decorator\n @inline\n export const NETUNREACH: errno = 40;\n /** Too many files open in system. */\n // @ts-ignore: decorator\n @inline\n export const NFILE: errno = 41;\n /** No buffer space available. */\n // @ts-ignore: decorator\n @inline\n export const NOBUFS: errno = 42;\n /** No such device. */\n // @ts-ignore: decorator\n @inline\n export const NODEV: errno = 43;\n /** No such file or directory. */\n // @ts-ignore: decorator\n @inline\n export const NOENT: errno = 44;\n /** Executable file format error. */\n // @ts-ignore: decorator\n @inline\n export const NOEXEC: errno = 45;\n /** No locks available. */\n // @ts-ignore: decorator\n @inline\n export const NOLCK: errno = 46;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const NOLINK: errno = 47;\n /** Not enough space. */\n // @ts-ignore: decorator\n @inline\n export const NOMEM: errno = 48;\n /** No message of the desired type. */\n // @ts-ignore: decorator\n @inline\n export const NOMSG: errno = 49;\n /** Protocol not available. */\n // @ts-ignore: decorator\n @inline\n export const NOPROTOOPT: errno = 50;\n /** No space left on device. */\n // @ts-ignore: decorator\n @inline\n export const NOSPC: errno = 51;\n /** Function not supported. */\n // @ts-ignore: decorator\n @inline\n export const NOSYS: errno = 52;\n /** The socket is not connected. */\n // @ts-ignore: decorator\n @inline\n export const NOTCONN: errno = 53;\n /** Not a directory or a symbolic link to a directory. */\n // @ts-ignore: decorator\n @inline\n export const NOTDIR: errno = 54;\n /** Directory not empty. */\n // @ts-ignore: decorator\n @inline\n export const NOTEMPTY: errno = 55;\n /** State not recoverable. */\n // @ts-ignore: decorator\n @inline\n export const NOTRECOVERABLE: errno = 56;\n /** Not a socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSOCK: errno = 57;\n /** Not supported, or operation not supported on socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSUP: errno = 58;\n /** Inappropriate I/O control operation. */\n // @ts-ignore: decorator\n @inline\n export const NOTTY: errno = 59;\n /** No such device or address. */\n // @ts-ignore: decorator\n @inline\n export const NXIO: errno = 60;\n /** Value too large to be stored in data type. */\n // @ts-ignore: decorator\n @inline\n export const OVERFLOW: errno = 61;\n /** Previous owner died. */\n // @ts-ignore: decorator\n @inline\n export const OWNERDEAD: errno = 62;\n /** Operation not permitted. */\n // @ts-ignore: decorator\n @inline\n export const PERM: errno = 63;\n /** Broken pipe. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: errno = 64;\n /** Protocol error. */\n // @ts-ignore: decorator\n @inline\n export const PROTO: errno = 65;\n /** Protocol not supported. */\n // @ts-ignore: decorator\n @inline\n export const PROTONOSUPPORT: errno = 66;\n /** Protocol wrong type for socket. */\n // @ts-ignore: decorator\n @inline\n export const PROTOTYPE: errno = 67;\n /** Result too large. */\n // @ts-ignore: decorator\n @inline\n export const RANGE: errno = 68;\n /** Read-only file system. */\n // @ts-ignore: decorator\n @inline\n export const ROFS: errno = 69;\n /** Invalid seek. */\n // @ts-ignore: decorator\n @inline\n export const SPIPE: errno = 70;\n /** No such process. */\n // @ts-ignore: decorator\n @inline\n export const SRCH: errno = 71;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const STALE: errno = 72;\n /** Connection timed out. */\n // @ts-ignore: decorator\n @inline\n export const TIMEDOUT: errno = 73;\n /** Text file busy. */\n // @ts-ignore: decorator\n @inline\n export const TXTBSY: errno = 74;\n /** Cross-device link. */\n // @ts-ignore: decorator\n @inline\n export const XDEV: errno = 75;\n /** Extension: Capabilities insufficient. */\n // @ts-ignore: decorator\n @inline\n export const NOTCAPABLE: errno = 76;\n}\nexport type errno = u16;\n\n/** An event that occurred. */\n@unmanaged export abstract class event {\n /** User-provided value that got attached to `subscription#userdata`. */\n userdata: userdata;\n /** If non-zero, an error that occurred while processing the subscription request. */\n error: errno;\n /* The type of the event that occurred. */\n type: eventtype;\n private __padding0: u16;\n}\n\n/** An event that occurred when type is `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\n@unmanaged export class rwevent extends event {\n /* The number of bytes available for reading or writing. */\n nbytes: filesize;\n /* The state of the file descriptor. */\n flags: eventrwflags;\n private __padding1: u32;\n}\n\n/** The state of the file descriptor subscribed to with `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\nexport namespace eventrwflags {\n /** The peer of this socket has closed or disconnected. */\n // @ts-ignore: decorator\n @inline\n export const HANGUP: eventrwflags = 1;\n}\nexport type eventrwflags = u16;\n\n/** Type of a subscription to an event or its occurrence. */\nexport namespace eventtype {\n /** The time value of clock has reached the timestamp. */\n // @ts-ignore: decorator\n @inline\n export const CLOCK: eventtype = 0;\n /** File descriptor has data available for reading. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: eventtype = 1;\n /** File descriptor has capacity available for writing */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: eventtype = 2;\n}\nexport type eventtype = u8;\n\n/** Exit code generated by a process when exiting. */\nexport type exitcode = u32;\n\n/** A file descriptor number. */\nexport type fd = u32;\n\n/** File descriptor flags. */\nexport namespace fdflags {\n /** Append mode: Data written to the file is always appended to the file's end. */\n // @ts-ignore: decorator\n @inline\n export const APPEND: fdflags = 1;\n /** Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. */\n // @ts-ignore: decorator\n @inline\n export const DSYNC: fdflags = 2;\n /** Non-blocking mode. */\n // @ts-ignore: decorator\n @inline\n export const NONBLOCK: fdflags = 4;\n /** Synchronized read I/O operations. */\n // @ts-ignore: decorator\n @inline\n export const RSYNC: fdflags = 8;\n /** Write according to synchronized I/O file integrity completion. */\n // @ts-ignore: decorator\n @inline\n export const SYNC: fdflags = 16;\n}\nexport type fdflags = u16;\n\n/** File descriptor attributes. */\n@unmanaged export class fdstat {\n /** File type. */\n filetype: filetype;\n /** File descriptor flags. */\n flags: fdflags;\n /** Rights that apply to this file descriptor. */\n rights_base: rights;\n /** Maximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., through `path_open`. */\n rights_inheriting: rights;\n}\n\n/** Relative offset within a file. */\nexport type filedelta = i64;\n\n/** Non-negative file size or length of a region within a file. */\nexport type filesize = u64;\n\n/** File attributes. */\n@unmanaged export class filestat {\n /** Device ID of device containing the file. */\n dev: device;\n /** File serial number. */\n ino: inode;\n /** File type. */\n filetype: filetype;\n /** Number of hard links to the file. */\n nlink: linkcount;\n /** For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. */\n size: filesize;\n /** Last data access timestamp. */\n atim: timestamp;\n /** Last data modification timestamp. */\n mtim: timestamp;\n /** Last file status change timestamp. */\n ctim: timestamp;\n}\n\n/** The type of a file descriptor or file. */\nexport namespace filetype {\n /** The type of the file descriptor or file is unknown or is different from any of the other types specified. */\n // @ts-ignore: decorator\n @inline\n export const UNKNOWN: filetype = 0;\n /** The file descriptor or file refers to a block device inode. */\n // @ts-ignore: decorator\n @inline\n export const BLOCK_DEVICE: filetype = 1;\n /** The file descriptor or file refers to a character device inode. */\n // @ts-ignore: decorator\n @inline\n export const CHARACTER_DEVICE: filetype = 2;\n /** The file descriptor or file refers to a directory inode. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: filetype = 3;\n /** The file descriptor or file refers to a regular file inode. */\n // @ts-ignore: decorator\n @inline\n export const REGULAR_FILE: filetype = 4;\n /** The file descriptor or file refers to a datagram socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_DGRAM: filetype = 5;\n /** The file descriptor or file refers to a byte-stream socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_STREAM: filetype = 6;\n /** The file refers to a symbolic link inode. */\n // @ts-ignore: decorator\n @inline\n export const SYMBOLIC_LINK: filetype = 7;\n}\nexport type filetype = u8;\n\n/** Which file time attributes to adjust. */\nexport namespace fstflags {\n /** Adjust the last data access timestamp to the value stored in `filestat#st_atim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM: fstflags = 1;\n /** Adjust the last data access timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM_NOW: fstflags = 2;\n /** Adjust the last data modification timestamp to the value stored in `filestat#st_mtim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM: fstflags = 4;\n /** Adjust the last data modification timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM_NOW: fstflags = 8;\n}\nexport type fstflags = u16;\n\n/** File serial number that is unique within its file system. */\nexport type inode = u64;\n\n/** A region of memory for scatter/gather reads. */\n@unmanaged export class iovec {\n /** The address of the buffer to be filled. */\n buf: usize;\n /** The length of the buffer to be filled. */\n buf_len: usize;\n}\n\n/** Number of hard links to an inode. */\nexport type linkcount = u32;\n\n/** Flags determining the method of how paths are resolved. */\nexport namespace lookupflags {\n /** As long as the resolved path corresponds to a symbolic link, it is expanded. */\n // @ts-ignore: decorator\n @inline\n export const SYMLINK_FOLLOW: lookupflags = 1;\n}\nexport type lookupflags = u32;\n\n/** Open flags. */\nexport namespace oflags {\n /** Create file if it does not exist. */\n // @ts-ignore: decorator\n @inline\n export const CREAT: oflags = 1;\n /** Fail if not a directory. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: oflags = 2;\n /** Fail if file already exists. */\n // @ts-ignore: decorator\n @inline\n export const EXCL: oflags = 4;\n /** Truncate file to size 0. */\n // @ts-ignore: decorator\n @inline\n export const TRUNC: oflags = 8;\n}\nexport type oflags = u16;\n\n// TODO: undocumented\nexport namespace preopentype {\n // @ts-ignore: decorator\n @inline\n export const DIR: preopentype = 0;\n}\nexport type preopentype = u8;\n\n// TODO: undocumented\nexport abstract class prestat {\n type: preopentype;\n}\n\n// TODO: undocumented\nexport class dirprestat extends prestat {\n name_len: usize;\n}\n\n/** Flags provided to `sock_recv`. */\nexport namespace riflags {\n /** Returns the message without removing it from the socket's receive queue. */\n // @ts-ignore: decorator\n @inline\n export const PEEK: riflags = 1;\n /** On byte-stream sockets, block until the full amount of data can be returned. */\n // @ts-ignore: decorator\n @inline\n export const WAITALL: riflags = 2;\n}\nexport type riflags = u16;\n\n/** File descriptor rights, determining which actions may be performed. */\nexport namespace rights {\n /** The right to invoke `fd_datasync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_DATASYNC: rights = 1;\n /** The right to invoke `fd_read` and `sock_recv`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: rights = 2;\n /** The right to invoke `fd_seek`. This flag implies `rights.FD_TELL`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SEEK: rights = 4;\n /** The right to invoke `fd_fdstat_set_flags`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FDSTAT_SET_FLAGS: rights = 8;\n /** The right to invoke `fd_sync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SYNC: rights = 16;\n /** The right to invoke `fd_seek` in such a way that the file offset remains unaltered (i.e., `whence.CUR` with offset zero), or to invoke `fd_tell`). */\n // @ts-ignore: decorator\n @inline\n export const FD_TELL: rights = 32;\n /** The right to invoke `fd_write` and `sock_send`. If `rights.FD_SEEK` is set, includes the right to invoke `fd_pwrite`. */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: rights = 64;\n /** The right to invoke `fd_advise`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ADVISE: rights = 128;\n /** The right to invoke `fd_allocate`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ALLOCATE: rights = 256;\n /** The right to invoke `path_create_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_DIRECTORY: rights = 512;\n /** If `rights.PATH_OPEN` is set, the right to invoke `path_open` with `oflags.CREAT`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_FILE: rights = 1024;\n /** The right to invoke `path_link` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_SOURCE: rights = 2048;\n /** The right to invoke `path_link` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_TARGET: rights = 4096;\n /** The right to invoke `path_open`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_OPEN: rights = 8192;\n /** The right to invoke `fd_readdir`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READDIR: rights = 16384;\n /** The right to invoke `path_readlink`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_READLINK: rights = 32768;\n /** The right to invoke `path_rename` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_SOURCE: rights = 65536;\n /** The right to invoke `path_rename` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_TARGET: rights = 131072;\n /** The right to invoke `path_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_GET: rights = 262144;\n /** The right to change a file's size (there is no `path_filestat_set_size`). If `rights.PATH_OPEN` is set, includes the right to invoke `path_open` with `oflags.TRUNC`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_SIZE: rights = 524288;\n /** The right to invoke `path_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_TIMES: rights = 1048576;\n /** The right to invoke `fd_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_GET: rights = 2097152;\n /** The right to invoke `fd_filestat_set_size`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_SIZE: rights = 4194304;\n /** The right to invoke `fd_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_TIMES: rights = 8388608;\n /** The right to invoke `path_symlink`. */\n // @ts-ignore: decorator\n @inline\n export const RIGHT_PATH_SYMLINK: rights = 16777216;\n /** The right to invoke `path_remove_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_REMOVE_DIRECTORY: rights = 33554432;\n /** The right to invoke `path_unlink_file`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_UNLINK_FILE: rights = 67108864;\n /** If `rights.FD_READ` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_READ`. If `rights.FD_WRITE` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_WRITE`. */\n // @ts-ignore: decorator\n @inline\n export const POLL_FD_READWRITE: rights = 134217728;\n /** The right to invoke `sock_shutdown`. */\n // @ts-ignore: decorator\n @inline\n export const SOCK_SHUTDOWN: rights = 268435456;\n}\nexport type rights = u64;\n\n/** Flags returned by `sock_recv`. */\nexport namespace roflags {\n /** Message data has been truncated. */\n // @ts-ignore: decorator\n @inline\n export const DATA_TRUNCATED: roflags = 1;\n}\nexport type roflags = u16;\n\n/** Which channels on a socket to shut down. */\nexport namespace sdflags {\n /** Disables further receive operations. */\n // @ts-ignore: decorator\n @inline\n export const RD: sdflags = 1;\n /** Disables further send operations. */\n // @ts-ignore: decorator\n @inline\n export const WR: sdflags = 2;\n}\nexport type sdflags = u8;\n\n/** Flags provided to `sock_send`. */\nexport namespace siflags {\n // As there are currently no flags defined, it must be set to zero.\n}\nexport type siflags = u16;\n\n/** Signal condition. */\nexport namespace signal {\n /** Hangup. */\n // @ts-ignore: decorator\n @inline\n export const HUP: signal = 1;\n /** Terminate interrupt signal. */\n // @ts-ignore: decorator\n @inline\n export const INT: signal = 2;\n /** Terminal quit signal. */\n // @ts-ignore: decorator\n @inline\n export const QUIT: signal = 3;\n /** Illegal instruction. */\n // @ts-ignore: decorator\n @inline\n export const ILL: signal = 4;\n /** Trace/breakpoint trap. */\n // @ts-ignore: decorator\n @inline\n export const TRAP: signal = 5;\n /** Process abort signal. */\n // @ts-ignore: decorator\n @inline\n export const ABRT: signal = 6;\n /** Access to an undefined portion of a memory object. */\n // @ts-ignore: decorator\n @inline\n export const BUS: signal = 7;\n /** Erroneous arithmetic operation. */\n // @ts-ignore: decorator\n @inline\n export const FPE: signal = 8;\n /** Kill. */\n // @ts-ignore: decorator\n @inline\n export const KILL: signal = 9;\n /** User-defined signal 1. */\n // @ts-ignore: decorator\n @inline\n export const USR1: signal = 10;\n /** Invalid memory reference. */\n // @ts-ignore: decorator\n @inline\n export const SEGV: signal = 11;\n /** User-defined signal 2. */\n // @ts-ignore: decorator\n @inline\n export const USR2: signal = 12;\n /** Write on a pipe with no one to read it. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: signal = 13;\n /** Alarm clock. */\n // @ts-ignore: decorator\n @inline\n export const ALRM: signal = 14;\n /** Termination signal. */\n // @ts-ignore: decorator\n @inline\n export const TERM: signal = 15;\n /** Child process terminated, stopped, or continued. */\n // @ts-ignore: decorator\n @inline\n export const CHLD: signal = 16;\n /** Continue executing, if stopped. */\n // @ts-ignore: decorator\n @inline\n export const CONT: signal = 17;\n /** Stop executing. */\n // @ts-ignore: decorator\n @inline\n export const STOP: signal = 18;\n /** Terminal stop signal. */\n // @ts-ignore: decorator\n @inline\n export const TSTP: signal = 19;\n /** Background process attempting read. */\n // @ts-ignore: decorator\n @inline\n export const TTIN: signal = 20;\n /** Background process attempting write. */\n // @ts-ignore: decorator\n @inline\n export const TTOU: signal = 21;\n /** High bandwidth data is available at a socket. */\n // @ts-ignore: decorator\n @inline\n export const URG: signal = 22;\n /** CPU time limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XCPU: signal = 23;\n /** File size limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XFSZ: signal = 24;\n /** Virtual timer expired. */\n // @ts-ignore: decorator\n @inline\n export const VTALRM: signal = 25;\n // @ts-ignore: decorator\n @inline\n export const PROF: signal = 26;\n // @ts-ignore: decorator\n @inline\n export const WINCH: signal = 27;\n // @ts-ignore: decorator\n @inline\n export const POLL: signal = 28;\n // @ts-ignore: decorator\n @inline\n export const PWR: signal = 29;\n /** Bad system call. */\n // @ts-ignore: decorator\n @inline\n export const SYS: signal = 30;\n}\nexport type signal = u8;\n\n/** Flags determining how to interpret the timestamp provided in `subscription_t::u.clock.timeout. */\nexport namespace subclockflags {\n /** If set, treat the timestamp provided in `clocksubscription` as an absolute timestamp. */\n // @ts-ignore: decorator\n @inline\n export const ABSTIME: subclockflags = 1;\n}\nexport type subclockflags = u16;\n\n/** Subscription to an event. */\n@unmanaged export abstract class subscription {\n /** User-provided value that is attached to the subscription. */\n userdata: userdata;\n /** The type of the event to which to subscribe. */\n type: eventtype;\n private __padding0: u32;\n}\n\n/* Subscription to an event of type `eventtype.CLOCK`.**/\n@unmanaged export class clocksubscription extends subscription {\n /** The user-defined unique identifier of the clock. */\n identifier: userdata;\n /** The clock against which to compare the timestamp. */\n clock_id: clockid;\n /** The absolute or relative timestamp. */\n timeout: timestamp;\n /** The amount of time that the implementation may wait additionally to coalesce with other events. */\n precision: timestamp;\n /** Flags specifying whether the timeout is absolute or relative. */\n flags: subclockflags;\n private __padding1: u32;\n}\n\n/* Subscription to an event of type `eventtype.FD_READ` or `eventtype.FD_WRITE`.**/\n@unmanaged export class fdsubscription extends subscription {\n /** The file descriptor on which to wait for it to become ready for reading or writing. */\n fd: fd;\n}\n\n/** Timestamp in nanoseconds. */\nexport type timestamp = u64;\n\n/** User-provided value that may be attached to objects that is retained when extracted from the implementation. */\nexport type userdata = u64;\n\n/** The position relative to which to set the offset of the file descriptor. */\nexport namespace whence {\n /** Seek relative to current position. */\n // @ts-ignore: decorator\n @inline\n export const CUR: whence = 0;\n /** Seek relative to end-of-file. */\n // @ts-ignore: decorator\n @inline\n export const END: whence = 1;\n /** Seek relative to start-of-file. */\n // @ts-ignore: decorator\n @inline\n export const SET: whence = 2;\n}\nexport type whence = u8;\n","bindings/wasi":'export * from "./wasi_unstable";\n',builtins:'// @ts-ignore: decorator\n@builtin @inline\nexport const NaN: f64 = 0 / 0;\n\n// @ts-ignore: decorator\n@builtin @inline\nexport const Infinity: f64 = 1 / 0;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isInteger(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFloat(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isBoolean(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isSigned(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isReference(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isString(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArray(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArrayLike(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFunction(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isNullable(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isDefined(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isConstant(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isManaged(value?: T): bool;\n\nexport function isNaN(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value != value;\n}\n\nexport function isFinite(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value - value == 0;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function clz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ctz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function popcnt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotl(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotr(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function abs(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function max(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function min(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ceil(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function floor(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function copysign(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function nearest(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function reinterpret(value: number): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sqrt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function trunc(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function load(offset: usize, immOffset?: usize, immAlign?: usize): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function store(offset: usize, value: void, immOffset?: usize, immAlign?: usize): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sizeof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function alignof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function offsetof(fieldName?: string): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function idof(): u32;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function unreachable(): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function changetype(value: void): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function assert(isTrueish: T, message?: string): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function unchecked(expr: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_indirect(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_direct(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function instantiate(...args: void[]): T;\n\nexport namespace atomic {\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: T, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n\n // @ts-ignore: decorator\n @builtin\n export declare function notify(ptr: usize, count: i32): i32;\n}\n\n// @ts-ignore: decorator\n@lazy\nexport const enum AtomicWaitResult {\n OK = 0,\n NOT_EQUAL = 1,\n TIMED_OUT = 2\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8(value: void): i8;\n\nexport namespace i8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i8 = -128;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i8 = 127;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16(value: void): i16;\n\nexport namespace i16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i16 = -32768;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i16 = 32767;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32(value: void): i32;\n\nexport namespace i32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i32 = -2147483648;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i32 = 2147483647;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f32(value: f32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64(value: void): i64;\n\nexport namespace i64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i64 = -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i64 = 9223372036854775807;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f64(value: f64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw32 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isize(value: void): isize;\n\nexport namespace isize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: isize = sizeof() == sizeof()\n ? -2147483648\n : -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: isize = sizeof() == sizeof()\n ? 2147483647\n : 9223372036854775807;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u8(value: void): u8;\n\nexport namespace u8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u8 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u8 = 255;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u16(value: void): u16;\n\nexport namespace u16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u16 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u16 = 65535;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u32(value: void): u32;\n\nexport namespace u32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u32 = 4294967295;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u64(value: void): u64;\n\nexport namespace u64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u64 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u64 = 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function usize(value: void): usize;\n\nexport namespace usize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: usize = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: usize = sizeof() == sizeof()\n ? 4294967295\n : 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function bool(value: void): bool;\n\nexport namespace bool {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: bool = false;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: bool = true;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32(value: void): f32;\n\nexport namespace f32 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x34000000); // 0x1p-23f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x00000001); // 0x0.000001p+0f\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7F7FFFFF); // 0x1.fffffep+127f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x00800000); // 0x1p-126f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f32 = -16777215;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f32 = 16777215;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f32, y: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i32(value: i32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f32): f32;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64(value: void): f64;\n\nexport namespace f64 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x3CB0000000000000); // 0x1p-52\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x0000000000000001); // 0x0.0000000000001p+0\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7FEFFFFFFFFFFFFF); // 0x1.fffffffffffffp+1023\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x0010000000000000); // 0x1p-1022\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f64 = -9007199254740991;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f64 = 9007199254740991;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f64, y: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i64(value: i64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f64): f64;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function v128(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace v128 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128; // except i64\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function not(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function bitselect(v1: v128, v2: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8x16(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace i8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\n\nexport namespace i16x8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\n\nexport namespace i32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f32x4_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f32x4_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64x2(a: i64, b: i64): v128;\n\nexport namespace i64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f64x2_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f64x2_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\n\nexport namespace f32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i32x4(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i32x4(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64x2(a: f64, b: f64): v128;\n\nexport namespace f64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i64x2(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i64x2(a: v128): v128;\n}\n\nexport namespace v8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(\n a: v128, b: v128,\n l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8,\n l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8\n ): v128;\n}\n\n// @ts-ignore: decorator\n@external("env", "abort")\ndeclare function abort(\n message?: string | null,\n fileName?: string | null,\n lineNumber?: u32,\n columnNumber?: u32\n): void;\n\n// @ts-ignore: decorator\n@external("env", "trace")\ndeclare function trace(\n message: string,\n n?: i32,\n a0?: f64,\n a1?: f64,\n a2?: f64,\n a3?: f64,\n a4?: f64\n): void;\n',dataview:'import { BLOCK_MAXSIZE } from "./rt/common";\nimport { ArrayBuffer } from "./arraybuffer";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH } from "./util/error";\n\n// TODO: there is probably a smarter way to check byteOffset for accesses larger than 1 byte\n\nexport class DataView {\n\n private data: ArrayBuffer;\n private dataStart: usize;\n private dataLength: i32;\n\n constructor(\n buffer: ArrayBuffer,\n byteOffset: i32 = 0,\n byteLength: i32 = buffer.byteLength\n ) {\n if (\n i32(byteLength > BLOCK_MAXSIZE) |\n i32(byteOffset + byteLength > buffer.byteLength)\n ) throw new RangeError(E_INVALIDLENGTH);\n this.data = buffer; // retains\n var dataStart = changetype(buffer) + byteOffset;\n this.dataStart = dataStart;\n this.dataLength = byteLength;\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getInt8(byteOffset: i32): i8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getInt32(byteOffset: i32, littleEndian: boolean = false): i32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint8(byteOffset: i32): u8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint32(byteOffset: i32, littleEndian: boolean = false): u32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setInt8(byteOffset: i32, value: i8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint8(byteOffset: i32, value: u8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n // Non-standard additions that make sense in WebAssembly, but won\'t work in JS:\n\n getInt64(byteOffset: i32, littleEndian: boolean = false): i64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i64 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint64(byteOffset: i32, littleEndian: boolean = false): u64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n toString(): string {\n return "[object DataView]";\n }\n}\n',date:'import {\n UTC as Date_UTC,\n now as Date_now\n} from "./bindings/Date";\n\nexport class Date {\n\n @inline static UTC(\n year: i32,\n month: i32 = 0,\n day: i32 = 1,\n hour: i32 = 0,\n minute: i32 = 0,\n second: i32 = 0,\n millisecond: i64 = 0\n ): i64 {\n return Date_UTC(year, month, day, hour, minute, second, millisecond);\n }\n\n @inline static now(): i64 {\n return Date_now();\n }\n\n private value: i64;\n\n constructor(value: i64) {\n this.value = value;\n }\n\n getTime(): i64 {\n return this.value;\n }\n\n setTime(value: i64): i64 {\n this.value = value;\n return value;\n }\n}\n',diagnostics:"// @ts-ignore: decorator\n@builtin\nexport declare function ERROR(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function WARNING(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function INFO(message?: string): void;\n",error:'export class Error {\n\n name: string = "Error";\n stack: string = ""; // TODO\n\n constructor(\n public message: string = ""\n ) {}\n\n toString(): string {\n var message = this.message;\n return message.length\n ? this.name + ": " + message\n : this.name;\n }\n}\n\nexport class RangeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "RangeError";\n }\n}\n\nexport class TypeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "TypeError";\n }\n}\n\nexport class SyntaxError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "SyntaxError";\n }\n}\n',fixedarray:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_HOLEYARRAY } from "./util/error";\n\n// NOTE: DO NOT USE YET!\n\n// TODO: FixedArray with S being the static size, i.e. `new FixedArray`.\n// Then hard-wire this special type to the compiler and do static length checks instead :)\n\nexport class FixedArray {\n [key: number]: T;\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n var outSize = length << alignof();\n var out = __alloc(outSize, idof>());\n memory.fill(out, 0, outSize);\n return changetype>(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >>> alignof();\n }\n\n @operator("[]") private __get(index: i32): T {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n this.__unchecked_set(index, value);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(changetype(this) + (index << alignof()));\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = changetype(this) + (index << alignof());\n let oldValue = load(offset);\n if (changetype(value) != oldValue) {\n store(offset, __retain(changetype(value)));\n __release(changetype(oldValue));\n }\n } else {\n store(changetype(this) + (index << alignof()), value);\n }\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = changetype(this);\n let end = cur + changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n }\n}\n',heap:"// @ts-ignore: decorator\n@builtin\nexport declare const HEAP_BASE: usize;\n",iterator:"export abstract class Iterable {\n // ?\n}\n\n@sealed\nexport abstract class Iterator {\n\n // private constructor(iterable: Iterable) {\n // }\n\n // TODO: these need to evaluate the classId at the respective reference in order to obtain the\n // next value, i.e. arrays work differently than maps. we'd then have:\n //\n // ╒═══════════════════ Iterator layout (32-bit) ══════════════════╕\n // 3 2 1\n // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n // ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n // │ index │\n // ├─────────────────────────────────────────────────────────┬───┬─┤\n // │ reference │ 0 │D│\n // └─────────────────────────────────────────────────────────┴───┴─┘\n // D: Done flag\n\n // get value(this: u64): T {\n // ?\n // }\n\n // next(this: u64): Iterator {\n // ?\n // }\n\n done(this: u64): bool {\n return (this & 1);\n }\n}\n",map:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash map based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a map entry. */\n@unmanaged class MapEntry {\n key: K;\n value: V;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K/V is <= 32-bits\n const maxkv = sizeof() > sizeof() ? sizeof() : sizeof();\n const align = (maxkv > sizeof() ? maxkv : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Map {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // MapEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() {\n this.clear();\n }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): MapEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n get(key: K): V {\n var entry = this.find(key, HASH(key));\n return entry ? entry.value : unreachable();\n }\n\n set(key: K, value: V): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (entry) {\n if (isManaged()) {\n let oldRef = changetype(entry.value);\n if (changetype(value) != oldRef) {\n entry.value = changetype(__retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n entry.value = value;\n }\n } else {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n let entries = this.entries;\n entry = changetype>(changetype(entries) + this.entriesOffset++ * ENTRY_SIZE());\n // link with the map\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n entry.value = isManaged()\n ? changetype(__retain(changetype(value)))\n : value;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key));\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key));\n if (isManaged()) __release(changetype(entry.value));\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr);\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr);\n newEntry.key = oldEntry.key;\n newEntry.value = oldEntry.value;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Map]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged() || isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n if (isManaged()) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n if (isManaged()) {\n let val = changetype(entry.value);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',math:'import * as JSMath from "./bindings/Math";\nexport { JSMath };\n\nimport {\n abs as builtin_abs,\n ceil as builtin_ceil,\n clz as builtin_clz,\n copysign as builtin_copysign,\n floor as builtin_floor,\n max as builtin_max,\n min as builtin_min,\n sqrt as builtin_sqrt,\n trunc as builtin_trunc\n} from "./builtins";\n\n// SUN COPYRIGHT NOTICE\n//\n// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n// Developed at SunPro, a Sun Microsystems, Inc. business.\n// Permission to use, copy, modify, and distribute this software\n// is freely granted, provided that this notice is preserved.\n//\n// Applies to all functions marked with a comment referring here.\n\n// TODO: sin, cos, tan for Math namespace\n\n/** @internal */\nfunction R(z: f64): f64 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3FC5555555555555), // 1.66666666666666657415e-01\n pS1 = reinterpret(0xBFD4D61203EB6F7D), // -3.25565818622400915405e-01\n pS2 = reinterpret(0x3FC9C1550E884455), // 2.01212532134862925881e-01\n pS3 = reinterpret(0xBFA48228B5688F3B), // -4.00555345006794114027e-02\n pS4 = reinterpret(0x3F49EFE07501B288), // 7.91534994289814532176e-04\n pS5 = reinterpret(0x3F023DE10DFDF709), // 3.47933107596021167570e-05\n qS1 = reinterpret(0xC0033A271C8A2D4B), // -2.40339491173441421878e+00\n qS2 = reinterpret(0x40002AE59C598AC8), // 2.02094576023350569471e+00\n qS3 = reinterpret(0xBFE6066C1B8D0159), // -6.88283971605453293030e-01\n qS4 = reinterpret(0x3FB3B8C5B12E9282); // 7.70381505559019352791e-02\n var p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n var q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2.c\n k = 2043,\n kln2 = reinterpret(0x40962066151ADD8B); // 0x1.62066151add8bp+10\n var scale = reinterpret(((0x3FF + k / 2) << 20) << 32);\n return NativeMath.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@lazy\nvar random_seeded = false;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_32: u32;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_32: u32;\n\nfunction murmurHash3(h: u64): u64 { // Force all bits of a hash block to avalanche\n h ^= h >> 33; // see: https://github.com/aappleby/smhasher\n h *= 0xFF51AFD7ED558CCD;\n h ^= h >> 33;\n h *= 0xC4CEB9FE1A85EC53;\n h ^= h >> 33;\n return h;\n}\n\nfunction splitMix32(h: u32): u32 {\n h += 0x6D2B79F5;\n h = (h ^ (h >> 15)) * (h | 1);\n h ^= h + (h ^ (h >> 7)) * (h | 61);\n return h ^ (h >> 14);\n}\n\nexport namespace NativeMath {\n\n // @ts-ignore: decorator\n @lazy\n export const E = reinterpret(0x4005BF0A8B145769); // 2.7182818284590452354\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = reinterpret(0x3FE62E42FEFA39EF); // 0.69314718055994530942\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = reinterpret(0x40026BB1BBB55516); // 2.30258509299404568402\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = reinterpret(0x3FF71547652B82FE); // 1.4426950408889634074\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = reinterpret(0x3FDBCB7B1526E50E); // 0.43429448190325182765\n\n // @ts-ignore: decorator\n @lazy\n export const PI = reinterpret(0x400921FB54442D18); // 3.14159265358979323846\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = reinterpret(0x3FE6A09E667F3BCD); // 0.70710678118654752440\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = reinterpret(0x3FF6A09E667F3BCD); // 1.41421356237309504880\n\n // @ts-ignore: decorator\n @inline export function abs(x: f64): f64 {\n return builtin_abs(x);\n }\n\n export function acos(x: f64): f64 { // see: musl/src/math/acos.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix <= 0x3C600000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * R(x * x)));\n }\n var s: f64, w: f64, z: f64;\n if (hx >> 31) {\n // z = (1.0 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = R(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1.0 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n var df = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n var c = (z - df * df) / (s + df);\n w = R(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f64): f64 { // see: musl/src/math/acosh.c\n const s = reinterpret(0x3FE62E42FEFA39EF);\n var e = reinterpret(x) >> 52 & 0x7FF;\n if (e < 0x3FF + 1) return log1p(x - 1 + builtin_sqrt((x - 1) * (x - 1) + 2 * (x - 1)));\n if (e < 0x3FF + 26) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f64): f64 { // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) return x * pio2_hi + Ox1p_120f;\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix < 0x3E500000 && ix >= 0x00100000) return x;\n return x + x * R(x * x);\n }\n // var z = (1.0 - builtin_abs(x)) * 0.5;\n var z = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z);\n var r = R(z);\n if (ix >= 0x3FEF3333) x = pio2_hi - (2 * (s + s * r) - pio2_lo);\n else {\n let f = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n let c = (z - f * f) / (s + f);\n x = 0.5 * pio2_hi - (2 * s * r - (pio2_lo - 2 * c) - (0.5 * pio2_hi - 2 * f));\n }\n if (hx >> 31) return -x;\n return x;\n }\n\n export function asinh(x: f64): f64 { // see: musl/src/math/asinh.c\n const c = reinterpret(0x3FE62E42FEFA39EF); // 0.693147180559945309417232121458176568\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var y = reinterpret(u & 0x7FFFFFFFFFFFFFFF);\n if (e >= 0x3FF + 26) y = log(y) + c;\n else if (e >= 0x3FF + 1) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (e >= 0x3FF - 26) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f64): f64 { // see musl/src/math/atan.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3FDDAC670561BB4F), // 4.63647609000806093515e-01\n atanhi1 = reinterpret(0x3FE921FB54442D18), // 7.85398163397448278999e-01\n atanhi2 = reinterpret(0x3FEF730BD281F69B), // 9.82793723247329054082e-01\n atanhi3 = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n atanlo0 = reinterpret(0x3C7A2B7F222F65E2), // 2.26987774529616870924e-17\n atanlo1 = reinterpret(0x3C81A62633145C07), // 3.06161699786838301793e-17\n atanlo2 = reinterpret(0x3C7007887AF0CBBD), // 1.39033110312309984516e-17\n atanlo3 = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n aT0 = reinterpret(0x3FD555555555550D), // 3.33333333333329318027e-01\n aT1 = reinterpret(0xBFC999999998EBC4), // -1.99999999998764832476e-01\n aT2 = reinterpret(0x3FC24924920083FF), // 1.42857142725034663711e-01\n aT3 = reinterpret(0xBFBC71C6FE231671), // -1.11111104054623557880e-01,\n aT4 = reinterpret(0x3FB745CDC54C206E), // 9.09088713343650656196e-02\n aT5 = reinterpret(0xBFB3B0F2AF749A6D), // -7.69187620504482999495e-02\n aT6 = reinterpret(0x3FB10D66A0D03D51), // 6.66107313738753120669e-02\n aT7 = reinterpret(0xBFADDE2D52DEFD9A), // -5.83357013379057348645e-02\n aT8 = reinterpret(0x3FA97B4B24760DEB), // 4.97687799461593236017e-02\n aT9 = reinterpret(0xBFA2B4442C6A6C2F), // -3.65315727442169155270e-02\n aT10 = reinterpret(0x3F90AD3AE322DA11), // 1.62858201153657823623e-02\n Ox1p_120f = reinterpret(0x03800000);\n var ix = (reinterpret(x) >> 32);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f64;\n if (ix >= 0x44100000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3FDC0000) {\n if (ix < 0x3E400000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3FF30000) {\n if (ix < 0x3FE60000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x40038000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * (aT4 + w * (aT6 + w * (aT8 + w * aT10)))));\n var s2 = w * (aT1 + w * (aT3 + w * (aT5 + w * (aT7 + w * aT9))));\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f64): f64 { // see: musl/src/math/atanh.c\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var s = u >> 63;\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n if (e < 0x3FF - 1) {\n if (e >= 0x3FF - 32) y = 0.5 * log1p(2 * y + 2 * y * y / (1 - y));\n } else {\n y = 0.5 * log1p(2 * (y / (1 - y)));\n }\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f64, x: f64): f64 { // see: musl/src/math/atan2.c and SUN COPYRIGHT NOTICE above\n const pi_lo = reinterpret(0x3CA1A62633145C07); // 1.2246467991473531772E-16\n if (isNaN(x) || isNaN(y)) return x + y;\n var u = reinterpret(x);\n var ix = (u >> 32);\n var lx = u;\n u = reinterpret(y);\n var iy = (u >> 32);\n var ly = u;\n if ((ix - 0x3FF00000 | lx) == 0) return atan(y);\n var m = ((iy >> 31) & 1) | ((ix >> 30) & 2);\n ix = ix & 0x7FFFFFFF;\n iy = iy & 0x7FFFFFFF;\n if ((iy | ly) == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n if ((ix | lx) == 0) return m & 1 ? -PI / 2 : PI / 2;\n if (ix == 0x7FF00000) {\n if (iy == 0x7FF00000) {\n switch (m) {\n case 0: return PI / 4;\n case 1: return -PI / 4;\n case 2: return 3 * PI / 4;\n case 3: return -3 * PI / 4;\n }\n } else {\n switch (m) {\n case 0: return 0.0;\n case 1: return -0.0;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n }\n var z: f64;\n if (ix + (64 << 20) < iy || iy == 0x7FF00000) return m & 1 ? -PI / 2 : PI / 2;\n if ((m & 2) && iy + (64 << 20) < ix) z = 0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return PI - (z - pi_lo);\n case 3: return (z - pi_lo) - PI;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f64): f64 { // see: musl/src/math/cbrt.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 715094163,\n B2 = 696219795,\n P0 = reinterpret(0x3FFE03E60F61E692), // 1.87595182427177009643\n P1 = reinterpret(0xBFFE28E092F02420), // -1.88497979543377169875\n P2 = reinterpret(0x3FF9F1604A49D6C2), // 1.621429720105354466140\n P3 = reinterpret(0xBFE844CBBEE751D9), // -0.758397934778766047437\n P4 = reinterpret(0x3FC2B000D4E4EDD7), // 0.145996192886612446982\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32) & 0x7FFFFFFF;\n if (hx >= 0x7FF00000) return x + x;\n if (hx < 0x00100000) {\n u = reinterpret(x * Ox1p54);\n hx = (u >> 32) & 0x7FFFFFFF;\n if (hx == 0) return x;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 1 << 63;\n u |= hx << 32;\n var t = reinterpret(u);\n var r = (t * t) * (t / x);\n t = t * ((P0 + r * (P1 + r * P2)) + ((r * r) * r) * (P3 + r * P4));\n t = reinterpret((reinterpret(t) + 0x80000000) & 0xFFFFFFFFC0000000);\n var s = t * t;\n r = x / s;\n r = (r - t) / (2 * t + r);\n t = t + t * r;\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f64): f64 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f64): f64 {\n if (!isFinite(x)) return 32;\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function cosh(x: f64): f64 { // see: musl/src/math/cosh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n x = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w < 0x3FE62E42) {\n if (w < 0x3FF00000 - (26 << 20)) return 1;\n t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (w < 0x40862E42) {\n t = exp(x);\n return 0.5 * (t + 1 / t);\n }\n t = expo2(x);\n return t;\n }\n\n export function exp(x: f64): f64 { // see: musl/src/math/exp.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n overflow = reinterpret(0x40862E42FEFA39EF), // 709.782712893383973096\n underflow = reinterpret(0xC0874910D52D3051), // -745.13321910194110842\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var hx = (reinterpret(x) >> 32);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x4086232B) {\n if (isNaN(x)) return x;\n if (x > overflow) return x * Ox1p1023;\n if (x < underflow) return 0;\n }\n var hi: f64, lo: f64 = 0;\n var k = 0;\n if (hx > 0x3FD62E42) {\n if (hx >= 0x3FF0A2B2) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x3E300000) {\n hi = x;\n } else return 1.0 + x;\n var xs = x * x;\n // var c = x - xp2 * (P1 + xp2 * (P2 + xp2 * (P3 + xp2 * (P4 + xp2 * P5))));\n var xq = xs * xs;\n var c = x - (xs * P1 + xq * ((P2 + xs * P3) + xq * (P4 + xs * P5)));\n var y = 1.0 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f64): f64 { // see: musl/src/math/expm1.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x40862E42FEFA39EF), // 7.09782712893383973096e+02\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n Q1 = reinterpret(0xBFA11111111110F4), // -3.33333333333331316428e-02\n Q2 = reinterpret(0x3F5A01A019FE5585), // 1.58730158725481460165e-03\n Q3 = reinterpret(0xBF14CE199EAADBB7), // -7.93650757867487942473e-05\n Q4 = reinterpret(0x3ED0CFCA86E65239), // 4.00821782732936239552e-06\n Q5 = reinterpret(0xBE8AFDB76E09C32D), // -2.01099218183624371326e-07\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32 & 0x7FFFFFFF);\n var k = 0, sign_ = (u >> 63);\n if (hx >= 0x4043687A) {\n if (isNaN(x)) return x;\n if (sign_) return -1;\n if (x > o_threshold) return x * Ox1p1023;\n }\n var c = 0.0, t: f64;\n if (hx > 0x3FD62E42) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3FF0A2B2\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x3C900000) return x;\n var hfx = 0.5 * x;\n var hxs = x * hfx;\n // var r1 = 1.0 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));\n var hxq = hxs * hxs;\n var r1 = (1.0 + hxs * Q1) + hxq * ((Q2 + hxs * Q3) + hxq * (Q4 + hxs * Q5));\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x3FF + k) << 52;\n var twopk = reinterpret(u);\n var y: f64;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 1024) y = y * 2.0 * Ox1p1023;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x3FF - k) << 52;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f64): f64 {\n return builtin_floor(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f64): f32 {\n return x;\n }\n\n export function hypot(x: f64, y: f64): f64 { // see: musl/src/math/hypot.c\n const\n SPLIT = reinterpret(0x41A0000000000000) + 1, // 0x1p27 + 1\n Ox1p700 = reinterpret(0x6BB0000000000000),\n Ox1p_700 = reinterpret(0x1430000000000000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFFFFFFFFFF;\n uy &= 0x7FFFFFFFFFFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n var ex = (ux >> 52);\n var ey = (uy >> 52);\n y = reinterpret(uy);\n if (ey == 0x7FF) return y;\n x = reinterpret(ux);\n if (ex == 0x7FF || uy == 0) return x;\n if (ex - ey > 64) return x + y;\n var z = 1.0;\n if (ex > 0x3FF + 510) {\n z = Ox1p700;\n x *= Ox1p_700;\n y *= Ox1p_700;\n } else if (ey < 0x3FF - 450) {\n z = Ox1p_700;\n x *= Ox1p700;\n y *= Ox1p700;\n }\n var c = x * SPLIT;\n var h = x - c + c;\n var l = x - h;\n var hx = x * x;\n var lx = h * h - hx + (2 * h + l) * l;\n c = y * SPLIT;\n h = y - c + c;\n l = y - h;\n var hy = y * y;\n var ly = h * h - hy + (2 * h + l) * l;\n return z * builtin_sqrt(ly + lx + hy + hx);\n }\n\n export function imul(x: f64, y: f64): f64 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f64): f64 { // see: musl/src/math/log.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f64): f64 { // see: musl/src/math/log10.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3FDBCB7B15200000), // 4.34294481878168880939e-01\n ivln10lo = reinterpret(0x3DBB9438CA9AADD5), // 2.50829467116452752298e-11\n log10_2hi = reinterpret(0x3FD34413509F6000), // 3.01029995663611771306e-01\n log10_2lo = reinterpret(0x3D59FEF311F12B36), // 3.69423907715893078616e-13\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln10hi;\n var dk = k;\n var y = dk * log10_2hi;\n var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n return val_lo + w;\n }\n\n export function log1p(x: f64): f64 { // see: musl/src/math/log1p.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244); // 1.479819860511658591e-01\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 1;\n var c = 0.0, f = 0.0;\n if (hx < 0x3FDA827A || (hx >> 31)) {\n if (hx >= 0xBFF00000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (hx << 1 < 0x3CA00000 << 1) return x;\n if (hx <= 0xBFD2BEC4) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (hx >= 0x7FF00000) return x;\n if (k) {\n u = reinterpret(1 + x);\n let hu = (u >> 32);\n hu += 0x3FF00000 - 0x3FE6A09E;\n k = (hu >> 20) - 0x3FF;\n if (k < 54) {\n let uf = reinterpret(u);\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n hu = (hu & 0x000FFFFF) + 0x3FE6A09E;\n u = hu << 32 | (u & 0xFFFFFFFF);\n f = reinterpret(u) - 1;\n }\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f64): f64 { // see: musl/src/math/log2.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FF7154765200000), // 1.44269504072144627571e+00\n ivln2lo = reinterpret(0x3DE705FC2EEFA200), // 1.67517131648865118353e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln2hi;\n var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;\n var y = k;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n val_hi = w;\n return val_lo + val_hi;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f64, value2: f64): f64 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f64, value2: f64): f64 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f64, y: f64): f64 { // see: musl/src/math/pow.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3FE2B80340000000), // 5.84962487220764160156e-01\n dp_l1 = reinterpret(0x3E4CFDEB43CFD006), // 1.35003920212974897128e-08\n two53 = reinterpret(0x4340000000000000), // 9007199254740992.0\n huge = reinterpret(0x7E37E43C8800759C), // 1e+300\n tiny = reinterpret(0x01A56E1FC2F8F359), // 1e-300\n L1 = reinterpret(0x3FE3333333333303), // 5.99999999999994648725e-01\n L2 = reinterpret(0x3FDB6DB6DB6FABFF), // 4.28571428578550184252e-01\n L3 = reinterpret(0x3FD55555518F264D), // 3.33333329818377432918e-01\n L4 = reinterpret(0x3FD17460A91D4101), // 2.72728123808534006489e-01\n L5 = reinterpret(0x3FCD864A93C9DB65), // 2.30660745775561754067e-01\n L6 = reinterpret(0x3FCA7E284A454EEF), // 2.06975017800338417784e-01\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n lg2 = reinterpret(0x3FE62E42FEFA39EF), // 6.93147180559945286227e-01\n lg2_h = reinterpret(0x3FE62E4300000000), // 6.93147182464599609375e-01\n lg2_l = reinterpret(0xBE205C610CA86C39), // -1.90465429995776804525e-09\n ovt = reinterpret(0x3C971547652B82FE), // 8.0085662595372944372e-017\n cp = reinterpret(0x3FEEC709DC3A03FD), // 9.61796693925975554329e-01\n cp_h = reinterpret(0x3FEEC709E0000000), // 9.61796700954437255859e-01\n cp_l = reinterpret(0xBE3E2FE0145B01F5), // -7.02846165095275826516e-09\n ivln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n ivln2_h = reinterpret(0x3FF7154760000000), // 1.44269502162933349609e+00\n ivln2_l = reinterpret(0x3E54AE0BF85DDF44), // 1.92596299112661746887e-08\n inv3 = reinterpret(0x3FD5555555555555); // 0.3333333333333333333333\n var u_ = reinterpret(x);\n var hx = (u_ >> 32);\n var lx = u_;\n u_ = reinterpret(y);\n var hy = (u_ >> 32);\n var ly = u_;\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if ((iy | ly) == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3FF00000 && lx == 0) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if ( // NaN if either arg is NaN\n ix > 0x7FF00000 || (ix == 0x7FF00000 && lx != 0) ||\n iy > 0x7FF00000 || (iy == 0x7FF00000 && ly != 0)\n ) return x + y;\n var yisint = 0, k: i32;\n if (hx < 0) {\n if (iy >= 0x43400000) yisint = 2;\n else if (iy >= 0x3FF00000) {\n k = (iy >> 20) - 0x3FF;\n let kcond = k > 20;\n let offset = select(52, 20, kcond) - k;\n let Ly = select(ly, iy, kcond);\n let jj = Ly >> offset;\n if ((jj << offset) == Ly) yisint = 2 - (jj & 1);\n }\n }\n if (ly == 0) {\n if (iy == 0x7FF00000) { // y is +-inf\n if (((ix - 0x3FF00000) | lx) == 0) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix >= 0x3FF00000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3FF00000) {\n if (hy >= 0) return x;\n return 1 / x;\n }\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3FE00000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n }\n var ax = builtin_abs(x), z: f64;\n if (lx == 0) {\n if (ix == 0 || ix == 0x7FF00000 || ix == 0x3FF00000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3FF00000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n } else if (yisint == 1) z = -z;\n }\n return z;\n }\n }\n var s = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) s = -1.0;\n }\n var t1: f64, t2: f64, p_h: f64, p_l: f64, r: f64, t: f64, u: f64, v: f64, w: f64;\n var j: i32, n: i32;\n if (iy > 0x41E00000) {\n if (iy > 0x43F00000) {\n if (ix <= 0x3FEFFFFF) return hy < 0 ? huge * huge : tiny * tiny;\n if (ix >= 0x3FF00000) return hy > 0 ? huge * huge : tiny * tiny;\n }\n if (ix < 0x3FEFFFFF) return hy < 0 ? s * huge * huge : s * tiny * tiny;\n if (ix > 0x3FF00000) return hy > 0 ? s * huge * huge : s * tiny * tiny;\n t = ax - 1.0;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = v - (t1 - u);\n } else {\n let ss: f64, s2: f64, s_h: f64, s_l: f64, t_h: f64, t_l: f64;\n n = 0;\n if (ix < 0x00100000) {\n ax *= two53;\n n -= 53;\n ix = (reinterpret(ax) >> 32);\n }\n n += (ix >> 20) - 0x3FF;\n j = ix & 0x000FFFFF;\n ix = j | 0x3FF00000;\n if (j <= 0x3988E) k = 0;\n else if (j < 0xBB67A) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00100000;\n }\n ax = reinterpret(reinterpret(ax) & 0xFFFFFFFF | (ix << 32));\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n ss = u * v;\n s_h = ss;\n s_h = reinterpret(reinterpret(s_h) & 0xFFFFFFFF00000000);\n t_h = reinterpret((((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18)) << 32);\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = ss * ss;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + ss);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n t_h = reinterpret(reinterpret(t_h) & 0xFFFFFFFF00000000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * ss;\n p_h = u + v;\n p_h = reinterpret(reinterpret(p_h) & 0xFFFFFFFF00000000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = ((z_h + z_l) + dp_h) + t;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n var y1 = y;\n y1 = reinterpret(reinterpret(y1) & 0xFFFFFFFF00000000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n u_ = reinterpret(z);\n j = (u_ >> 32);\n var i = u_;\n if (j >= 0x40900000) {\n if (((j - 0x40900000) | i) != 0) return s * huge * huge;\n if (p_l + ovt > z - p_h) return s * huge * huge;\n } else if ((j & 0x7FFFFFFF) >= 0x4090CC00) {\n if (((j - 0xC090CC00) | i) != 0) return s * tiny * tiny;\n if (p_l <= z - p_h) return s * tiny * tiny;\n }\n i = j & 0x7FFFFFFF;\n k = (i >> 20) - 0x3FF;\n n = 0;\n if (i > 0x3FE00000) {\n n = j + (0x00100000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 20) - 0x3FF;\n t = 0.0;\n t = reinterpret((n & ~(0x000FFFFF >> k)) << 32);\n n = ((n & 0x000FFFFF) | 0x00100000) >> (20 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n t = reinterpret(reinterpret(t) & 0xFFFFFFFF00000000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = (reinterpret(z) >> 32);\n j += n << 20;\n if ((j >> 20) <= 0) z = scalbn(z, n);\n else z = reinterpret(reinterpret(z) & 0xFFFFFFFF | (j << 32));\n return s * z;\n }\n\n export function seedRandom(value: i64): void {\n assert(value);\n random_seeded = true;\n random_state0_64 = murmurHash3(value);\n random_state1_64 = murmurHash3(~random_state0_64);\n random_state0_32 = splitMix32(value);\n random_state1_32 = splitMix32(random_state0_32);\n }\n\n export function random(): f64 { // see: v8/src/base/random-number-generator.cc\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n var s1 = random_state0_64;\n var s0 = random_state1_64;\n random_state0_64 = s0;\n s1 ^= s1 << 23;\n s1 ^= s1 >> 17;\n s1 ^= s0;\n s1 ^= s0 >> 26;\n random_state1_64 = s1;\n var r = ((s0 + s1) & 0x000FFFFFFFFFFFFF) | 0x3FF0000000000000;\n return reinterpret(r) - 1;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f64): f64 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f64): f64 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f64): bool {\n // In ECMAScript all NaN values are indistinguishable from each other\n // so we need handle NaN and negative NaN in similar way\n return ((reinterpret(x) >>> 63) & i32(x == x));\n }\n\n export function sin(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function sinh(x: f64): f64 { // see: musl/src/math/sinh.c\n var u = reinterpret(x) & 0x7FFFFFFFFFFFFFFF;\n var absx = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n var h = builtin_copysign(0.5, x);\n if (w < 0x40862E42) {\n t = expm1(absx);\n if (w < 0x3FF00000) {\n if (w < 0x3FF00000 - (26 << 20)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f64): f64 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function tanh(x: f64): f64 { // see: musl/src/math/tanh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w > 0x3FE193EA) {\n if (w > 0x40340000) {\n t = 1 - 0 / y;\n } else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (w > 0x3FD058AE) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (w >= 0x00100000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f64): f64 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f64, n: i32): f64 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbn.c\n const\n Ox1p53 = reinterpret(0x4340000000000000),\n Ox1p1023 = reinterpret(0x7FE0000000000000),\n Ox1p_1022 = reinterpret(0x0010000000000000);\n var y = x;\n if (n > 1023) {\n y *= Ox1p1023;\n n -= 1023;\n if (n > 1023) {\n y *= Ox1p1023;\n n = builtin_min(n - 1023, 1023);\n }\n } else if (n < -1022) {\n /* make sure final n < -53 to avoid double\n rounding in the subnormal range */\n y *= Ox1p_1022 * Ox1p53;\n n += 1022 - 53;\n if (n < -1022) {\n y *= Ox1p_1022 * Ox1p53;\n n = builtin_max(n + 1022 - 53, -1022);\n }\n }\n return y * reinterpret((0x3FF + n) << 52);\n }\n\n export function mod(x: f64, y: f64): f64 { // see: musl/src/math/fmod.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = ux >> 63;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 12);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 12;\n ux |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 52); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 11);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 52;\n ux |= ex << 52;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx << 63;\n return reinterpret(ux);\n }\n\n export function rem(x: f64, y: f64): f64 { // see: musl/src/math/remquo.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = (ux >> 63);\n if (uy << 1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n if (ux << 1 == 0) return x;\n var uxi = ux;\n if (!ex) {\n ex -= builtin_clz(uxi << 12);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 12;\n uxi |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n var q: u32 = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -60;\n else {\n let shift = builtin_clz(uxi << 11);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end:\n if (ex > 0) {\n uxi -= 1 << 52;\n uxi |= ex << 52;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // ++q;\n }\n return sx ? -x : x;\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar rempio2f_y: f64;\n\n// @ts-ignore: decorator\n@lazy\nconst PIO2_TABLE: u64[] = [\n 0xA2F9836E4E441529,\n 0xFC2757D1F534DDC0,\n 0xDB6295993C439041,\n 0xFE5163ABDEBBC561\n];\n\nfunction Rf(z: f32): f32 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3E2AAA75), // 1.6666586697e-01f\n pS1 = reinterpret(0xBD2F13BA), // -4.2743422091e-02f\n pS2 = reinterpret(0xBC0DD36B), // -8.6563630030e-03f\n qS1 = reinterpret(0xBF34E5AE); // -7.0662963390e-01f\n var p = z * (pS0 + z * (pS1 + z * pS2));\n var q: f32 = 1 + z * qS1;\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2f.c\n k = 235,\n kln2 = reinterpret(0x4322E3BC); // 0x1.45c778p+7f\n var scale = reinterpret((0x7F + (k >> 1)) << 23);\n return NativeMathf.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction pio2_large_quot(x: f32, u: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const coeff = reinterpret(0x3BF921FB54442D18); // π * 0x1p-65 = 8.51530395021638647334e-20\n const bits = PIO2_TABLE;\n\n var offset = (u >> 23) - 152;\n var index = offset >> 6;\n var shift = offset & 63;\n\n var b0 = unchecked(bits[index + 0]);\n var b1 = unchecked(bits[index + 1]);\n var lo: u64;\n\n if (shift > 32) {\n let b2 = unchecked(bits[index + 2]);\n lo = b2 >> (96 - shift);\n lo |= b1 << (shift - 32);\n } else {\n lo = b1 >> (32 - shift);\n }\n\n var hi = (b1 >> (64 - shift)) | (b0 << shift);\n var mantissa: u64 = (u & 0x007FFFFF) | 0x00800000;\n var product: u64 = mantissa * hi + (mantissa * lo >> 32);\n var r: i64 = product << 2;\n var q: i32 = ((product >> 62) + (r >>> 63));\n rempio2f_y = copysign(coeff, x) * r;\n return q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction rempio2f(x: f32, u: u32, sign: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const pi2hi = reinterpret(0x3FF921FB50000000); // 1.57079631090164184570\n const pi2lo = reinterpret(0x3E5110B4611A6263); // 1.58932547735281966916e-8\n const _2_pi = reinterpret(0x3FE45F306DC9C883); // 0.63661977236758134308\n\n if (u < 0x4DC90FDB) { /* π * 0x1p28 */\n let q = nearest(x * _2_pi);\n rempio2f_y = x - q * pi2hi - q * pi2lo;\n return q;\n }\n\n var q = pio2_large_quot(x, u);\n return select(-q, q, sign);\n}\n\n/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */\n// @ts-ignore: decorator\n@inline\nfunction sin_kernf(x: f64): f32 { // see: musl/tree/src/math/__sindf.c\n const S1 = reinterpret(0xBFC5555554CBAC77); // -0x15555554cbac77.0p-55\n const S2 = reinterpret(0x3F811110896EFBB2); // 0x111110896efbb2.0p-59\n const S3 = reinterpret(0xBF2A00F9E2CAE774); // -0x1a00f9e2cae774.0p-65\n const S4 = reinterpret(0x3EC6CD878C3B46A7); // 0x16cd878c3b46a7.0p-71\n\n var z = x * x;\n var w = z * z;\n var r = S3 + z * S4;\n var s = z * x;\n return ((x + s * (S1 + z * S2)) + s * w * r);\n}\n\n/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */\n// @ts-ignore: decorator\n@inline\nfunction cos_kernf(x: f64): f32 { // see: musl/tree/src/math/__cosdf.c\n const C0 = reinterpret(0xBFDFFFFFFD0C5E81); // -0x1ffffffd0c5e81.0p-54\n const C1 = reinterpret(0x3FA55553E1053A42); // 0x155553e1053a42.0p-57\n const C2 = reinterpret(0xBF56C087E80F1E27); // -0x16c087e80f1e27.0p-62\n const C3 = reinterpret(0x3EF99342E0EE5069); // 0x199342e0ee5069.0p-68\n\n var z = x * x;\n var w = z * z;\n var r = C2 + z * C3;\n return (((1 + z * C0) + w * C1) + (w * z) * r);\n}\n\n/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */\n// @ts-ignore: decorator\n@inline\nfunction tan_kernf(x: f64, odd: i32): f32 { // see: musl/tree/src/math/__tandf.c\n\n const T0 = reinterpret(0x3FD5554D3418C99F); /* 0x15554d3418c99f.0p-54 */\n const T1 = reinterpret(0x3FC112FD38999F72); /* 0x1112fd38999f72.0p-55 */\n const T2 = reinterpret(0x3FAB54C91D865AFE); /* 0x1b54c91d865afe.0p-57 */\n const T3 = reinterpret(0x3F991DF3908C33CE); /* 0x191df3908c33ce.0p-58 */\n const T4 = reinterpret(0x3F685DADFCECF44E); /* 0x185dadfcecf44e.0p-61 */\n const T5 = reinterpret(0x3F8362B9BF971BCD); /* 0x1362b9bf971bcd.0p-59 */\n\n var z = x * x;\n var r = T4 + z * T5;\n var t = T2 + z * T3;\n var w = z * z;\n var s = z * x;\n var u = T0 + z * T1;\n\n r = (x + s * u) + (s * w) * (t + w * r);\n return (odd ? -1 / r : r);\n}\n\nexport namespace NativeMathf {\n\n // @ts-ignore: decorator\n @lazy\n export const E = NativeMath.E;\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = NativeMath.LN2;\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = NativeMath.LN10;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = NativeMath.LOG2E;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = NativeMath.LOG10E;\n\n // @ts-ignore: decorator\n @lazy\n export const PI = NativeMath.PI;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = NativeMath.SQRT1_2;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = NativeMath.SQRT2;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_sin: f32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_cos: f32 = 0;\n\n // @ts-ignore: decorator\n @inline\n export function abs(x: f32): f32 {\n return builtin_abs(x);\n }\n\n export function acos(x: f32): f32 { // see: musl/src/math/acosf.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n pio2_lo = reinterpret(0x33A22168), // 7.5497894159e-08f\n Ox1p_120f = reinterpret(0x03800000);\n var hx = reinterpret(x);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3F800000) {\n if (ix == 0x3F800000) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3F000000) {\n if (ix <= 0x32800000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * Rf(x * x)));\n }\n var z: f32, w: f32, s: f32;\n if (hx >> 31) {\n // z = (1 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = Rf(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n hx = reinterpret(s);\n var df = reinterpret(hx & 0xFFFFF000);\n var c = (z - df * df) / (s + df);\n w = Rf(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f32): f32 { // see: musl/src/math/acoshf.c\n const s = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x);\n var a = u & 0x7FFFFFFF;\n if (a < 0x3F800000 + (1 << 23)) {\n let xm1 = x - 1;\n return log1p(xm1 + builtin_sqrt(xm1 * (xm1 + 2)));\n }\n if (a < 0x3F800000 + (12 << 23)) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f32): f32 { // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n const\n pio2 = reinterpret(0x3FC90FDB), // 1.570796326794896558e+00f\n Ox1p_120f = reinterpret(0x03800000);\n var sx = x;\n var hx = reinterpret(x) & 0x7FFFFFFF;\n if (hx >= 0x3F800000) {\n if (hx == 0x3F800000) return x * pio2 + Ox1p_120f;\n return 0 / (x - x);\n }\n if (hx < 0x3F000000) {\n if (hx < 0x39800000 && hx >= 0x00800000) return x;\n return x + x * Rf(x * x);\n }\n // var z: f32 = (1 - builtin_abs(x)) * 0.5;\n var z: f32 = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z); // sic\n x = (pio2 - 2 * (s + s * Rf(z)));\n return builtin_copysign(x, sx);\n }\n\n export function asinh(x: f32): f32 { // see: musl/src/math/asinhf.c\n const c = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x) & 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u >= 0x3F800000 + (12 << 23)) y = log(y) + c;\n else if (u >= 0x3F800000 + (1 << 23)) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (u >= 0x3F800000 - (12 << 23)) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f32): f32 { // see: musl/src/math/atanf.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3EED6338), // 4.6364760399e-01f\n atanhi1 = reinterpret(0x3F490FDA), // 7.8539812565e-01f\n atanhi2 = reinterpret(0x3F7B985E), // 9.8279368877e-01f\n atanhi3 = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n atanlo0 = reinterpret(0x31AC3769), // 5.0121582440e-09f\n atanlo1 = reinterpret(0x33222168), // 3.7748947079e-08f\n atanlo2 = reinterpret(0x33140FB4), // 3.4473217170e-08f\n atanlo3 = reinterpret(0x33A22168), // 7.5497894159e-08f\n aT0 = reinterpret(0x3EAAAAA9), // 3.3333328366e-01f\n aT1 = reinterpret(0xBE4CCA98), // -1.9999158382e-01f\n aT2 = reinterpret(0x3E11F50D), // 1.4253635705e-01f\n aT3 = reinterpret(0xBDDA1247), // -1.0648017377e-01f\n aT4 = reinterpret(0x3D7CAC25), // 6.1687607318e-02f\n Ox1p_120f = reinterpret(0x03800000);\n var ix = reinterpret(x);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f32;\n if (ix >= 0x4C800000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3EE00000) {\n if (ix < 0x39800000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3F980000) {\n if (ix < 0x3F300000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x401C0000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * aT4));\n var s2 = w * (aT1 + w * aT3);\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f32): f32 { // see: musl/src/math/atanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u < 0x3F800000 - (1 << 23)) {\n if (u >= 0x3F800000 - (32 << 23)) y = 0.5 * log1p(2 * y * (1.0 + y / (1 - y)));\n } else y = 0.5 * log1p(2 * (y / (1 - y)));\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f32, x: f32): f32 { // see: musl/src/math/atan2f.c and SUN COPYRIGHT NOTICE above\n const\n pi = reinterpret(0x40490FDB), // 3.1415927410e+00f\n pi_lo = reinterpret(0xB3BBBD2E); // -8.7422776573e-08f\n if (isNaN(x) || isNaN(y)) return x + y;\n var ix = reinterpret(x);\n var iy = reinterpret(y);\n if (ix == 0x3F800000) return atan(y);\n var m = (((iy >> 31) & 1) | ((ix >> 30) & 2));\n ix &= 0x7FFFFFFF;\n iy &= 0x7FFFFFFF;\n if (iy == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n if (ix == 0) return m & 1 ? -pi / 2 : pi / 2;\n if (ix == 0x7F800000) {\n if (iy == 0x7F800000) {\n switch (m) {\n case 0: return pi / 4;\n case 1: return -pi / 4;\n case 2: return 3 * pi / 4;\n case 3: return -3 * pi / 4;\n }\n } else {\n switch (m) {\n case 0: return 0;\n case 1: return -0;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n }\n if (ix + (26 << 23) < iy || iy == 0x7F800000) return m & 1 ? -pi / 2 : pi / 2;\n var z: f32;\n if ((m & 2) && iy + (26 << 23) < ix) z = 0.0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return pi - (z - pi_lo);\n case 3: return (z - pi_lo) - pi;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f32): f32 { // see: musl/src/math/cbrtf.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 709958130,\n B2 = 642849266,\n Ox1p24f = reinterpret(0x4B800000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n if (hx >= 0x7F800000) return x + x;\n if (hx < 0x00800000) {\n if (hx == 0) return x;\n u = reinterpret(x * Ox1p24f);\n hx = u & 0x7FFFFFFF;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 0x80000000;\n u |= hx;\n var t = reinterpret(u);\n var r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f32): f32 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f32): f32 {\n if (!isFinite(x)) return 32;\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f32): f32 { // see: musl/src/math/cosf.c\n const c1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const c2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const c3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const c4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n /* raise inexact if x != 0 */\n return 1;\n }\n return cos_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix > 0x4016cbe3) { /* |x| ~> 3π/4 */\n return -cos_kernf(sign ? x + c2pio2 : x - c2pio2);\n } else {\n return sign ? sin_kernf(x + c1pio2) : sin_kernf(c1pio2 - x);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix > 0x40afeddf) { /* |x| ~> 7π/4 */\n return cos_kernf(sign ? x + c4pio2 : x - c4pio2);\n } else {\n return sign ? sin_kernf(-x - c3pio2) : sin_kernf(x - c3pio2);\n }\n }\n }\n\n /* cos(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? sin_kernf(y) : cos_kernf(y);\n return (n + 1) & 2 ? -t : t;\n }\n\n export function cosh(x: f32): f32 { // see: musl/src/math/coshf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n x = reinterpret(u);\n if (u < 0x3F317217) {\n if (u < 0x3F800000 - (12 << 23)) return 1;\n let t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (u < 0x42B17217) {\n let t = exp(x);\n // return 0.5 * (t + 1 / t);\n return 0.5 * t + 0.5 / t;\n }\n return expo2f(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f32): f32 {\n return builtin_floor(x);\n }\n\n export function exp(x: f32): f32 { // see: musl/src/math/expf.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3F317200), // 6.9314575195e-1f\n ln2lo = reinterpret(0x35BFBE8E), // 1.4286067653e-6f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+0f\n P1 = reinterpret(0x3E2AAA8F), // 1.6666625440e-1f\n P2 = reinterpret(0xBB355215), // -2.7667332906e-3f\n Ox1p127f = reinterpret(0x7F000000);\n var hx = reinterpret(x);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x42AEAC50) {\n if (hx >= 0x42B17218) {\n if (!sign_) return x * Ox1p127f;\n else if (hx >= 0x42CFF1B5) return 0;\n }\n }\n var hi: f32, lo: f32;\n var k: i32;\n if (hx > 0x3EB17218) {\n if (hx > 0x3F851592) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x39000000) {\n k = 0;\n hi = x;\n lo = 0;\n } else {\n return 1 + x;\n }\n var xx = x * x;\n var c = x - xx * (P1 + xx * P2);\n var y: f32 = 1 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f32): f32 { // see: musl/src/math/expm1f.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x42B17180), // 8.8721679688e+01f\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00f\n Q1 = reinterpret(0xBD088868), // -3.3333212137e-02f\n Q2 = reinterpret(0x3ACF3010), // 1.5807170421e-03f\n Ox1p127f = reinterpret(0x7F000000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n var sign_ = (u >> 31);\n if (hx >= 0x4195B844) {\n if (hx > 0x7F800000) return x;\n if (sign_) return -1;\n if (x > o_threshold) {\n x *= Ox1p127f;\n return x;\n }\n }\n var c: f32 = 0.0, t: f32, k: i32;\n if (hx > 0x3EB17218) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3F851592\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x33000000) {\n return x;\n } else k = 0;\n var hfx: f32 = 0.5 * x;\n var hxs: f32 = x * hfx;\n var r1: f32 = 1.0 + hxs * (Q1 + hxs * Q2);\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x7F + k) << 23;\n var twopk = reinterpret(u);\n var y: f32;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 128) y = y * 2.0 * Ox1p127f;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x7F - k) << 23;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f32): f32 {\n return x;\n }\n\n export function hypot(x: f32, y: f32): f32 { // see: musl/src/math/hypotf.c\n const\n Ox1p90f = reinterpret(0x6C800000),\n Ox1p_90f = reinterpret(0x12800000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFF;\n uy &= 0x7FFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n x = reinterpret(ux);\n y = reinterpret(uy);\n if (uy == 0xFF << 23) return y;\n if (ux >= 0xFF << 23 || uy == 0 || ux - uy >= 25 << 23) return x + y;\n var z: f32 = 1;\n if (ux >= (0x7F + 60) << 23) {\n z = Ox1p90f;\n x *= Ox1p_90f;\n y *= Ox1p_90f;\n } else if (uy < (0x7F - 60) << 23) {\n z = Ox1p_90f;\n x *= Ox1p90f;\n y *= Ox1p90f;\n }\n return z * builtin_sqrt((x * x + y * y));\n }\n\n // @ts-ignore: decorator\n @inline\n export function imul(x: f32, y: f32): f32 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f32): f32 { // see: musl/src/math/logf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f\n Ox1p25f = reinterpret(0x4C000000);\n var u = reinterpret(x);\n var k = 0;\n if (u < 0x00800000 || (u >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (u >> 31) return (x - x) / 0;\n k -= 25;\n x *= Ox1p25f;\n u = reinterpret(x);\n } else if (u >= 0x7F800000) return x;\n else if (u == 0x3F800000) return 0;\n u += 0x3F800000 - 0x3F3504F3;\n k += (u >> 23) - 0x7F;\n u = (u & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(u);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f32): f32 { // see: musl/src/math/log10f.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3EDE6000), // 4.3432617188e-01f\n ivln10lo = reinterpret(0xB804EAD9), // -3.1689971365e-05f\n log10_2hi = reinterpret(0x3E9A2080), // 3.0102920532e-01f\n log10_2lo = reinterpret(0x355427DB), // 7.9034151668e-07f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n ix = reinterpret(hi);\n ix &= 0xFFFFF000;\n hi = reinterpret(ix);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;\n }\n\n export function log1p(x: f32): f32 { // see: musl/src/math/log1pf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26); // 0xf89e26.0p-26f, 0.24279078841f\n var ix = reinterpret(x);\n var c: f32 = 0, f: f32 = 0;\n var k: i32 = 1;\n if (ix < 0x3ED413D0 || (ix >> 31)) {\n if (ix >= 0xBF800000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (ix << 1 < 0x33800000 << 1) return x;\n if (ix <= 0xBE95F619) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (ix >= 0x7F800000) return x;\n if (k) {\n let uf: f32 = 1 + x;\n let iu = reinterpret(uf);\n iu += 0x3F800000 - 0x3F3504F3;\n k = (iu >> 23) - 0x7F;\n if (k < 25) {\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n iu = (iu & 0x007FFFFF) + 0x3F3504F3;\n f = reinterpret(iu) - 1;\n }\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f32): f32 { // see: musl/src/math/log2f.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FB8B000), // 1.4428710938e+00f\n ivln2lo = reinterpret(0xB9389AD4), // -1.7605285393e-04\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k: i32 = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n var u = reinterpret(hi);\n u &= 0xFFFFF000;\n hi = reinterpret(u);\n var lo: f32 = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + dk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f32, value2: f32): f32 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f32, value2: f32): f32 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f32, y: f32): f32 { // see: musl/src/math/powf.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3F15C000), // 5.84960938e-01f\n dp_l1 = reinterpret(0x35D1CFDC), // 1.56322085e-06f\n two24 = reinterpret(0x4B800000), // 16777216f\n huge = reinterpret(0x7149F2CA), // 1.0e+30f\n tiny = reinterpret(0x0DA24260), // 1.0e-30f\n L1 = reinterpret(0x3F19999A), // 6.0000002384e-01f\n L2 = reinterpret(0x3EDB6DB7), // 4.2857143283e-01f\n L3 = reinterpret(0x3EAAAAAB), // 3.3333334327e-01f\n L4 = reinterpret(0x3E8BA305), // 2.7272811532e-01f\n L5 = reinterpret(0x3E6C3255), // 2.3066075146e-01f\n L6 = reinterpret(0x3E53F142), // 2.0697501302e-01f\n P1 = reinterpret(0x3E2AAAAB), // 1.6666667163e-01f\n P2 = reinterpret(0xBB360B61), // -2.7777778450e-03f\n P3 = reinterpret(0x388AB355), // 6.6137559770e-05f\n P4 = reinterpret(0xB5DDEA0E), // -1.6533901999e-06f\n P5 = reinterpret(0x3331BB4C), // 4.1381369442e-08f\n lg2 = reinterpret(0x3F317218), // 6.9314718246e-01f\n lg2_h = reinterpret(0x3F317200), // 6.93145752e-01f\n lg2_l = reinterpret(0x35BFBE8C), // 1.42860654e-06f\n ovt = reinterpret(0x3338AA3C), // 4.2995665694e-08f\n cp = reinterpret(0x3F76384F), // 9.6179670095e-01\n cp_h = reinterpret(0x3F764000), // 9.6191406250e-01\n cp_l = reinterpret(0xB8F623C6), // -1.1736857402e-04\n ivln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00\n ivln2_h = reinterpret(0x3FB8AA00), // 1.4426879883e+00\n ivln2_l = reinterpret(0x36ECA570), // 7.0526075433e-06\n inv3 = reinterpret(0x3EAAAAAB); // 0.333333333333\n var hx = reinterpret(x);\n var hy = reinterpret(y);\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if (iy == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3F800000) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if (ix > 0x7F800000 || iy > 0x7F800000) return x + y; // NaN if either arg is NaN\n var yisint = 0, j: i32, k: i32;\n if (hx < 0) {\n if (iy >= 0x4B800000) yisint = 2;\n else if (iy >= 0x3F800000) {\n k = (iy >> 23) - 0x7F;\n let ki = 23 - k;\n j = iy >> ki;\n if ((j << ki) == iy) yisint = 2 - (j & 1);\n }\n }\n if (iy == 0x7F800000) { // y is +-inf\n if (ix == 0x3F800000) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix > 0x3F800000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3F800000) return hy >= 0 ? x : 1.0 / x;\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3F000000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n var ax = builtin_abs(x);\n var z: f32;\n if (ix == 0x7F800000 || ix == 0 || ix == 0x3F800000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3F800000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n }\n else if (yisint == 1) z = -z;\n }\n return z;\n }\n var sn = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) sn = -1.0;\n }\n var t1: f32, t2: f32, r: f32, s: f32, t: f32, u: f32, v: f32, w: f32, p_h: f32, p_l: f32;\n var n: i32, is: i32;\n if (iy > 0x4D000000) {\n if (ix < 0x3F7FFFF8) return hy < 0 ? sn * huge * huge : sn * tiny * tiny;\n if (ix > 0x3F800007) return hy > 0 ? sn * huge * huge : sn * tiny * tiny;\n t = ax - 1;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = v - (t1 - u);\n } else {\n let s2: f32, s_h: f32, s_l: f32, t_h: f32, t_l: f32;\n n = 0;\n if (ix < 0x00800000) {\n ax *= two24;\n n -= 24;\n ix = reinterpret(ax);\n }\n n += (ix >> 23) - 0x7F;\n j = ix & 0x007FFFFF;\n ix = j | 0x3F800000;\n if (j <= 0x1CC471) k = 0;\n else if (j < 0x5DB3D7) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00800000;\n }\n ax = reinterpret(ix);\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n s = u * v;\n s_h = s;\n is = reinterpret(s_h);\n s_h = reinterpret(is & 0xFFFFF000);\n is = ((ix >> 1) & 0xFFFFF000) | 0x20000000;\n t_h = reinterpret(is + 0x00400000 + (k << 21));\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = s * s;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + s);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n is = reinterpret(t_h);\n t_h = reinterpret(is & 0xFFFFF000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * s;\n p_h = u + v;\n is = reinterpret(p_h);\n p_h = reinterpret(is & 0xFFFFF000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = (((z_h + z_l) + dp_h) + t);\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n is = reinterpret(y);\n var y1 = reinterpret(is & 0xFFFFF000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n j = reinterpret(z);\n if (j > 0x43000000) {\n return sn * huge * huge;\n } else if (j == 0x43000000) {\n if (p_l + ovt > z - p_h) return sn * huge * huge;\n } else if ((j & 0x7FFFFFFF) > 0x43160000) {\n return sn * tiny * tiny;\n } else if (j == 0xC3160000) {\n if (p_l <= z - p_h) return sn * tiny * tiny;\n }\n var i = j & 0x7FFFFFFF;\n k = (i >> 23) - 0x7F;\n n = 0;\n if (i > 0x3F000000) {\n n = j + (0x00800000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 23) - 0x7F;\n t = reinterpret(n & ~(0x007FFFFF >> k));\n n = ((n & 0x007FFFFF) | 0x00800000) >> (23 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n is = reinterpret(t);\n t = reinterpret(is & 0xFFFF8000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = reinterpret(z);\n j += n << 23;\n if ((j >> 23) <= 0) z = scalbn(z, n);\n else z = reinterpret(j);\n return sn * z;\n }\n\n // @ts-ignore: decorator\n @inline\n export function seedRandom(value: i64): void {\n NativeMath.seedRandom(value);\n }\n\n // Using xoroshiro64starstar from http://xoshiro.di.unimi.it/xoroshiro64starstar.c\n export function random(): f32 {\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n\n var s0 = random_state0_32;\n var s1 = random_state1_32;\n var r = rotl(s0 * 0x9E3779BB, 5) * 5;\n\n s1 ^= s0;\n random_state0_32 = rotl(s0, 26) ^ s1 ^ (s1 << 9);\n random_state1_32 = rotl(s1, 13);\n\n return reinterpret((r >> 9) | (127 << 23)) - 1.0;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f32): f32 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f32): f32 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f32): bool {\n // @ts-ignore: type\n return ((reinterpret(x) >>> 31) & (x == x));\n }\n\n export function sin(x: f32): f32 { // see: musl/src/math/sinf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const s2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const s4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return sin_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return sign ? -cos_kernf(x + s1pio2) : cos_kernf(x - s1pio2);\n }\n return sin_kernf(-(sign ? x + s2pio2 : x - s2pio2));\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return sign ? cos_kernf(x + s3pio2) : -cos_kernf(x - s3pio2);\n }\n return sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? cos_kernf(y) : sin_kernf(y);\n return n & 2 ? -t : t;\n }\n\n export function sinh(x: f32): f32 { // see: musl/src/math/sinhf.c\n var u = reinterpret(x) & 0x7FFFFFFF;\n var absx = reinterpret(u);\n var t: f32;\n var h = builtin_copysign(0.5, x);\n if (u < 0x42B17217) {\n t = expm1(absx);\n if (u < 0x3F800000) {\n if (u < 0x3F800000 - (12 << 23)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2f(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f32): f32 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f32): f32 { // see: musl/src/math/tanf.c\n const t1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const t2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const t3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const t4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return tan_kernf(x, 0);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return tan_kernf((sign ? x + t1pio2 : x - t1pio2), 1);\n } else {\n return tan_kernf((sign ? x + t2pio2 : x - t2pio2), 0);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return tan_kernf((sign ? x + t3pio2 : x - t3pio2), 1);\n } else {\n return tan_kernf((sign ? x + t4pio2 : x - t4pio2), 0);\n }\n }\n }\n\n /* tan(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* argument reduction */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n return tan_kernf(y, n & 1);\n }\n\n export function tanh(x: f32): f32 { // see: musl/src/math/tanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n var t: f32;\n if (u > 0x3F0C9F54) {\n if (u > 0x41200000) t = 1 + 0 / y;\n else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (u > 0x3E82C578) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (u >= 0x00800000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f32): f32 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f32, n: i32): f32 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbnf.c\n const\n Ox1p24f = reinterpret(0x4B800000),\n Ox1p127f = reinterpret(0x7F000000),\n Ox1p_126f = reinterpret(0x00800000);\n var y = x;\n if (n > 127) {\n y *= Ox1p127f;\n n -= 127;\n if (n > 127) {\n y *= Ox1p127f;\n n = builtin_min(n - 127, 127);\n }\n } else if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n += 126 - 24;\n if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n = builtin_max(n + 126 - 24, -126);\n }\n }\n return y * reinterpret((0x7F + n) << 23);\n }\n\n export function mod(x: f32, y: f32): f32 { // see: musl/src/math/fmodf.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = ux & 0x80000000;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0xFF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 9);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 9;\n ux |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 23); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 8);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 23;\n ux |= ex << 23;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx;\n return reinterpret(ux);\n }\n\n export function rem(x: f32, y: f32): f32 { // see: musl/src/math/remquof.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = (ux >> 31);\n var uxi = ux;\n if (uy << 1 == 0 || ex == 0xFF || isNaN(y)) return (x * y) / (x * y);\n if (ux << 1 == 0) return x;\n if (!ex) {\n ex -= builtin_clz(uxi << 9);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 9;\n uxi |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n var q = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -30;\n else {\n let shift = builtin_clz(uxi << 8);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end\n if (ex > 0) {\n uxi -= 1 << 23;\n uxi |= ex << 23;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // q++;\n }\n return sx ? -x : x;\n }\n\n export function sincos(x: f32): void { // see: musl/tree/src/math/sincosf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const s2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const s4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7fffffff;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n sincos_sin = x;\n sincos_cos = 1;\n return;\n }\n sincos_sin = sin_kernf(x);\n sincos_cos = cos_kernf(x);\n return;\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n if (sign) {\n sincos_sin = -cos_kernf(x + s1pio2);\n sincos_cos = sin_kernf(x + s1pio2);\n } else {\n sincos_sin = cos_kernf(s1pio2 - x);\n sincos_cos = sin_kernf(s1pio2 - x);\n }\n return;\n }\n /* -sin(x + c) is not correct if x+c could be 0: -0 vs +0 */\n sincos_sin = -sin_kernf(sign ? x + s2pio2 : x - s2pio2);\n sincos_cos = -cos_kernf(sign ? x + s2pio2 : x - s2pio2);\n return;\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n if (sign) {\n sincos_sin = cos_kernf(x + s3pio2);\n sincos_cos = -sin_kernf(x + s3pio2);\n } else {\n sincos_sin = -cos_kernf(x - s3pio2);\n sincos_cos = sin_kernf(x - s3pio2);\n }\n return;\n }\n sincos_sin = sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n sincos_cos = cos_kernf(sign ? x + s4pio2 : x - s4pio2);\n return;\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) {\n let xx = x - x;\n sincos_sin = xx;\n sincos_cos = xx;\n return;\n }\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n var s = sin_kernf(y);\n var c = cos_kernf(y);\n\n switch (n & 3) {\n case 0: {\n sincos_sin = s;\n sincos_cos = c;\n break;\n }\n case 1: {\n sincos_sin = c;\n sincos_cos = -s;\n break;\n }\n case 2: {\n sincos_sin = -s;\n sincos_cos = -c;\n break;\n }\n case 3:\n default: {\n sincos_sin = -c;\n sincos_cos = s;\n break;\n }\n }\n }\n}\n\nexport function ipow32(x: i32, e: i32): i32 {\n var out = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 5) {\n // 32 = 2 ^ 5, so need only five cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow64(x: i64, e: i32): i64 {\n var out: i64 = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 6) {\n // 64 = 2 ^ 6, so need only six cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 6: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow32f(x: f32, e: i32): f32 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out: f32 = 1;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n\nexport function ipow64f(x: f64, e: i32): f64 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out = 1.0;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n',memory:'import { memcmp, memmove, memset } from "./util/memory";\nimport { E_NOTIMPLEMENTED } from "./util/error";\n\n/** Memory manager interface. */\nexport namespace memory {\n\n /** Gets the size of the memory in pages. */\n // @ts-ignore: decorator\n @builtin\n export declare function size(): i32;\n\n /** Grows the memory by the given size in pages and returns the previous size in pages. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function grow(pages: i32): i32;\n\n /** Fills a section in memory with the specified byte value. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function fill(dst: usize, c: u8, n: usize): void {\n memset(dst, c, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Copies a section of memory to another. Has move semantics. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function copy(dst: usize, src: usize, n: usize): void {\n memmove(dst, src, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Initializes a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Drops a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function drop(segmentIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Repeats a section of memory at a specific address. */\n // @ts-ignore: decorator\n @unsafe\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void {\n var index: usize = 0;\n var total = srcLength * count;\n while (index < total) {\n memory.copy(dst + index, src, srcLength);\n index += srcLength;\n }\n }\n\n /** Compares a section of memory to another. */\n // @ts-ignore: decorator\n @inline\n export function compare(vl: usize, vr: usize, n: usize): i32 {\n return memcmp(vl, vr, n);\n }\n}\n',number:'import { itoa, dtoa } from "./util/number";\nimport { isNaN as builtin_isNaN, isFinite as builtin_isFinite } from "./builtins";\n\n@sealed @unmanaged\nexport abstract class I8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i8 = i8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i8 = i8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i8 {\n return parseI32(value, radix);\n }\n\n toString(this: i8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i16 = i16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i16 = i16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i16 {\n return parseI32(value, radix);\n }\n\n toString(this: i16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i32 = i32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i32 = i32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i32 {\n return parseI32(value, radix);\n }\n\n toString(this: i32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i64 = i64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i64 = i64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i64 {\n return parseI64(value, radix);\n }\n\n toString(this: i64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Isize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: isize = isize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: isize = isize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): isize {\n return parseI64(value, radix);\n }\n\n toString(this: isize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u8 = u8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u8 = u8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u8 {\n return parseI32(value, radix);\n }\n\n toString(this: u8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u16 = u16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u16 = u16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u16 {\n return parseI32(value, radix);\n }\n\n toString(this: u16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u32 = u32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u32 = u32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u32 {\n return parseI32(value, radix);\n }\n\n toString(this: u32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u64 = u64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u64 = u64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u64 {\n return parseI64(value, radix);\n }\n\n toString(this: u64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Usize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: usize = usize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: usize = usize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): usize {\n return parseI64(value, radix);\n }\n\n toString(this: usize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Bool {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: bool = bool.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: bool = bool.MAX_VALUE;\n\n toString(this: bool): String {\n // TODO: radix?\n return this ? "true" : "false";\n }\n}\n\nexport { Bool as Boolean };\n\n@sealed @unmanaged\nexport abstract class F32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f32 = f32.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f32 = f32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f32 = f32.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f32 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f32 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f32 = NaN;\n\n static isNaN(value: f32): bool {\n return isNaN(value);\n }\n\n static isFinite(value: f32): bool {\n return isFinite(value);\n }\n\n static isSafeInteger(value: f32): bool {\n return abs(value) <= f32.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f32): bool {\n return isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f32 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f32 {\n return parseFloat(value);\n }\n\n toString(this: f32): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class F64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f64 = f64.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f64 = f64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f64 = f64.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f64 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f64 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f64 = NaN;\n\n static isNaN(value: f64): bool {\n return builtin_isNaN(value);\n }\n\n static isFinite(value: f64): bool {\n return builtin_isFinite(value);\n }\n\n static isSafeInteger(value: f64): bool {\n return abs(value) <= f64.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f64): bool {\n return builtin_isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f64 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f64 {\n return parseFloat(value);\n }\n\n toString(this: f64): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\nexport { F64 as Number };\n',polyfills:"export function bswap(value: T): T {\n if (isInteger()) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n }\n if (sizeof() == 4) {\n return (\n rotl(value & 0xFF00FF00, 8) |\n rotr(value & 0x00FF00FF, 8)\n );\n }\n if (sizeof() == 8) {\n let a = (value >> 8) & 0x00FF00FF00FF00FF;\n let b = (value & 0x00FF00FF00FF00FF) << 8;\n let v = a | b;\n\n a = (v >> 16) & 0x0000FFFF0000FFFF;\n b = (v & 0x0000FFFF0000FFFF) << 16;\n\n return rotr(a | b, 32);\n }\n return value;\n }\n assert(false);\n return value;\n}\n\nexport function bswap16(value: T): T {\n if (isInteger() && sizeof() <= 4) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n } else if (sizeof() == 4) {\n return (((value << 8) & 0xFF00) | ((value >> 8) & 0x00FF) | (value & 0xFFFF0000));\n }\n return value;\n }\n assert(false);\n return value;\n}\n",regexp:'export class RegExp {\n\n // @binding(CALL_NEW, [ STRING, STRING], OBJECT_HANDLE)\n constructor(pattern: string, flags: string = "") { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [ STRING ], PASS_THRU)\n test(search: string): bool { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [], STRING)\n toString(): string { throw new Error("unreachable"); }\n\n}\n',rt:'import { Typeinfo, TypeinfoFlags } from "./shared/typeinfo";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { BLOCK, BLOCK_OVERHEAD } from "./rt/common";\nimport { ArrayBufferView } from "./arraybuffer";\n\n// @ts-ignore: decorator\n@builtin\nexport declare const RTTI_BASE: usize;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_globals(cookie: u32): void;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_members(ref: usize, cookie: u32): void;\n\n// @ts-ignore: decorator\n@unsafe\nexport function __typeinfo(id: u32): TypeinfoFlags {\n var ptr = RTTI_BASE;\n if (id > load(ptr)) throw new Error(E_INDEXOUTOFRANGE);\n return changetype(ptr + sizeof() + id * offsetof()).flags;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __instanceof(ref: usize, superId: u32): bool { // keyword\n var id = changetype(ref - BLOCK_OVERHEAD).rtId;\n var ptr = RTTI_BASE;\n if (id <= load(ptr)) {\n do if (id == superId) return true;\n while (id = changetype(ptr + sizeof() + id * offsetof()).base);\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize {\n var array = __alloc(offsetof(), id);\n var bufferSize = length << alignLog2;\n var buffer = __alloc(bufferSize, idof());\n store(array, __retain(buffer), offsetof("data"));\n changetype(array).dataStart = buffer;\n changetype(array).dataLength = bufferSize;\n store(changetype(array), length, offsetof("length_"));\n if (data) memory.copy(buffer, data, bufferSize);\n return array;\n}\n\n// These are provided by the respective implementation, included as another entry file by asc:\n\n// @builtin @unsafe\n// export declare function __alloc(size: usize, id: u32): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __realloc(ref: usize, size: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __free(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __retain(ref: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __release(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __collect(): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __visit(ref: usize, cookie: u32): void;\n',"rt/common":"// Alignment guarantees\n\n// @ts-ignore: decorator\n@inline export const AL_BITS: u32 = 4; // 16 bytes to fit up to v128\n// @ts-ignore: decorator\n@inline export const AL_SIZE: usize = 1 << AL_BITS;\n// @ts-ignore: decorator\n@inline export const AL_MASK: usize = AL_SIZE - 1;\n\n// Extra debugging\n\n// @ts-ignore: decorator\n@inline export const DEBUG = true;\n\n// ╒════════════════ Common block layout (32-bit) ═════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │ MM info │ -16\n// ├───────────────────────────────────────────────────────────────┤\n// │ GC info │ -12\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime id │ -8\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime size │ -4\n// ╞═══════════════════════════════════════════════════════════════╡\n// │ ... │ ref\n@unmanaged export class BLOCK {\n /** Memory manager info. */\n mmInfo: usize; // WASM64 needs adaption\n /** Garbage collector info. */\n gcInfo: u32;\n /** Runtime class id. */\n rtId: u32;\n /** Runtime object size. */\n rtSize: u32;\n}\n\n// @ts-ignore: decorator\n@inline export const BLOCK_OVERHEAD = (offsetof() + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@inline export const BLOCK_MAXSIZE: usize = (1 << 30) - BLOCK_OVERHEAD;\n","rt/index-full":'export { __alloc } from "rt/tlsf";\nexport { __retain, __release, __collect } from "rt/pure";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/index-half":'import "rt/index-full";\n',"rt/index-none":'import "rt/index-stub";\n',"rt/index-stub":'export { __alloc, __retain, __release, __collect } from "rt/stub";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/pure":'import { DEBUG, BLOCK_OVERHEAD } from "rt/common";\nimport { Block, freeBlock, ROOT } from "rt/tlsf";\nimport { TypeinfoFlags } from "shared/typeinfo";\nimport { onincrement, ondecrement, onfree, onalloc } from "./rtrace";\n\n/////////////////////////// A Pure Reference Counting Garbage Collector ///////////////////////////\n// see: https://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon03Pure.pdf\n\n// ╒══════════════════════ GC Info structure ══════════════════════╕\n// │ 3 2 1 │\n// │1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0│\n// ├─┼─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │B│color│ refCount │\n// └─┴─────┴───────────────────────────────────────────────────────┘\n// B: buffered\n\n// @ts-ignore: decorator\n@inline const BUFFERED_MASK: u32 = 1 << (sizeof() * 8 - 1);\n// @ts-ignore: decorator\n@inline const COLOR_BITS = 3;\n// @ts-ignore: decorator\n@inline const COLOR_SHIFT: u32 = ctz(BUFFERED_MASK) - COLOR_BITS;\n// @ts-ignore: decorator\n@inline const COLOR_MASK: u32 = ((1 << COLOR_BITS) - 1) << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const REFCOUNT_MASK: u32 = (1 << COLOR_SHIFT) - 1;\n\n// ╒════════╤═══════════════════ Colors ═══════════════════════════╕\n// │ Color │ Meaning │\n// ├────────┼──────────────────────────────────────────────────────┤\n// │ BLACK │ In use or free │\n// │ GRAY │ Possible member of cycle │\n// │ WHITE │ Member of garbage cycle │\n// │ PURPLE │ Possible root of cycle │\n// │ RED │ Candidate cycle undergoing Σ-computation *concurrent │\n// │ ORANGE │ Candidate cycle awaiting epoch boundary *concurrent │\n// └────────┴──────────────────────────────────────────────────────┘\n// Acyclic detection has been decoupled, hence no GREEN.\n\n// @ts-ignore: decorator\n@inline const COLOR_BLACK: u32 = 0 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_GRAY: u32 = 1 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_WHITE: u32 = 2 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_PURPLE: u32 = 3 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_RED: u32 = 4 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_ORANGE: u32 = 5 << COLOR_SHIFT;\n\n// @ts-ignore: decorator\n@inline const VISIT_DECREMENT = 1; // guard 0\n// @ts-ignore: decorator\n@inline const VISIT_MARKGRAY = 2;\n// @ts-ignore: decorator\n@inline const VISIT_SCAN = 3;\n// @ts-ignore: decorator\n@inline const VISIT_SCANBLACK = 4;\n// @ts-ignore: decorator\n@inline const VISIT_COLLECTWHITE = 5;\n\n// @ts-ignore: decorator\n@global @unsafe\nfunction __visit(ref: usize, cookie: i32): void {\n if (ref < HEAP_BASE) return;\n var s = changetype(ref - BLOCK_OVERHEAD);\n switch (cookie) {\n case VISIT_DECREMENT: {\n decrement(s);\n break;\n }\n case VISIT_MARKGRAY: {\n if (DEBUG) assert((s.gcInfo & REFCOUNT_MASK) > 0);\n s.gcInfo = s.gcInfo - 1;\n markGray(s);\n break;\n }\n case VISIT_SCAN: {\n scan(s);\n break;\n }\n case VISIT_SCANBLACK: {\n let info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if ((info & COLOR_MASK) != COLOR_BLACK) {\n scanBlack(s);\n }\n break;\n }\n case VISIT_COLLECTWHITE: {\n collectWhite(s);\n break;\n }\n default: if (DEBUG) assert(false);\n }\n}\n\n/** Increments the reference count of the specified block by one.*/\nfunction increment(s: Block): void {\n var info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if (isDefined(ASC_RTRACE)) onincrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n}\n\n/** Decrements the reference count of the specified block by one, possibly freeing it. */\nfunction decrement(s: Block): void {\n var info = s.gcInfo;\n var rc = info & REFCOUNT_MASK;\n if (isDefined(ASC_RTRACE)) ondecrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n if (rc == 1) {\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_DECREMENT);\n if (!(info & BUFFERED_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = BUFFERED_MASK | COLOR_BLACK | 0;\n }\n } else {\n if (DEBUG) assert(rc > 0);\n if (!(__typeinfo(s.rtId) & TypeinfoFlags.ACYCLIC)) {\n s.gcInfo = BUFFERED_MASK | COLOR_PURPLE | (rc - 1);\n if (!(info & BUFFERED_MASK)) {\n appendRoot(s);\n }\n } else {\n s.gcInfo = (info & ~REFCOUNT_MASK) | (rc - 1);\n }\n }\n}\n\n/** Buffer of possible roots. */\n// @ts-ignore: decorator\n@lazy var ROOTS: usize;\n/** Current absolute offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var CUR: usize = 0;\n/** Current absolute end offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var END: usize = 0;\n\n/** Appends a block to possible roots. */\nfunction appendRoot(s: Block): void {\n var cur = CUR;\n if (cur >= END) {\n growRoots(); // TBD: either that or pick a default and force collection on overflow\n cur = CUR;\n }\n store(cur, s);\n CUR = cur + sizeof();\n}\n\n/** Grows the roots buffer if it ran full. */\nfunction growRoots(): void {\n var oldRoots = ROOTS;\n var oldSize = CUR - oldRoots;\n var newSize = max(oldSize * 2, 64 << alignof());\n var newRoots = __alloc(newSize, 0);\n if (isDefined(ASC_RTRACE)) onfree(changetype(newRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n memory.copy(newRoots, oldRoots, oldSize);\n if (oldRoots) {\n if (isDefined(ASC_RTRACE)) onalloc(changetype(oldRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n __free(oldRoots);\n }\n ROOTS = newRoots;\n CUR = newRoots + oldSize;\n END = newRoots + newSize;\n}\n\n/** Collects cyclic garbage. */\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n\n // markRoots\n var roots = ROOTS;\n var cur = roots;\n for (let pos = cur, end = CUR; pos < end; pos += sizeof()) {\n let s = load(pos);\n let info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_PURPLE && (info & REFCOUNT_MASK) > 0) {\n markGray(s);\n store(cur, s);\n cur += sizeof();\n } else {\n if ((info & COLOR_MASK) == COLOR_BLACK && !(info & REFCOUNT_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = info & ~BUFFERED_MASK;\n }\n }\n }\n CUR = cur;\n\n // scanRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n scan(load(pos));\n }\n\n // collectRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n let s = load(pos);\n s.gcInfo = s.gcInfo & ~BUFFERED_MASK;\n collectWhite(s);\n }\n CUR = roots;\n}\n\n/** Marks a block as gray (possible member of cycle) during the collection phase. */\nfunction markGray(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) != COLOR_GRAY) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_GRAY;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_MARKGRAY);\n }\n}\n\n/** Scans a block during the collection phase, determining whether it is garbage or not. */\nfunction scan(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_GRAY) {\n if ((info & REFCOUNT_MASK) > 0) {\n scanBlack(s);\n } else {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_WHITE;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCAN);\n }\n }\n}\n\n/** Marks a block as black (in use) if it was found to be reachable during the collection phase. */\nfunction scanBlack(s: Block): void {\n s.gcInfo = (s.gcInfo & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCANBLACK);\n}\n\n/** Collects all white (member of a garbage cycle) nodes when completing the collection phase. */\nfunction collectWhite(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_WHITE && !(info & BUFFERED_MASK)) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_COLLECTWHITE);\n freeBlock(ROOT, s);\n }\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n if (ref > HEAP_BASE) increment(changetype(ref - BLOCK_OVERHEAD));\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n if (ref > HEAP_BASE) decrement(changetype(ref - BLOCK_OVERHEAD));\n}\n',"rt/rtrace":'import { BLOCK } from "./common";\n\nexport declare function onalloc(s: BLOCK): void;\nexport declare function onincrement(s: BLOCK): void;\nexport declare function ondecrement(s: BLOCK): void;\nexport declare function onfree(s: BLOCK): void;\n',"rt/stub":'import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common";\n\n// @ts-ignore: decorator\n@lazy\nvar startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@lazy\nvar offset: usize = startOffset;\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __alloc(size: usize, id: u32): usize {\n if (size > BLOCK_MAXSIZE) unreachable();\n var ptr = offset + BLOCK_OVERHEAD;\n var newPtr = (ptr + max(size, 1) + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n if (newPtr > pagesBefore << 16) {\n let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;\n let pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable(); // out of memory\n }\n }\n offset = newPtr;\n var block = changetype(ptr - BLOCK_OVERHEAD);\n block.rtId = id;\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __realloc(ref: usize, size: usize): usize {\n var block = changetype(ref - BLOCK_OVERHEAD);\n var oldSize = block.rtSize;\n if (size > oldSize) {\n let newRef = __alloc(size, block.rtId);\n memory.copy(newRef, ref, oldSize);\n ref = newRef;\n } else {\n block.rtSize = size;\n }\n return ref;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __free(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nfunction __reset(): void { // special\n offset = startOffset;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __visit(ref: usize, cookie: u32): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n}\n',"rt/tlsf":"import { AL_BITS, AL_MASK, DEBUG, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from \"rt/common\";\nimport { onfree, onalloc } from \"./rtrace\";\n\n/////////////////////// The TLSF (Two-Level Segregate Fit) memory allocator ///////////////////////\n// see: http://www.gii.upv.es/tlsf/\n\n// - `ffs(x)` is equivalent to `ctz(x)` with x != 0\n// - `fls(x)` is equivalent to `sizeof(x) * 8 - clz(x) - 1`\n\n// ╒══════════════ Block size interpretation (32-bit) ═════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─╫─┴─┴─┴─┤\n// │ | FL │ SB = SL + AL │ ◄─ usize\n// └───────────────────────────────────────────────┴───────╨───────┘\n// FL: first level, SL: second level, AL: alignment, SB: small block\n\n// @ts-ignore: decorator\n@inline const SL_BITS: u32 = 4;\n// @ts-ignore: decorator\n@inline const SL_SIZE: usize = 1 << SL_BITS;\n\n// @ts-ignore: decorator\n@inline const SB_BITS: usize = (SL_BITS + AL_BITS);\n// @ts-ignore: decorator\n@inline const SB_SIZE: usize = 1 << SB_BITS;\n\n// @ts-ignore: decorator\n@inline const FL_BITS: u32 = 31 - SB_BITS;\n\n// [00]: < 256B (SB) [12]: < 1M\n// [01]: < 512B [13]: < 2M\n// [02]: < 1K [14]: < 4M\n// [03]: < 2K [15]: < 8M\n// [04]: < 4K [16]: < 16M\n// [05]: < 8K [17]: < 32M\n// [06]: < 16K [18]: < 64M\n// [07]: < 32K [19]: < 128M\n// [08]: < 64K [20]: < 256M\n// [09]: < 128K [21]: < 512M\n// [10]: < 256K [22]: <= 1G - OVERHEAD\n// [11]: < 512K\n// VMs limit to 2GB total (currently), making one 1G block max (or three 512M etc.) due to block overhead\n\n// Tags stored in otherwise unused alignment bits\n\n// @ts-ignore: decorator\n@inline const FREE: usize = 1 << 0;\n// @ts-ignore: decorator\n@inline const LEFTFREE: usize = 1 << 1;\n// @ts-ignore: decorator\n@inline const TAGS_MASK: usize = FREE | LEFTFREE; // <= AL_MASK\n\n// ╒════════════════════ Block layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┼─┤ overhead ┐\n// │ size │0│L│F│ ◄─┐ info\n// ├─────────────────────────────────────────────────────────┴─┴─┴─┤ │\n// │ │ │\n// │ ... additional runtime overhead ... │ │\n// │ │ │\n// ╞═══════════════════════════════════════════════════════════════╡ │ ┐ ┘\n// │ if free: ◄ prev │ ◄─┤ usize\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: next ► │ ◄─┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ │ = 0\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: back ▲ │ ◄─┘\n// └───────────────────────────────────────────────────────────────┘ payload ┘ >= MIN SIZE\n// F: FREE, L: LEFTFREE\n@unmanaged export class Block extends BLOCK {\n\n /** Previous free block, if any. Only valid if free, otherwise part of payload. */\n prev: Block | null;\n /** Next free block, if any. Only valid if free, otherwise part of payload. */\n next: Block | null;\n\n // If the block is free, there is a 'back'reference at its end pointing at its start.\n}\n\n// Block constants. A block must have a minimum size of three pointers so it can hold `prev`,\n// `next` and `back` if free.\n\n// @ts-ignore: decorator\n@inline const BLOCK_MINSIZE: usize = (3 * sizeof() + AL_MASK) & ~AL_MASK; // prev + next + back\n// @ts-ignore: decorator\n// @inline const BLOCK_MAXSIZE: usize = 1 << (FL_BITS + SB_BITS - 1); // exclusive, lives in common.ts\n\n/** Gets the left block of a block. Only valid if the left block is free. */\n// @ts-ignore: decorator\n@inline function GETFREELEFT(block: Block): Block {\n return load(changetype(block) - sizeof());\n}\n\n/** Gets the right block of of a block by advancing to the right by its size. */\n// @ts-ignore: decorator\n@inline function GETRIGHT(block: Block): Block {\n return changetype(changetype(block) + BLOCK_OVERHEAD + (block.mmInfo & ~TAGS_MASK));\n}\n\n// ╒═════════════════════ Root layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ┐\n// │ 0 | flMap S│ ◄────┐\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ slMap[0] S │ ◄─┐ │\n// ├───────────────────────────────────────────────────────────────┤ │ │\n// │ slMap[1] │ ◄─┤ │\n// ├───────────────────────────────────────────────────────────────┤ u32 │\n// │ slMap[22] │ ◄─┘ │\n// ╞═══════════════════════════════════════════════════════════════╡ usize\n// │ head[0] │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ head[367] │ ◄────┤\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ tail │ ◄────┘\n// └───────────────────────────────────────────────────────────────┘ SIZE ┘\n// S: Small blocks map\n@unmanaged class Root {\n /** First level bitmap. */\n flMap: usize;\n}\n\n// Root constants. Where stuff is stored inside of the root structure.\n\n// @ts-ignore: decorator\n@inline const SL_START = sizeof();\n// @ts-ignore: decorator\n@inline const SL_END = SL_START + (FL_BITS << alignof());\n// @ts-ignore: decorator\n@inline const HL_START = (SL_END + AL_MASK) & ~AL_MASK;\n// @ts-ignore: decorator\n@inline const HL_END = HL_START + FL_BITS * SL_SIZE * sizeof();\n// @ts-ignore: decorator\n@inline const ROOT_SIZE = HL_END + sizeof();\n\n// @ts-ignore: decorator\n@lazy export var ROOT: Root;\n\n/** Gets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function GETSL(root: Root, fl: usize): u32 {\n return load(\n changetype(root) + (fl << alignof()),\n SL_START\n );\n}\n\n/** Sets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function SETSL(root: Root, fl: usize, slMap: u32): void {\n store(\n changetype(root) + (fl << alignof()),\n slMap,\n SL_START\n );\n}\n\n/** Gets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function GETHEAD(root: Root, fl: usize, sl: u32): Block | null {\n return load(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n HL_START\n );\n}\n\n/** Sets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function SETHEAD(root: Root, fl: usize, sl: u32, head: Block | null): void {\n store(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n head,\n HL_START\n );\n}\n\n/** Gets the tail block.. */\n// @ts-ignore: decorator\n@inline function GETTAIL(root: Root): Block {\n return load(\n changetype(root),\n HL_END\n );\n}\n\n/** Sets the tail block. */\n// @ts-ignore: decorator\n@inline function SETTAIL(root: Root, tail: Block): void {\n store(\n changetype(root),\n tail,\n HL_END\n );\n}\n\n/** Inserts a previously used block back into the free list. */\nfunction insertBlock(root: Root, block: Block): void {\n if (DEBUG) assert(block); // cannot be null\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n\n // merge with right block if also free\n if (rightInfo & FREE) {\n let newSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, right);\n block.mmInfo = blockInfo = (blockInfo & TAGS_MASK) | newSize;\n right = GETRIGHT(block);\n rightInfo = right.mmInfo;\n // 'back' is set below\n }\n }\n\n // merge with left block if also free\n if (blockInfo & LEFTFREE) {\n let left = GETFREELEFT(block);\n let leftInfo = left.mmInfo;\n if (DEBUG) assert(leftInfo & FREE); // must be free according to right tags\n let newSize = (leftInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (blockInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, left);\n left.mmInfo = blockInfo = (leftInfo & TAGS_MASK) | newSize;\n block = left;\n // 'back' is set below\n }\n }\n\n right.mmInfo = rightInfo | LEFTFREE;\n // right is no longer used now, hence rightInfo is not synced\n\n // we now know the size of the block\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be a valid size\n if (DEBUG) assert(changetype(block) + BLOCK_OVERHEAD + size == changetype(right)); // must match\n\n // set 'back' to itself at the end of block\n store(changetype(right) - sizeof(), block);\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // perform insertion\n var head = GETHEAD(root, fl, sl);\n block.prev = null;\n block.next = head;\n if (head) head.prev = block;\n SETHEAD(root, fl, sl, block);\n\n // update first and second level maps\n root.flMap |= (1 << fl);\n SETSL(root, fl, GETSL(root, fl) | (1 << sl));\n}\n\n/** Removes a free block from internal lists. */\nfunction removeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be valid\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // link previous and next free block\n var prev = block.prev;\n var next = block.next;\n if (prev) prev.next = next;\n if (next) next.prev = prev;\n\n // update head if we are removing it\n if (block == GETHEAD(root, fl, sl)) {\n SETHEAD(root, fl, sl, next);\n\n // clear second level map if head is empty now\n if (!next) {\n let slMap = GETSL(root, fl);\n SETSL(root, fl, slMap &= ~(1 << sl));\n\n // clear first level map if second level is empty now\n if (!slMap) root.flMap &= ~(1 << fl);\n }\n }\n // note: does not alter left/back because it is likely that splitting\n // is performed afterwards, invalidating those changes. so, the caller\n // must perform those updates.\n}\n\n/** Searches for a free block of at least the specified size. */\nfunction searchBlock(root: Root, size: usize): Block | null {\n // size was already asserted by caller\n\n // mapping_search\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const halfMaxSize = BLOCK_MAXSIZE >> 1; // don't round last fl\n const inv: usize = sizeof() * 8 - 1;\n const invRound = inv - SL_BITS;\n let requestSize = size < halfMaxSize\n ? size + (1 << (invRound - clz(size))) - 1\n : size;\n fl = inv - clz(requestSize);\n sl = ((requestSize >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // search second level\n var slMap = GETSL(root, fl) & (~0 << sl);\n var head: Block | null = null;\n if (!slMap) {\n // search next larger first level\n let flMap = root.flMap & (~0 << (fl + 1));\n if (!flMap) {\n head = null;\n } else {\n fl = ctz(flMap);\n slMap = GETSL(root, fl);\n if (DEBUG) assert(slMap); // can't be zero if fl points here\n head = GETHEAD(root, fl, ctz(slMap));\n }\n } else {\n head = GETHEAD(root, fl, ctz(slMap));\n }\n return head;\n}\n\n/** Prepares the specified block before (re-)use, possibly splitting it. */\nfunction prepareBlock(root: Root, block: Block, size: usize): void {\n // size was already asserted by caller\n\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(size & AL_MASK)); // size must be aligned so the new block is\n\n // split if the block can hold another MINSIZE block incl. overhead\n var remaining = (blockInfo & ~TAGS_MASK) - size;\n if (remaining >= BLOCK_OVERHEAD + BLOCK_MINSIZE) {\n block.mmInfo = size | (blockInfo & LEFTFREE); // also discards FREE\n\n let spare = changetype(changetype(block) + BLOCK_OVERHEAD + size);\n spare.mmInfo = (remaining - BLOCK_OVERHEAD) | FREE; // not LEFTFREE\n insertBlock(root, spare); // also sets 'back'\n\n // otherwise tag block as no longer FREE and right as no longer LEFTFREE\n } else {\n block.mmInfo = blockInfo & ~FREE;\n GETRIGHT(block).mmInfo &= ~LEFTFREE;\n }\n}\n\n/** Adds more memory to the pool. */\nfunction addMemory(root: Root, start: usize, end: usize): bool {\n if (DEBUG) {\n assert(\n start <= end && // must be valid\n !(start & AL_MASK) && // must be aligned\n !(end & AL_MASK) // must be aligned\n );\n }\n\n var tail = GETTAIL(root);\n var tailInfo: usize = 0;\n if (tail) { // more memory\n if (DEBUG) assert(start >= changetype(tail) + BLOCK_OVERHEAD);\n\n // merge with current tail if adjacent\n if (start - BLOCK_OVERHEAD == changetype(tail)) {\n start -= BLOCK_OVERHEAD;\n tailInfo = tail.mmInfo;\n } else {\n // We don't do this, but a user might `memory.grow` manually\n // leading to non-adjacent pages managed by TLSF.\n }\n\n } else if (DEBUG) { // first memory\n assert(start >= changetype(root) + ROOT_SIZE); // starts after root\n }\n\n // check if size is large enough for a free block and the tail block\n var size = end - start;\n if (size < BLOCK_OVERHEAD + BLOCK_MINSIZE + BLOCK_OVERHEAD) {\n return false;\n }\n\n // left size is total minus its own and the zero-length tail's header\n var leftSize = size - 2 * BLOCK_OVERHEAD;\n var left = changetype(start);\n left.mmInfo = leftSize | FREE | (tailInfo & LEFTFREE);\n left.prev = null;\n left.next = null;\n\n // tail is a zero-length used block\n tail = changetype(start + size - BLOCK_OVERHEAD);\n tail.mmInfo = 0 | LEFTFREE;\n SETTAIL(root, tail);\n\n insertBlock(root, left); // also merges with free left before tail / sets 'back'\n\n return true;\n}\n\n/** Grows memory to fit at least another block of the specified size. */\nfunction growMemory(root: Root, size: usize): void {\n var pagesBefore = memory.size();\n var pagesNeeded = (((size + 0xffff) & ~0xffff) >>> 16);\n var pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable();\n }\n var pagesAfter = memory.size();\n addMemory(root, pagesBefore << 16, pagesAfter << 16);\n}\n\n/** Prepares and checks an allocation size. */\nfunction prepareSize(size: usize): usize {\n if (size >= BLOCK_MAXSIZE) throw new Error(\"allocation too large\");\n return max((size + AL_MASK) & ~AL_MASK, BLOCK_MINSIZE); // align and ensure min size\n}\n\n/** Initilizes the root structure. */\nexport function initializeRoot(): void {\n var rootOffset = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n var pagesNeeded = ((((rootOffset + ROOT_SIZE) + 0xffff) & ~0xffff) >>> 16);\n if (pagesNeeded > pagesBefore && memory.grow(pagesNeeded - pagesBefore) < 0) unreachable();\n var root = changetype(rootOffset);\n root.flMap = 0;\n SETTAIL(root, changetype(0));\n for (let fl: usize = 0; fl < FL_BITS; ++fl) {\n SETSL(root, fl, 0);\n for (let sl: u32 = 0; sl < SL_SIZE; ++sl) {\n SETHEAD(root, fl, sl, null);\n }\n }\n addMemory(root, (rootOffset + ROOT_SIZE + AL_MASK) & ~AL_MASK, memory.size() << 16);\n ROOT = root;\n}\n\n/** Allocates a block of the specified size. */\nexport function allocateBlock(root: Root, size: usize): Block {\n var payloadSize = prepareSize(size);\n var block = searchBlock(root, payloadSize);\n if (!block) {\n growMemory(root, payloadSize);\n block = searchBlock(root, payloadSize);\n if (DEBUG) assert(block); // must be found now\n }\n if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit\n block.gcInfo = 0; // RC=0\n // block.rtId = 0; // set by the caller (__alloc)\n block.rtSize = size;\n removeBlock(root, block);\n prepareBlock(root, block, payloadSize);\n if (isDefined(ASC_RTRACE)) onalloc(block);\n return block;\n}\n\n/** Reallocates a block to the specified size. */\nexport function reallocateBlock(root: Root, block: Block, size: usize): Block {\n var payloadSize = prepareSize(size);\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(blockInfo & FREE)); // must be used\n\n // possibly split and update runtime size if it still fits\n if (payloadSize <= (blockInfo & ~TAGS_MASK)) {\n prepareBlock(root, block, payloadSize);\n block.rtSize = size;\n return block;\n }\n\n // merge with right free block if merger is large enough\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n if (rightInfo & FREE) {\n let mergeSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (mergeSize >= payloadSize) {\n removeBlock(root, right);\n // TODO: this can yield an intermediate block larger than BLOCK_MAXSIZE, which\n // is immediately split though. does this trigger any assertions / issues?\n block.mmInfo = (blockInfo & TAGS_MASK) | mergeSize;\n block.rtSize = size;\n prepareBlock(root, block, payloadSize);\n return block;\n }\n }\n\n // otherwise move the block\n var newBlock = allocateBlock(root, size);\n newBlock.gcInfo = block.gcInfo;\n newBlock.rtId = block.rtId;\n memory.copy(changetype(newBlock) + BLOCK_OVERHEAD, changetype(block) + BLOCK_OVERHEAD, size);\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n return newBlock;\n}\n\n/** Frees a block. */\nexport function freeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n assert(!(blockInfo & FREE)); // must be used (user might call through to this)\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n if (isDefined(ASC_RTRACE)) onfree(block);\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __alloc(size: usize, id: u32): usize {\n var root = ROOT;\n if (!root) {\n initializeRoot();\n root = ROOT;\n }\n var block = allocateBlock(root, size);\n block.rtId = id;\n return changetype(block) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __realloc(ref: usize, size: usize): usize {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n return changetype(reallocateBlock(ROOT, changetype(ref - BLOCK_OVERHEAD), size)) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __free(ref: usize): void {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n freeBlock(ROOT, changetype(ref - BLOCK_OVERHEAD));\n}\n",set:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a set entry. */\n@unmanaged class SetEntry {\n key: K;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K is <= 32-bits\n const align = (sizeof() > sizeof() ? sizeof() : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Set {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // SetEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() { this.clear(); }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): SetEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n add(key: K): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (!entry) {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n entry = changetype>(changetype(this.entries) + this.entriesOffset++ * ENTRY_SIZE());\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key)); // unmanaged!\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key)); // exact \'key\'\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr); // unmanaged!\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr); // unmanaged!\n newEntry.key = oldEntry.key;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Set]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',"shared/feature":"// This file is shared with the compiler and must remain portable\n\n/** Indicates specific features to activate. */\nexport const enum Feature {\n /** No additional features. */\n NONE = 0,\n /** Sign extension operations. */\n SIGN_EXTENSION = 1 << 0, // see: https://github.com/WebAssembly/sign-extension-ops\n /** Mutable global imports and exports. */\n MUTABLE_GLOBAL = 1 << 1, // see: https://github.com/WebAssembly/mutable-global\n /** Bulk memory operations. */\n BULK_MEMORY = 1 << 2, // see: https://github.com/WebAssembly/bulk-memory-operations\n /** SIMD types and operations. */\n SIMD = 1 << 3, // see: https://github.com/WebAssembly/simd\n /** Threading and atomic operations. */\n THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads\n}\n","shared/target":"// This file is shared with the compiler and must remain portable\n\n/** Compilation target. */\nexport enum Target {\n /** WebAssembly with 32-bit pointers. */\n WASM32,\n /** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */\n WASM64,\n /** Portable. */\n JS\n}\n","shared/typeinfo":"// This file is shared with the compiler and must remain portable\n\n// ╒═══════════════════ Typeinfo interpretation ═══════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ◄─ RTTI_BASE\n// │ count │\n// ╞═══════════════════════════════════════════════════════════════╡ ┐\n// │ Typeinfo#flags [id=0] │ id < count\n// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤\n// │ Typeinfo#base [id=0] │\n// ├───────────────────────────────────────────────────────────────┤\n// │ ... │\n\n/** Runtime type information data structure. */\n@unmanaged\nexport class Typeinfo {\n /** Flags describing the shape of this class type. */\n flags: TypeinfoFlags;\n /** Base class id or `0` if none. */\n base: u32;\n}\n\n/** Runtime type information flags. */\nexport const enum TypeinfoFlags {\n /** No specific flags. */\n NONE = 0,\n /** Type is an `ArrayBufferView`. */\n ARRAYBUFFERVIEW = 1 << 0,\n /** Type is an `Array`. */\n ARRAY = 1 << 1,\n /** Type is a `Set`. */\n SET = 1 << 2,\n /** Type is a `Map`. */\n MAP = 1 << 3,\n /** Type is inherently acyclic. */\n ACYCLIC = 1 << 4,\n /** Value alignment of 1 byte. */\n VALUE_ALIGN_0 = 1 << 5,\n /** Value alignment of 2 bytes. */\n VALUE_ALIGN_1 = 1 << 6,\n /** Value alignment of 4 bytes. */\n VALUE_ALIGN_2 = 1 << 7,\n /** Value alignment of 8 bytes. */\n VALUE_ALIGN_3 = 1 << 8,\n /** Value alignment of 16 bytes. */\n VALUE_ALIGN_4 = 1 << 9,\n /** Value is a signed type. */\n VALUE_SIGNED = 1 << 10,\n /** Value is a float type. */\n VALUE_FLOAT = 1 << 11,\n /** Value type is nullable. */\n VALUE_NULLABLE = 1 << 12,\n /** Value type is managed. */\n VALUE_MANAGED = 1 << 13,\n /** Key alignment of 1 byte. */\n KEY_ALIGN_0 = 1 << 14,\n /** Key alignment of 2 bytes. */\n KEY_ALIGN_1 = 1 << 15,\n /** Key alignment of 4 bytes. */\n KEY_ALIGN_2 = 1 << 16,\n /** Key alignment of 8 bytes. */\n KEY_ALIGN_3 = 1 << 17,\n /** Key alignment of 16 bytes. */\n KEY_ALIGN_4 = 1 << 18,\n /** Value is a signed type. */\n KEY_SIGNED = 1 << 19,\n /** Value is a float type. */\n KEY_FLOAT = 1 << 20,\n /** Key type is nullable. */\n KEY_NULLABLE = 1 << 21,\n /** Key type is managed. */\n KEY_MANAGED = 1 << 22\n}\n",string:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./util/string";\nimport { E_INVALIDLENGTH } from "./util/error";\nimport { ArrayBufferView } from "./arraybuffer";\nimport { idof } from "./builtins";\n\n@sealed export abstract class String {\n\n @lazy static readonly MAX_LENGTH: i32 = BLOCK_MAXSIZE >>> alignof();\n\n // TODO Add and handle second argument\n static fromCharCode(code: i32): string {\n var out = __alloc(2, idof());\n store(out, code);\n return changetype(out); // retains\n }\n\n static fromCodePoint(code: i32): string {\n assert(code <= 0x10FFFF);\n var sur = code > 0xFFFF;\n var out = __alloc((i32(sur) + 1) << 1, idof());\n if (!sur) {\n store(out, code);\n } else {\n code -= 0x10000;\n let hi: u32 = (code >>> 10) + 0xD800;\n let lo: u32 = (code & 0x3FF) + 0xDC00;\n store(out, (hi << 16) | lo);\n }\n return changetype(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >> 1;\n }\n\n @operator("[]") charAt(pos: i32): String {\n assert(this !== null);\n if (pos >= this.length) return changetype("");\n var out = __alloc(2, idof());\n store(out, load(changetype(this) + (pos << 1)));\n return changetype(out); // retains\n }\n\n charCodeAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (NaN)\n return load(changetype(this) + (pos << 1));\n }\n\n codePointAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (undefined)\n var first = load(changetype(this) + (pos << 1));\n if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length) return first;\n var second = load(changetype(this) + ((pos + 1) << 1));\n if (second < 0xDC00 || second > 0xDFFF) return first;\n return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;\n }\n\n @operator("+") private static __concat(left: String, right: String): String {\n return select(left, changetype("null"), left !== null).concat(right);\n }\n\n concat(other: String): String {\n if (other === null) other = changetype("null");\n var thisSize: isize = this.length << 1;\n var otherSize: isize = other.length << 1;\n var outSize: usize = thisSize + otherSize;\n if (outSize == 0) return changetype("");\n var out = changetype(__alloc(outSize, idof())); // retains\n memory.copy(changetype(out), changetype(this), thisSize);\n memory.copy(changetype(out) + thisSize, changetype(other), otherSize);\n return out;\n }\n\n endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool {\n assert(this !== null);\n if (searchString === null) return false;\n var end = min(max(endPosition, 0), this.length);\n var searchLength: isize = searchString.length;\n var start: isize = end - searchLength;\n if (start < 0) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n @operator("==") private static __eq(left: String | null, right: String | null): bool {\n if (left === right) return true;\n if (left === null || right === null) return false;\n var leftLength = left.length;\n if (leftLength != right.length) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(left, 0, right, 0, leftLength);\n }\n\n @operator.prefix("!")\n private static __not(str: String | null): bool {\n return str === null || !str.length;\n }\n\n @operator("!=")\n private static __ne(left: String | null, right: String | null): bool {\n return !this.__eq(left, right);\n }\n\n @operator(">") private static __gt(left: String | null, right: String | null): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!leftLength) return false;\n if (!rightLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) > 0;\n }\n\n @operator(">=") private static __gte(left: String, right: String): bool {\n return !this.__lt(left, right);\n }\n\n @operator("<") private static __lt(left: String, right: String): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!rightLength) return false;\n if (!leftLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) < 0;\n }\n\n @operator("<=") private static __lte(left: String, right: String): bool {\n return !this.__gt(left, right);\n }\n\n @inline includes(searchString: String, position: i32 = 0): bool {\n return this.indexOf(searchString, position) != -1;\n }\n\n indexOf(searchString: String, fromIndex: i32 = 0): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var searchLen: isize = searchString.length;\n if (!searchLen) return 0;\n var len: isize = this.length;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len);\n len -= searchLen;\n for (let k: isize = start; k <= len; ++k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var len: isize = this.length;\n var searchLen: isize = searchString.length;\n if (!searchLen) return len;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len - searchLen);\n for (let k = start; k >= 0; --k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n startsWith(searchString: String, position: i32 = 0): bool {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var pos: isize = position;\n var len: isize = this.length;\n var start = min(max(pos, 0), len);\n var searchLength: isize = searchString.length;\n if (searchLength + start > len) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var intStart: isize = start;\n var end: isize = length;\n var size: isize = this.length;\n if (intStart < 0) intStart = max(size + intStart, 0);\n var resultLength = min(max(end, 0), size - intStart);\n if (resultLength <= 0) return changetype("");\n var out = __alloc(resultLength << 1, idof());\n memory.copy(out, changetype(this) + intStart, resultLength);\n return changetype(out); // retains\n }\n\n substring(start: i32, end: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var len: isize = this.length;\n var finalStart = min(max(start, 0), len);\n var finalEnd = min(max(end, 0), len);\n var fromPos = min(finalStart, finalEnd) << 1;\n var toPos = max(finalStart, finalEnd) << 1;\n len = toPos - fromPos;\n if (!len) return changetype("");\n if (!fromPos && toPos == this.length << 1) return this;\n var out = __alloc(len, idof());\n memory.copy(out, changetype(this) + fromPos, len);\n return changetype(out); // retains\n }\n\n trim(): String {\n assert(this !== null);\n var length = this.length;\n var size: usize = length << 1;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2; size -= 2;\n }\n if (!size) return changetype("");\n if (!start && size == length << 1) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n @inline\n trimLeft(): String {\n return this.trimStart();\n }\n\n @inline\n trimRight(): String {\n return this.trimEnd();\n }\n\n trimStart(): String {\n assert(this !== null);\n var size = this.length << 1;\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2;\n }\n if (!offset) return this;\n size -= offset;\n if (!size) return changetype("");\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n trimEnd(): String {\n assert(this !== null);\n var originalSize = this.length << 1;\n var size = originalSize;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n if (!size) return changetype("");\n if (size == originalSize) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this), size);\n return changetype(out); // retains\n }\n\n padStart(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var prependSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n if (prependSize > padSize) {\n let repeatCount = (prependSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = prependSize - restBase;\n memory.repeat(out, changetype(padString), padSize, repeatCount);\n memory.copy(out + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out, changetype(padString), prependSize);\n }\n memory.copy(out + prependSize, changetype(this), thisSize);\n return changetype(out); // retains\n }\n\n padEnd(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var appendSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n memory.copy(out, changetype(this), thisSize);\n if (appendSize > padSize) {\n let repeatCount = (appendSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = appendSize - restBase;\n memory.repeat(out + thisSize, changetype(padString), padSize, repeatCount);\n memory.copy(out + thisSize + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out + thisSize, changetype(padString), appendSize);\n }\n return changetype(out); // retains\n }\n\n repeat(count: i32 = 0): String {\n assert(this !== null);\n var length = this.length;\n\n // Most browsers can\'t handle strings 1 << 28 chars or longer\n if (count < 0 || length * count > (1 << 28)) {\n throw new RangeError(E_INVALIDLENGTH);\n }\n\n if (count == 0 || !length) return changetype("");\n if (count == 1) return this;\n var out = __alloc((length * count) << 1, idof());\n memory.repeat(out, changetype(this), length << 1, count);\n return changetype(out); // retains\n }\n\n slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {\n var len = this.length;\n var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len);\n var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);\n len = end - begin;\n if (len <= 0) return changetype("");\n var out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (begin << 1), len << 1);\n return changetype(out); // retains\n }\n\n split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {\n assert(this !== null);\n if (!limit) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n if (separator === null) return [this];\n var length: isize = this.length;\n var sepLen: isize = separator.length;\n if (limit < 0) limit = i32.MAX_VALUE;\n if (!sepLen) {\n if (!length) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n // split by chars\n length = min(length, limit);\n let result = __allocArray(length, alignof(), idof>());\n let resultStart = changetype(result).dataStart;\n for (let i: isize = 0; i < length; ++i) {\n let charStr = __alloc(2, idof());\n store(charStr, load(changetype(this) + (i << 1)));\n store(resultStart + (i << alignof()), charStr); // result[i] = charStr\n if (isManaged()) __retain(charStr);\n }\n return changetype>(result); // retains\n } else if (!length) {\n let result = __allocArray(1, alignof(), idof>());\n store(changetype(result).dataStart, changetype("")); // static ""\n return changetype>(result); // retains\n }\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n var end = 0, start = 0, i = 0;\n while ((end = this.indexOf(separator, start)) != -1) {\n let len = end - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out));\n } else {\n result.push(changetype(""));\n }\n if (++i == limit) return changetype>(result); // retains\n start = end + sepLen;\n }\n if (!start) { // also means: loop above didn\'t do anything\n result.push(this);\n return changetype>(result); // retains\n }\n var len = length - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out)); // retains\n } else {\n result.push(changetype("")); // static ""\n }\n return changetype>(result); // retains\n // releases result\n }\n\n toString(): String {\n return this;\n }\n\n get lengthUTF8(): i32 {\n var len = 1; // null terminated\n var pos: usize = 0;\n var end = this.length;\n while (pos < end) {\n let c = load(changetype(this) + (pos << 1));\n if (c < 128) {\n len += 1; ++pos;\n } else if (c < 2048) {\n len += 2; ++pos;\n } else {\n if (\n (c & 0xFC00) == 0xD800 && pos + 1 < end &&\n (load(changetype(this) + ((pos + 1) << 1)) & 0xFC00) == 0xDC00\n ) {\n len += 4; pos += 2;\n } else {\n len += 3; ++pos;\n }\n }\n }\n return len;\n }\n\n static fromUTF8(ptr: usize, len: usize): String {\n if (len < 1) return changetype("");\n var ptrPos = 0;\n var buf = __alloc(len << 1, 0);\n var bufPos = 0;\n while (ptrPos < len) {\n let cp = load(ptr + ptrPos++);\n if (cp < 128) {\n store(buf + bufPos, cp);\n bufPos += 2;\n } else if (cp > 191 && cp < 224) {\n assert(ptrPos + 1 <= len);\n store(buf + bufPos, (cp & 31) << 6 | load(ptr + ptrPos++) & 63);\n bufPos += 2;\n } else if (cp > 239 && cp < 365) {\n assert(ptrPos + 3 <= len);\n cp = (\n (cp & 7) << 18 |\n (load(ptr + ptrPos++) & 63) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n ) - 0x10000;\n store(buf + bufPos, 0xD800 + (cp >> 10));\n bufPos += 2;\n store(buf + bufPos, 0xDC00 + (cp & 1023));\n bufPos += 2;\n } else {\n assert(ptrPos + 2 <= len);\n store(buf + bufPos,\n (cp & 15) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n );\n bufPos += 2;\n }\n }\n assert(ptrPos == len);\n var out = __alloc(bufPos, idof());\n memory.copy(out, buf, bufPos);\n __free(buf);\n return changetype(out); // retains\n }\n\n toUTF8(): usize {\n var buf = __alloc(this.lengthUTF8, 0);\n var pos: usize = 0;\n var end = this.length;\n var off: usize = 0;\n while (pos < end) {\n let c1 = load(changetype(this) + (pos << 1));\n if (c1 < 128) {\n store(buf + off, c1);\n ++off; ++pos;\n } else if (c1 < 2048) {\n let ptr = buf + off;\n store(ptr, c1 >> 6 | 192);\n store(ptr, c1 & 63 | 128, 1);\n off += 2; ++pos;\n } else {\n let ptr = buf + off;\n if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) {\n let c2 = load(changetype(this) + ((pos + 1) << 1));\n if ((c2 & 0xFC00) == 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n store(ptr, c1 >> 18 | 240);\n store(ptr, c1 >> 12 & 63 | 128, 1);\n store(ptr, c1 >> 6 & 63 | 128, 2);\n store(ptr, c1 & 63 | 128, 3);\n off += 4; pos += 2;\n continue;\n }\n }\n store(ptr, c1 >> 12 | 224);\n store(ptr, c1 >> 6 & 63 | 128, 1);\n store(ptr, c1 & 63 | 128, 2);\n off += 3; ++pos;\n }\n }\n store(buf + off, 0);\n return buf;\n }\n}\n\n// @ts-ignore: nolib\nexport type string = String;\n\nexport function parseInt(str: String, radix: i32 = 0): f64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI32(str: String, radix: i32 = 0): i32 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI64(str: String, radix: i32 = 0): i64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\n// FIXME: naive implementation\nexport function parseFloat(str: String): f64 {\n var len: i32 = str.length;\n if (!len) return NaN;\n\n var ptr = changetype(str);\n var code = load(ptr);\n\n // determine sign\n var sign: f64;\n if (code == CharCode.MINUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = 1;\n } else {\n sign = 1;\n }\n\n // calculate value\n var num: f64 = 0;\n while (len--) {\n code = load(ptr);\n if (code == CharCode.DOT) {\n ptr += 2;\n let fac: f64 = 0.1; // precision :(\n while (len--) {\n code = load(ptr);\n if (code == CharCode.E || code == CharCode.e) {\n assert(false); // TODO\n }\n code -= CharCode._0;\n if (code > 9) break;\n num += code * fac;\n fac *= 0.1;\n ptr += 2;\n }\n break;\n }\n code -= CharCode._0;\n if (code >= 10) break;\n num = (num * 10) + code;\n ptr += 2;\n }\n return sign * num;\n}\n',symbol:'import { Map } from "./map";\n\n// @ts-ignore: decorator\n@lazy\nvar stringToId: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar idToString: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar nextId: usize = 12; // Symbol.unscopables + 1\n\n@unmanaged @sealed abstract class _Symbol {\n\n // TODO: all of the following default symbols are unused currently yet add to\n // binary size if #toString becomes compiled. Ultimately we\'ll most likely want\n // to remove the unsupported ones and only keep what\'s actually supported.\n\n // @ts-ignore: decorator\n @lazy\n static readonly hasInstance: symbol = changetype(1);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isConcatSpreadable: symbol = changetype(2);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isRegExp: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly iterator: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly match: symbol = changetype(4);\n\n // @ts-ignore: decorator\n @lazy\n static readonly replace: symbol = changetype(5);\n\n // @ts-ignore: decorator\n @lazy\n static readonly search: symbol = changetype(6);\n\n // @ts-ignore: decorator\n @lazy\n static readonly species: symbol = changetype(7);\n\n // @ts-ignore: decorator\n @lazy\n static readonly split: symbol = changetype(8);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toPrimitive: symbol = changetype(9);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toStringTag: symbol = changetype(10);\n\n // @ts-ignore: decorator\n @lazy\n static readonly unscopables: symbol = changetype(11);\n\n static for(key: string): symbol {\n if (!stringToId) { stringToId = new Map(); idToString = new Map(); }\n else if (stringToId.has(key)) return changetype(stringToId.get(key));\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n stringToId.set(key, id);\n idToString.set(id, key);\n return changetype(id);\n }\n\n static keyFor(sym: symbol): string | null {\n return idToString !== null && idToString.has(changetype(sym))\n ? idToString.get(changetype(sym))\n : null;\n }\n\n toString(): string {\n var id = changetype(this);\n var str = "";\n switch (id) {\n case 1: { str = "hasInstance"; break; }\n case 2: { str = "isConcatSpreadable"; break; }\n case 3: { str = "isRegExp"; break; }\n case 4: { str = "match"; break; }\n case 5: { str = "replace"; break; }\n case 6: { str = "search"; break; }\n case 7: { str = "species"; break; }\n case 8: { str = "split"; break; }\n case 9: { str = "toPrimitive"; break; }\n case 10: { str = "toStringTag"; break; }\n case 11: { str = "unscopables"; break; }\n default: {\n if (idToString !== null && idToString.has(id)) str = idToString.get(id);\n break;\n }\n }\n return "Symbol(" + str + ")";\n }\n}\n\nexport function Symbol(description: string | null = null): symbol {\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n return changetype(id);\n}\n\nexport type Symbol = _Symbol;\n\n// @ts-ignore: nolib\nexport type symbol = _Symbol;\n',table:'import { E_NOTIMPLEMENTED } from "./util/error";\n\nexport namespace table {\n\n export function copy(dst: u32, src: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function drop(elementIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n}\n',typedarray:'import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { idof } from "./builtins";\nimport { ArrayBufferView } from "./arraybuffer";\n\nexport class Int8Array extends ArrayBufferView {\n [key: number]: i8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i8, b: i8) => i32 = COMPARATOR()): Int8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i8, index: i32, self: Int8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8Array extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8ClampedArray extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8ClampedArray {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8ClampedArray {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int16Array extends ArrayBufferView {\n [key: number]: i16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i16, b: i16) => i32 = COMPARATOR()): Int16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i16, index: i32, self: Int16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint16Array extends ArrayBufferView {\n [key: number]: u16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u16, b: u16) => i32 = COMPARATOR()): Uint16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u16, index: i32, self: Uint16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int32Array extends ArrayBufferView {\n [key: number]: i32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i32, b: i32) => i32 = COMPARATOR()): Int32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i32, index: i32, self: Int32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint32Array extends ArrayBufferView {\n [key: number]: u32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u32, b: u32) => i32 = COMPARATOR()): Uint32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u32, index: i32, self: Uint32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int64Array extends ArrayBufferView {\n [key: number]: i64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i64, b: i64) => i32 = COMPARATOR()): Int64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i64, index: i32, self: Int64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint64Array extends ArrayBufferView {\n [key: number]: u64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u64, b: u64) => i32 = COMPARATOR()): Uint64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u64, index: i32, self: Uint64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float32Array extends ArrayBufferView {\n [key: number]: f32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f32, b: f32) => i32 = COMPARATOR()): Float32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f32, index: i32, self: Float32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float64Array extends ArrayBufferView {\n [key: number]: f64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f64, b: f64) => i32 = COMPARATOR()): Float64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f64, index: i32, self: Float64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FILL(\n array: TArray,\n value: native,\n start: i32,\n end: i32\n): TArray {\n var dataStart = array.dataStart;\n var length = array.length;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) memory.fill(dataStart + start, value, (end - start));\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SORT(\n array: TArray,\n comparator: (a: T, b: T) => i32\n): TArray {\n var length = array.length;\n if (length <= 1) return array;\n var base = array.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b\n store(base, a); // arr[0] = a\n }\n return array;\n }\n SORT_IMPL(base, length, comparator);\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SUBARRAY(\n array: TArray,\n begin: i32,\n end: i32\n): TArray {\n var len = array.length;\n begin = begin < 0 ? max(len + begin, 0) : min(begin, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\n end = max(end, begin);\n var out = changetype(__alloc(offsetof(), idof())); // retains\n out.data = array.data; // retains\n out.dataStart = array.dataStart + (begin << alignof());\n out.dataLength = (end - begin) << alignof();\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE_RIGHT(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = array.length - 1; i >= 0; i--) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction MAP(\n array: TArray,\n callbackfn: (value: T, index: i32, self: TArray) => T,\n): TArray {\n var length = array.length;\n var dataStart = array.dataStart;\n var out = instantiate(length);\n var outDataStart = out.dataStart;\n for (let i = 0; i < length; i++) {\n store(\n outDataStart + (i << alignof()),\n callbackfn(load(dataStart + (i << alignof())), i, array)\n );\n }\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FIND_INDEX(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): i32 {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return i;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SOME(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return true;\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction EVERY(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) continue;\n return false;\n }\n return true;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FOREACH(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => void,\n): void {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n callbackfn(load(dataStart + (i << alignof())), i, array);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function REVERSE(array: TArray): TArray {\n var dataStart = array.dataStart;\n for (let front = 0, back = array.length - 1; front < back; ++front, --back) {\n let frontPtr = dataStart + (front << alignof());\n let backPtr = dataStart + (back << alignof());\n let temp = load(frontPtr);\n store(frontPtr, load(backPtr));\n store(backPtr, temp);\n }\n return array;\n}\n',"util/error":'// Common error messages for use accross the standard library. Keeping error messages compact\n// and reusing them where possible ensures minimal static data in binaries.\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INDEXOUTOFRANGE: string = "Index out of range";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INVALIDLENGTH: string = "Invalid length";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_EMPTYARRAY: string = "Array is empty";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_HOLEYARRAY: string = "Element type must be nullable if array is holey";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_NOTIMPLEMENTED: string = "Not implemented";\n',"util/hash":"// @ts-ignore: decorator\n@inline\nexport function HASH(key: T): u32 {\n if (isString()) {\n return hashStr(changetype(key));\n } else if (isReference()) {\n if (sizeof() == 4) return hash32(changetype(key));\n if (sizeof() == 8) return hash64(changetype(key));\n } else if (isFloat()) {\n if (sizeof() == 4) return hash32(reinterpret(f32(key)));\n if (sizeof() == 8) return hash64(reinterpret(f64(key)));\n } else {\n if (sizeof() == 1) return hash8 (u32(key));\n if (sizeof() == 2) return hash16(u32(key));\n if (sizeof() == 4) return hash32(u32(key));\n if (sizeof() == 8) return hash64(u64(key));\n }\n return unreachable();\n}\n\n// FNV-1a 32-bit as a starting point, see: http://isthe.com/chongo/tech/comp/fnv/\n\n// @ts-ignore: decorator\n@inline\nconst FNV_OFFSET: u32 = 2166136261;\n\n// @ts-ignore: decorator\n@inline\nconst FNV_PRIME: u32 = 16777619;\n\nfunction hash8(key: u32): u32 {\n return (FNV_OFFSET ^ key) * FNV_PRIME;\n}\n\nfunction hash16(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 8 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash32(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash64(key: u64): u32 {\n var l = key;\n var h = (key >>> 32);\n var v = FNV_OFFSET;\n v = (v ^ ( l & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( l >> 24 )) * FNV_PRIME;\n v = (v ^ ( h & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( h >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hashStr(key: string): u32 {\n var v = FNV_OFFSET;\n if (key !== null) {\n for (let i: usize = 0, k: usize = key.length << 1; i < k; ++i) {\n v = (v ^ load(changetype(key) + i)) * FNV_PRIME;\n }\n }\n return v;\n}\n","util/memory":"export function memcpy(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memcpy.c\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n let w: u32, x: u32;\n\n // copy 1 byte each until src is aligned to 4 bytes\n while (n && (src & 3)) {\n store(dest++, load(src++));\n n--;\n }\n\n // if dst is aligned to 4 bytes as well, copy 4 bytes each\n if ((dest & 3) == 0) {\n while (n >= 16) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n store(dest + 8, load(src + 8));\n store(dest + 12, load(src + 12));\n src += 16; dest += 16; n -= 16;\n }\n if (n & 8) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n dest += 8; src += 8;\n }\n if (n & 4) {\n store(dest, load(src));\n dest += 4; src += 4;\n }\n if (n & 2) { // drop to 2 bytes each\n store(dest, load(src));\n dest += 2; src += 2;\n }\n if (n & 1) { // drop to 1 byte\n store(dest++, load(src++));\n }\n return;\n }\n\n // if dst is not aligned to 4 bytes, use alternating shifts to copy 4 bytes each\n // doing shifts if faster when copying enough bytes (here: 32 or more)\n if (n >= 32) {\n switch (dest & 3) {\n // known to be != 0\n case 1: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 3;\n while (n >= 17) {\n x = load(src + 1);\n store(dest, w >> 24 | x << 8);\n w = load(src + 5);\n store(dest + 4, x >> 24 | w << 8);\n x = load(src + 9);\n store(dest + 8, w >> 24 | x << 8);\n w = load(src + 13);\n store(dest + 12, x >> 24 | w << 8);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 2: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 2;\n while (n >= 18) {\n x = load(src + 2);\n store(dest, w >> 16 | x << 16);\n w = load(src + 6);\n store(dest + 4, x >> 16 | w << 16);\n x = load(src + 10);\n store(dest + 8, w >> 16 | x << 16);\n w = load(src + 14);\n store(dest + 12, x >> 16 | w << 16);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 3: {\n w = load(src);\n store(dest++, load(src++));\n n -= 1;\n while (n >= 19) {\n x = load(src + 3);\n store(dest, w >> 8 | x << 24);\n w = load(src + 7);\n store(dest + 4, x >> 8 | w << 24);\n x = load(src + 11);\n store(dest + 8, w >> 8 | x << 24);\n w = load(src + 15);\n store(dest + 12, x >> 8 | w << 24);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n }\n }\n\n // copy remaining bytes one by one\n if (n & 16) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 8) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 4) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 2) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 1) {\n store(dest++, load(src++));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memmove(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memmove.c\n if (dest === src) return;\n if (ASC_SHRINK_LEVEL < 1) {\n if (src + n <= dest || dest + n <= src) {\n memcpy(dest, src, n);\n return;\n }\n }\n if (dest < src) {\n if ((src & 7) == (dest & 7)) {\n while (dest & 7) {\n if (!n) return;\n --n;\n store(dest++, load(src++));\n }\n while (n >= 8) {\n store(dest, load(src));\n n -= 8;\n dest += 8;\n src += 8;\n }\n }\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n if ((src & 7) == (dest & 7)) {\n while ((dest + n) & 7) {\n if (!n) return;\n store(dest + --n, load(src + n));\n }\n while (n >= 8) {\n n -= 8;\n store(dest + n, load(src + n));\n }\n }\n while (n) {\n store(dest + --n, load(src + n));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/string/memset\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, c);\n --n;\n }\n } else {\n // fill head and tail with minimal branching\n if (!n) return;\n store(dest, c);\n store(dest + n - 1, c);\n if (n <= 2) return;\n\n store(dest + 1, c);\n store(dest + 2, c);\n store(dest + n - 2, c);\n store(dest + n - 3, c);\n if (n <= 6) return;\n store(dest + 3, c);\n store(dest + n - 4, c);\n if (n <= 8) return;\n\n // advance pointer to align it at 4-byte boundary\n let k: usize = -dest & 3;\n dest += k;\n n -= k;\n n &= -4;\n\n let c32: u32 = -1 / 255 * c;\n\n // fill head/tail up to 28 bytes each in preparation\n store(dest, c32);\n store(dest + n - 4, c32);\n if (n <= 8) return;\n store(dest + 4, c32);\n store(dest + 8, c32);\n store(dest + n - 12, c32);\n store(dest + n - 8, c32);\n if (n <= 24) return;\n store(dest + 12, c32);\n store(dest + 16, c32);\n store(dest + 20, c32);\n store(dest + 24, c32);\n store(dest + n - 28, c32);\n store(dest + n - 24, c32);\n store(dest + n - 20, c32);\n store(dest + n - 16, c32);\n\n // align to a multiple of 8\n k = 24 + (dest & 4);\n dest += k;\n n -= k;\n\n // copy 32 bytes each\n let c64: u64 = c32 | (c32 << 32);\n while (n >= 32) {\n store(dest, c64);\n store(dest + 8, c64);\n store(dest + 16, c64);\n store(dest + 24, c64);\n n -= 32;\n dest += 32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memcmp(vl: usize, vr: usize, n: usize): i32 { // see: musl/src/string/memcmp.c\n if (vl == vr) return 0;\n while (n != 0 && load(vl) == load(vr)) {\n n--; vl++; vr++;\n }\n return n ? load(vl) - load(vr) : 0;\n}\n","util/number":'/// \n\nimport { idof } from "../builtins";\nimport { CharCode } from "./string";\nimport { ArrayBufferView } from "../arraybuffer";\n\n// @ts-ignore: decorator\n@inline\nexport const MAX_DOUBLE_LENGTH = 28;\n\n// @ts-ignore: decorator\n@lazy @inline\nconst POWERS10: u32[] = [\n 1,\n 10,\n 100,\n 1000,\n 10000,\n 100000,\n 1000000,\n 10000000,\n 100000000,\n 1000000000\n];\n\n/*\n Lookup table for pairwise char codes in range [0-99]\n\n "00", "01", "02", "03", "04", "05", "06", "07", "08", "09",\n "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",\n "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",\n "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",\n "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",\n "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",\n "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",\n "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",\n "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",\n "90", "91", "92", "93", "94", "95", "96", "97", "98", "99"\n*/\n// @ts-ignore: decorator\n@lazy @inline\nconst DIGITS: u32[] = [\n 0x00300030, 0x00310030, 0x00320030, 0x00330030, 0x00340030,\n 0x00350030, 0x00360030, 0x00370030, 0x00380030, 0x00390030,\n 0x00300031, 0x00310031, 0x00320031, 0x00330031, 0x00340031,\n 0x00350031, 0x00360031, 0x00370031, 0x00380031, 0x00390031,\n 0x00300032, 0x00310032, 0x00320032, 0x00330032, 0x00340032,\n 0x00350032, 0x00360032, 0x00370032, 0x00380032, 0x00390032,\n 0x00300033, 0x00310033, 0x00320033, 0x00330033, 0x00340033,\n 0x00350033, 0x00360033, 0x00370033, 0x00380033, 0x00390033,\n 0x00300034, 0x00310034, 0x00320034, 0x00330034, 0x00340034,\n 0x00350034, 0x00360034, 0x00370034, 0x00380034, 0x00390034,\n 0x00300035, 0x00310035, 0x00320035, 0x00330035, 0x00340035,\n 0x00350035, 0x00360035, 0x00370035, 0x00380035, 0x00390035,\n 0x00300036, 0x00310036, 0x00320036, 0x00330036, 0x00340036,\n 0x00350036, 0x00360036, 0x00370036, 0x00380036, 0x00390036,\n 0x00300037, 0x00310037, 0x00320037, 0x00330037, 0x00340037,\n 0x00350037, 0x00360037, 0x00370037, 0x00380037, 0x00390037,\n 0x00300038, 0x00310038, 0x00320038, 0x00330038, 0x00340038,\n 0x00350038, 0x00360038, 0x00370038, 0x00380038, 0x00390038,\n 0x00300039, 0x00310039, 0x00320039, 0x00330039, 0x00340039,\n 0x00350039, 0x00360039, 0x00370039, 0x00380039, 0x00390039\n];\n\n// @ts-ignore: decorator\n@lazy @inline\nconst EXP_POWERS: i16[] = [\n -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980,\n -954, -927, -901, -874, -847, -821, -794, -768, -741, -715,\n -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,\n -422, -396, -369, -343, -316, -289, -263, -236, -210, -183,\n -157, -130, -103, -77, -50, -24, 3, 30, 56, 83,\n 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,\n 375, 402, 428, 455, 481, 508, 534, 561, 588, 614,\n 641, 667, 694, 720, 747, 774, 800, 827, 853, 880,\n 907, 933, 960, 986, 1013, 1039, 1066\n];\n\n// 1e-348, 1e-340, ..., 1e340\n// @ts-ignore: decorator\n@lazy @inline\nconst FRC_POWERS: u64[] = [\n 0xFA8FD5A0081C0288, 0xBAAEE17FA23EBF76, 0x8B16FB203055AC76, 0xCF42894A5DCE35EA,\n 0x9A6BB0AA55653B2D, 0xE61ACF033D1A45DF, 0xAB70FE17C79AC6CA, 0xFF77B1FCBEBCDC4F,\n 0xBE5691EF416BD60C, 0x8DD01FAD907FFC3C, 0xD3515C2831559A83, 0x9D71AC8FADA6C9B5,\n 0xEA9C227723EE8BCB, 0xAECC49914078536D, 0x823C12795DB6CE57, 0xC21094364DFB5637,\n 0x9096EA6F3848984F, 0xD77485CB25823AC7, 0xA086CFCD97BF97F4, 0xEF340A98172AACE5,\n 0xB23867FB2A35B28E, 0x84C8D4DFD2C63F3B, 0xC5DD44271AD3CDBA, 0x936B9FCEBB25C996,\n 0xDBAC6C247D62A584, 0xA3AB66580D5FDAF6, 0xF3E2F893DEC3F126, 0xB5B5ADA8AAFF80B8,\n 0x87625F056C7C4A8B, 0xC9BCFF6034C13053, 0x964E858C91BA2655, 0xDFF9772470297EBD,\n 0xA6DFBD9FB8E5B88F, 0xF8A95FCF88747D94, 0xB94470938FA89BCF, 0x8A08F0F8BF0F156B,\n 0xCDB02555653131B6, 0x993FE2C6D07B7FAC, 0xE45C10C42A2B3B06, 0xAA242499697392D3,\n 0xFD87B5F28300CA0E, 0xBCE5086492111AEB, 0x8CBCCC096F5088CC, 0xD1B71758E219652C,\n 0x9C40000000000000, 0xE8D4A51000000000, 0xAD78EBC5AC620000, 0x813F3978F8940984,\n 0xC097CE7BC90715B3, 0x8F7E32CE7BEA5C70, 0xD5D238A4ABE98068, 0x9F4F2726179A2245,\n 0xED63A231D4C4FB27, 0xB0DE65388CC8ADA8, 0x83C7088E1AAB65DB, 0xC45D1DF942711D9A,\n 0x924D692CA61BE758, 0xDA01EE641A708DEA, 0xA26DA3999AEF774A, 0xF209787BB47D6B85,\n 0xB454E4A179DD1877, 0x865B86925B9BC5C2, 0xC83553C5C8965D3D, 0x952AB45CFA97A0B3,\n 0xDE469FBD99A05FE3, 0xA59BC234DB398C25, 0xF6C69A72A3989F5C, 0xB7DCBF5354E9BECE,\n 0x88FCF317F22241E2, 0xCC20CE9BD35C78A5, 0x98165AF37B2153DF, 0xE2A0B5DC971F303A,\n 0xA8D9D1535CE3B396, 0xFB9B7CD9A4A7443C, 0xBB764C4CA7A44410, 0x8BAB8EEFB6409C1A,\n 0xD01FEF10A657842C, 0x9B10A4E5E9913129, 0xE7109BFBA19C0C9D, 0xAC2820D9623BF429,\n 0x80444B5E7AA7CF85, 0xBF21E44003ACDD2D, 0x8E679C2F5E44FF8F, 0xD433179D9C8CB841,\n 0x9E19DB92B4E31BA9, 0xEB96BF6EBADF77D9, 0xAF87023B9BF0EE6B\n];\n\n// Count number of decimals for u32 values\n// In our case input value always non-zero so we can simplify some parts\nexport function decimalCount32(value: u32): u32 {\n if (value < 100000) {\n if (value < 100) {\n return select(1, 2, value < 10);\n } else {\n let m = select(4, 5, value < 10000);\n return select(3, m, value < 1000);\n }\n } else {\n if (value < 10000000) {\n return select(6, 7, value < 1000000);\n } else {\n let m = select(9, 10, value < 1000000000);\n return select(8, m, value < 100000000);\n }\n }\n}\n\n// Count number of decimals for u64 values\n// In our case input value always greater than 2^32-1 so we can skip some parts\nexport function decimalCount64(value: u64): u32 {\n if (value < 1000000000000000) {\n if (value < 1000000000000) {\n return select(11, 12, value < 100000000000);\n } else {\n let m = select(14, 15, value < 100000000000000);\n return select(13, m, value < 10000000000000);\n }\n } else {\n if (value < 100000000000000000) {\n return select(16, 17, value < 10000000000000000);\n } else {\n let m = select(19, 20, value < 10000000000000000000);\n return select(18, m, value < 1000000000000000000);\n }\n }\n}\n\nfunction utoa32_lut(buffer: usize, num: u32, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 10000) {\n // in most VMs i32/u32 div and modulo by constant can be shared and simplificate\n let t = num / 10000;\n let r = num % 10000;\n num = t;\n\n let d1 = r / 100;\n let d2 = r % 100;\n\n let digits1 = load(lut + (d1 << alignof()));\n let digits2 = load(lut + (d2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n if (num >= 100) {\n let t = num / 100;\n let d1 = num % 100;\n num = t;\n offset -= 2;\n let digits = load(lut + (d1 << alignof()));\n store(buffer + (offset << 1), digits);\n }\n\n if (num >= 10) {\n offset -= 2;\n let digits = load(lut + (num << alignof()));\n store(buffer + (offset << 1), digits);\n } else {\n offset -= 1;\n let digit = CharCode._0 + num;\n store(buffer + (offset << 1), digit);\n }\n}\n\nfunction utoa64_lut(buffer: usize, num: u64, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 100000000) {\n let t = num / 100000000;\n let r = (num - t * 100000000);\n num = t;\n\n let b = r / 10000;\n let c = r % 10000;\n\n let b1 = b / 100;\n let b2 = b % 100;\n let c1 = c / 100;\n let c2 = c % 100;\n\n let digits1 = load(lut + (c1 << alignof()));\n let digits2 = load(lut + (c2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n\n digits1 = load(lut + (b1 << alignof()));\n digits2 = load(lut + (b2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n utoa32_lut(buffer, num, offset);\n}\n\nfunction utoa_simple(buffer: usize, num: T, offset: usize): void {\n do {\n let t = num / 10;\n let r = (num % 10);\n num = changetype(t);\n offset -= 1;\n store(buffer + (offset << 1), CharCode._0 + r);\n } while (num);\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa32_core(buffer: usize, num: u32, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa32_lut(buffer, num, offset);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa64_core(buffer: usize, num: u64, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa64_lut(buffer, num, offset);\n }\n}\n\nexport function utoa32(value: u32): String {\n if (!value) return "0";\n\n var decimals = decimalCount32(value);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n return changetype(out); // retains\n}\n\nexport function itoa32(value: i32): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var decimals = decimalCount32(value) + u32(sign);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n if (sign) store(out, CharCode.MINUS);\n return changetype(out); // retains\n}\n\nexport function utoa64(value: u64): String {\n if (!value) return "0";\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n return changetype(out); // retains\n}\n\nexport function itoa64(value: i64): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n if (sign) store(out, CharCode.MINUS);\n\n return changetype(out); // retains\n}\n\nexport function itoa(value: T): String {\n if (!isInteger()) ERROR("integer type expected");\n if (isSigned()) {\n if (sizeof() <= 4) {\n return itoa32(value);\n } else {\n return itoa64(value);\n }\n } else {\n if (sizeof() <= 4) {\n return utoa32(value);\n } else {\n return utoa64(value);\n }\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar _K: i32 = 0;\n\n// // @ts-ignore: decorator\n// @lazy\n// var _frc: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp: i32 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_minus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_plus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_pow: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp_pow: i32 = 0;\n\n// @ts-ignore: decorator\n@inline\nfunction umul64f(u: u64, v: u64): u64 {\n var u0 = u & 0xFFFFFFFF;\n var v0 = v & 0xFFFFFFFF;\n\n var u1 = u >> 32;\n var v1 = v >> 32;\n\n var l = u0 * v0;\n var t = u1 * v0 + (l >> 32);\n var w = u0 * v1 + (t & 0xFFFFFFFF);\n\n w += 0x7FFFFFFF; // rounding\n\n t >>= 32;\n w >>= 32;\n\n return u1 * v1 + t + w;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction umul64e(e1: i32, e2: i32): i32 {\n return e1 + e2 + 64; // where 64 is significand size\n}\n\n// @ts-ignore: decorator\n@inline\nfunction normalizedBoundaries(f: u64, e: i32): void {\n var frc = (f << 1) + 1;\n var exp = e - 1;\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var m = 1 + i32(f == 0x0010000000000000);\n\n _frc_plus = frc;\n _frc_minus = ((f << m) - 1) << e - m - exp;\n _exp = exp;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisuRound(buffer: usize, len: i32, delta: u64, rest: u64, ten_kappa: u64, wp_w: u64): void {\n var lastp = buffer + ((len - 1) << 1);\n var digit = load(lastp);\n while (\n rest < wp_w &&\n delta - rest >= ten_kappa && (\n rest + ten_kappa < wp_w ||\n wp_w - rest > rest + ten_kappa - wp_w\n )\n ) {\n --digit;\n rest += ten_kappa;\n }\n store(lastp, digit);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction getCachedPower(minExp: i32): void {\n const c = reinterpret(0x3FD34413509F79FE); // 1 / lg(10) = 0.30102999566398114\n var dk = (-61 - minExp) * c + 347;\t // dk must be positive, so can do ceiling in positive\n var k = dk;\n k += i32(k != dk); // conversion with ceil\n\n var index = (k >> 3) + 1;\n _K = 348 - (index << 3);\t// decimal exponent no need lookup table\n _frc_pow = unchecked(FRC_POWERS[index]);\n _exp_pow = unchecked(EXP_POWERS[index]);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisu2(value: f64, buffer: usize, sign: i32): i32 {\n\n // frexp routine\n var uv = reinterpret(value);\n var exp = ((uv & 0x7FF0000000000000) >>> 52);\n var sid = uv & 0x000FFFFFFFFFFFFF;\n var frc = (u64(exp != 0) << 52) + sid;\n exp = select(exp, 1, exp != 0) - (0x3FF + 52);\n\n normalizedBoundaries(frc, exp);\n getCachedPower(_exp);\n\n // normalize\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var frc_pow = _frc_pow;\n var exp_pow = _exp_pow;\n\n var w_frc = umul64f(frc, frc_pow);\n var w_exp = umul64e(exp, exp_pow);\n\n var wp_frc = umul64f(_frc_plus, frc_pow) - 1;\n var wp_exp = umul64e(_exp, exp_pow);\n\n var wm_frc = umul64f(_frc_minus, frc_pow) + 1;\n var delta = wp_frc - wm_frc;\n\n return genDigits(buffer, w_frc, w_exp, wp_frc, wp_exp, delta, sign);\n}\n\nfunction genDigits(buffer: usize, w_frc: u64, w_exp: i32, mp_frc: u64, mp_exp: i32, delta: u64, sign: i32): i32 {\n var one_exp = -mp_exp;\n var one_frc = (1) << one_exp;\n var mask = one_frc - 1;\n\n var wp_w_frc = mp_frc - w_frc;\n var wp_w_exp = mp_exp;\n\n var p1 = (mp_frc >> one_exp);\n var p2 = mp_frc & mask;\n\n var kappa = decimalCount32(p1);\n var len = sign;\n\n var lut = changetype(POWERS10).dataStart;\n\n while (kappa > 0) {\n let d: u32;\n switch (kappa) {\n case 10: { d = p1 / 1000000000; p1 %= 1000000000; break; }\n case 9: { d = p1 / 100000000; p1 %= 100000000; break; }\n case 8: { d = p1 / 10000000; p1 %= 10000000; break; }\n case 7: { d = p1 / 1000000; p1 %= 1000000; break; }\n case 6: { d = p1 / 100000; p1 %= 100000; break; }\n case 5: { d = p1 / 10000; p1 %= 10000; break; }\n case 4: { d = p1 / 1000; p1 %= 1000; break; }\n case 3: { d = p1 / 100; p1 %= 100; break; }\n case 2: { d = p1 / 10; p1 %= 10; break; }\n case 1: { d = p1; p1 = 0; break; }\n default: { d = 0; break; }\n }\n\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n --kappa;\n let tmp = ((p1) << one_exp) + p2;\n if (tmp <= delta) {\n _K += kappa;\n grisuRound(buffer, len, delta, tmp, load(lut + (kappa << alignof())) << one_exp, wp_w_frc);\n return len;\n }\n }\n\n while (1) {\n p2 *= 10;\n delta *= 10;\n\n let d = p2 >> one_exp;\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n p2 &= mask;\n --kappa;\n if (p2 < delta) {\n _K += kappa;\n wp_w_frc *= load(lut + (-kappa << alignof()));\n grisuRound(buffer, len, delta, p2, one_frc, wp_w_frc);\n return len;\n }\n }\n\n return len;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction genExponent(buffer: usize, k: i32): i32 {\n var sign = k < 0;\n if (sign) k = -k;\n var decimals = decimalCount32(k) + 1;\n utoa32_core(buffer, k, decimals);\n store(buffer, select(CharCode.MINUS, CharCode.PLUS, sign));\n return decimals;\n}\n\nfunction prettify(buffer: usize, length: i32, k: i32): i32 {\n if (!k) {\n store(buffer + (length << 1), CharCode.DOT | (CharCode._0 << 16));\n return length + 2;\n }\n\n var kk = length + k;\n if (length <= kk && kk <= 21) {\n // 1234e7 -> 12340000000\n for (let i = length; i < kk; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n store(buffer + (kk << 1), CharCode.DOT | (CharCode._0 << 16));\n return kk + 2;\n } else if (kk > 0 && kk <= 21) {\n // 1234e-2 -> 12.34\n let ptr = buffer + (kk << 1);\n memory.copy(\n ptr + 2,\n ptr,\n -k << 1\n );\n store(buffer + (kk << 1), CharCode.DOT);\n return length + 1;\n } else if (-6 < kk && kk <= 0) {\n // 1234e-6 -> 0.001234\n let offset = 2 - kk;\n memory.copy(\n buffer + (offset << 1),\n buffer,\n length << 1\n );\n store(buffer, CharCode._0 | (CharCode.DOT << 16));\n for (let i = 2; i < offset; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n return length + offset;\n } else if (length == 1) {\n // 1e30\n store(buffer, CharCode.e, 2);\n length = genExponent(buffer + 4, kk - 1);\n return length + 2;\n } else {\n let len = length << 1;\n memory.copy(\n buffer + 4,\n buffer + 2,\n len - 2\n );\n store(buffer, CharCode.DOT, 2);\n store(buffer + len, CharCode.e, 2);\n length += genExponent(buffer + len + 4, kk - 1);\n return length + 2;\n }\n}\n\nexport function dtoa_core(buffer: usize, value: f64): i32 {\n var sign = i32(value < 0);\n if (sign) {\n value = -value;\n store(buffer, CharCode.MINUS);\n }\n // assert(value > 0 && value <= 1.7976931348623157e308);\n var len = grisu2(value, buffer, sign);\n len = prettify(buffer + (sign << 1), len - sign, _K);\n return len + sign;\n}\n\nexport function dtoa(value: f64): String {\n if (value == 0) return "0.0";\n if (!isFinite(value)) {\n if (isNaN(value)) return "NaN";\n return select("-Infinity", "Infinity", value < 0);\n }\n var buffer = __alloc(MAX_DOUBLE_LENGTH << 1, idof());\n var length = dtoa_core(buffer, value);\n if (length == MAX_DOUBLE_LENGTH) return changetype(buffer);\n var result = changetype(buffer).substring(0, length);\n __free(buffer);\n return result;\n}\n\nexport function itoa_stream(buffer: usize, offset: usize, value: T): u32 {\n buffer += (offset << 1);\n if (!value) {\n store(buffer, CharCode._0);\n return 1;\n }\n var decimals: u32 = 0;\n if (isSigned()) {\n let sign = i32(value < 0);\n if (sign) value = changetype(-value);\n if (sizeof() <= 4) {\n decimals = decimalCount32(value) + sign;\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32) + sign;\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value) + sign;\n utoa64_core(buffer, value, decimals);\n }\n }\n if (sign) store(buffer, CharCode.MINUS);\n } else {\n if (sizeof() <= 4) {\n decimals = decimalCount32(value);\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32);\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value);\n utoa64_core(buffer, value, decimals);\n }\n }\n }\n return decimals;\n}\n\nexport function dtoa_stream(buffer: usize, offset: usize, value: f64): u32 {\n buffer += (offset << 1);\n if (value == 0.0) {\n store(buffer, CharCode._0);\n store(buffer, CharCode.DOT, 2);\n store(buffer, CharCode._0, 4);\n return 3;\n }\n if (!isFinite(value)) {\n if (isNaN(value)) {\n store(buffer, CharCode.N);\n store(buffer, CharCode.a, 2);\n store(buffer, CharCode.N, 4);\n return 3;\n } else {\n let sign = i32(value < 0);\n let len = 8 + sign;\n memory.copy(buffer, changetype(select("-Infinity", "Infinity", sign)), len << 1);\n return len;\n }\n }\n return dtoa_core(buffer, value);\n}\n',"util/sort":'import { compareImpl } from "./string";\n\n// @ts-ignore: decorator\n@inline\nexport function COMPARATOR(): (a: T, b: T) => i32 {\n if (isInteger()) {\n if (isSigned() && sizeof() <= 4) {\n return (a: T, b: T): i32 => (i32(a) - i32(b));\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n } else if (isFloat()) {\n if (sizeof() == 4) {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f32(a));\n var ib = reinterpret(f32(b));\n ia ^= (ia >> 31) >>> 1;\n ib ^= (ib >> 31) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n } else {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f64(a));\n var ib = reinterpret(f64(b));\n ia ^= (ia >> 63) >>> 1;\n ib ^= (ib >> 63) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n }\n } else if (isString()) {\n return (a: T, b: T): i32 => {\n if (a === b || a === null || b === null) return 0;\n var alen = changetype(a).length;\n var blen = changetype(b).length;\n if (!alen && !blen) return 0;\n if (!alen) return -1;\n if (!blen) return 1;\n return compareImpl(changetype(a), 0, changetype(b), 0, min(alen, blen));\n };\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function SORT(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n if (isReference()) {\n // TODO replace this to faster stable sort (TimSort) when it implemented\n insertionSort(dataStart, length, comparator);\n } else {\n if (length < 256) {\n insertionSort(dataStart, length, comparator);\n } else {\n weakHeapSort(dataStart, length, comparator);\n }\n }\n}\n\nfunction insertionSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n for (let i = 0; i < length; i++) {\n let a: T = load(dataStart + (i << alignof())); // a = arr[i]\n let j = i - 1;\n while (j >= 0) {\n let b: T = load(dataStart + (j << alignof())); // b = arr[j]\n if (comparator(a, b) < 0) {\n store(dataStart + ((j-- + 1) << alignof()), b); // arr[j + 1] = b\n } else break;\n }\n store(dataStart + ((j + 1) << alignof()), a); // arr[j + 1] = a\n }\n}\n\nfunction weakHeapSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n const shift32 = alignof();\n\n var bitsetSize = (length + 31) >> 5 << shift32;\n var bitset = __alloc(bitsetSize, 0); // indexed in 32-bit chunks below\n memory.fill(bitset, 0, bitsetSize);\n\n // see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf\n\n for (let i = length - 1; i > 0; i--) {\n let j = i;\n while ((j & 1) == (load(bitset + (j >> 6 << shift32)) >> (j >> 1 & 31) & 1)) j >>= 1;\n\n let p = j >> 1;\n let a: T = load(dataStart + (p << alignof())); // a = arr[p]\n let b: T = load(dataStart + (i << alignof())); // b = arr[i]\n if (comparator(a, b) < 0) {\n store(\n bitset + (i >> 5 << shift32),\n load(bitset + (i >> 5 << shift32)) ^ (1 << (i & 31))\n );\n store(dataStart + (i << alignof()), a); // arr[i] = a\n store(dataStart + (p << alignof()), b); // arr[p] = b\n }\n }\n\n for (let i = length - 1; i >= 2; i--) {\n let a: T = load(dataStart); // a = arr[0]\n store(dataStart, load(dataStart + (i << alignof()))); // arr[0] = arr[i]\n store(dataStart + (i << alignof()), a); // arr[i] = a\n\n let x = 1, y: i32;\n while ((y = (x << 1) + ((load(bitset + (x >> 5 << shift32)) >> (x & 31)) & 1)) < i) x = y;\n\n while (x > 0) {\n a = load(dataStart); // a = arr[0]\n let b: T = load(dataStart + (x << alignof())); // b = arr[x]\n\n if (comparator(a, b) < 0) {\n store(\n bitset + (x >> 5 << shift32),\n load(bitset + (x >> 5 << shift32)) ^ (1 << (x & 31))\n );\n store(dataStart + (x << alignof()), a); // arr[x] = a\n store(dataStart, b); // arr[0] = b\n }\n x >>= 1;\n }\n }\n\n __free(bitset);\n\n var t: T = load(dataStart, sizeof()); // t = arr[1]\n store(dataStart, load(dataStart), sizeof()); // arr[1] = arr[0]\n store(dataStart, t); // arr[0] = t\n}\n',"util/string":"export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {\n var result: i32 = 0;\n var ptr1 = changetype(str1) + (index1 << 1);\n var ptr2 = changetype(str2) + (index2 << 1);\n while (len && !(result = load(ptr1) - load(ptr2))) {\n --len, ptr1 += 2, ptr2 += 2;\n }\n return result;\n}\n\n// @ts-ignore: decorator\n@inline\nexport const enum CharCode {\n PLUS = 0x2B,\n MINUS = 0x2D,\n DOT = 0x2E,\n _0 = 0x30,\n _1 = 0x31,\n _2 = 0x32,\n _3 = 0x33,\n _4 = 0x34,\n _5 = 0x35,\n _6 = 0x36,\n _7 = 0x37,\n _8 = 0x38,\n _9 = 0x39,\n A = 0x41,\n B = 0x42,\n E = 0x45,\n N = 0x4E,\n O = 0x4F,\n X = 0x58,\n Z = 0x5a,\n a = 0x61,\n b = 0x62,\n e = 0x65,\n n = 0x6E,\n o = 0x6F,\n x = 0x78,\n z = 0x7A\n}\n\nexport function isWhiteSpaceOrLineTerminator(c: u16): bool {\n switch (c) {\n case 9: // \n case 10: // \n case 13: // \n case 11: // \n case 12: // \n case 32: // \n case 160: // \n case 8232: // \n case 8233: // \n case 65279: return true; // \n default: return false;\n }\n}\n\n/** Parses a string to an integer (usually), using the specified radix. */\nexport function parse(str: string, radix: i32 = 0): T {\n var len: i32 = str.length;\n // @ts-ignore: cast\n if (!len) return NaN;\n\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr);\n\n // determine sign\n var sign: T;\n if (code == CharCode.MINUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = -1;\n } else if (code == CharCode.PLUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = 1;\n } else {\n // @ts-ignore: type\n sign = 1;\n }\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2)) {\n case CharCode.B:\n case CharCode.b: {\n ptr += 4; len -= 2;\n radix = 2;\n break;\n }\n case CharCode.O:\n case CharCode.o: {\n ptr += 4; len -= 2;\n radix = 8;\n break;\n }\n case CharCode.X:\n case CharCode.x: {\n ptr += 4; len -= 2;\n radix = 16;\n break;\n }\n default: radix = 10;\n }\n } else radix = 10;\n } else if (radix < 2 || radix > 36) {\n // @ts-ignore: cast\n return NaN;\n }\n\n // calculate value\n // @ts-ignore: type\n var num: T = 0;\n while (len--) {\n code = load(ptr);\n if (code >= CharCode._0 && code <= CharCode._9) {\n code -= CharCode._0;\n } else if (code >= CharCode.A && code <= CharCode.Z) {\n code -= CharCode.A - 10;\n } else if (code >= CharCode.a && code <= CharCode.z) {\n code -= CharCode.a - 10;\n } else break;\n if (code >= radix) break;\n // @ts-ignore: type\n num = (num * radix) + code;\n ptr += 2;\n }\n // @ts-ignore: type\n return sign * num;\n}\n",vector:"/** Vector abstraction. */\n@sealed @unmanaged\nexport abstract class V128 {\n}\n"}):(()=>{const n=path.join(".","..","std","assembly"),e=__webpack_require__(!function(){var n=new Error("Cannot find module 'glob'");throw n.code="MODULE_NOT_FOUND",n}()).sync("**/!(*.d).ts",{cwd:n}),t={};return e.forEach(e=>t[e.replace(/\.ts$/,"")]=fs.readFileSync(path.join(n,e),"utf8")),t})(),exports.definitionFiles=exports.isBundle?Object({assembly:'/**\n * Environment definitions for compiling AssemblyScript to WebAssembly using asc.\n * @module std/assembly\n *//***/\n\n/// \n\n// Types\n\n/** An 8-bit signed integer. */\ndeclare type i8 = number;\n/** A 16-bit signed integer. */\ndeclare type i16 = number;\n/** A 32-bit signed integer. */\ndeclare type i32 = number;\n/** A 64-bit signed integer. */\ndeclare type i64 = number;\n/** A 32-bit signed integer when targeting 32-bit WebAssembly or a 64-bit signed integer when targeting 64-bit WebAssembly. */\ndeclare type isize = number;\n/** An 8-bit unsigned integer. */\ndeclare type u8 = number;\n/** A 16-bit unsigned integer. */\ndeclare type u16 = number;\n/** A 32-bit unsigned integer. */\ndeclare type u32 = number;\n/** A 64-bit unsigned integer. */\ndeclare type u64 = number;\n/** A 32-bit unsigned integer when targeting 32-bit WebAssembly or a 64-bit unsigned integer when targeting 64-bit WebAssembly. */\ndeclare type usize = number;\n/** A 1-bit unsigned integer. */\ndeclare type bool = boolean | number;\n/** A 32-bit float. */\ndeclare type f32 = number;\n/** A 64-bit float. */\ndeclare type f64 = number;\n/** A 128-bit vector. */\ndeclare type v128 = object;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n/** Whether the bulk memory feature is enabled. */\ndeclare const ASC_FEATURE_BULK_MEMORY: bool;\n/** Whether the SIMD feature is enabled. */\ndeclare const ASC_FEATURE_SIMD: bool;\n/** Whether the threads feature is enabled. */\ndeclare const ASC_FEATURE_THREADS: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit or 64-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit or 64-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit or 64-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Reinterprets the bits of the specified value as type `T`. Valid reinterpretations are u32/i32 to/from f32 and u64/i64 to/from f64. */\ndeclare function reinterpret(value: number): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Equivalent to dereferncing a pointer in other languages. */\ndeclare function load(ptr: usize, immOffset?: usize, immAlign?: usize): T;\n/** Stores a value of the specified type to memory. Equivalent to dereferencing a pointer in other languages when assigning a value. */\ndeclare function store(ptr: usize, value: any, immOffset?: usize, immAlign?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. Both a statement and an expression of any type. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Heap base offset. */\ndeclare const HEAP_BASE: usize;\n/** Determines the byte size of the specified underlying core type. Compiles to a constant. */\ndeclare function sizeof(): usize;\n/** Determines the alignment (log2) of the specified underlying core type. Compiles to a constant. */\ndeclare function alignof(): usize;\n/** Determines the offset of the specified field within the given class type. Returns the class type\'s end offset if field name has been omitted. Compiles to a constant. */\ndeclare function offsetof(fieldName?: string): usize;\n/** Determines the unique runtime id of a class type. Compiles to a constant. */\ndeclare function idof(): u32;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Emits a `call_indirect` instruction, calling the specified function in the function table by index with the specified arguments. Does result in a runtime error if the arguments do not match the called function. */\ndeclare function call_indirect(target: Function | u32, ...args: any[]): T;\n/** Emits a `call` instruction, calling the specified function in the function table directly with the specified arguments. Function index must be a compile-time constant. */\ndeclare function call_direct(target: Function | u32, ...args: any[]): T;\n/** Instantiates a new instance of `T` using the specified constructor arguments. */\ndeclare function instantiate(...args: any[]): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified type *or* expression is of an integer type and not a reference. Compiles to a constant. */\ndeclare function isInteger(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a float type. Compiles to a constant. */\ndeclare function isFloat(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a boolean type. */\ndeclare function isBoolean(value?: any): value is number;\n/** Tests if the specified type *or* expression can represent negative numbers. Compiles to a constant. */\ndeclare function isSigned(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a reference type. Compiles to a constant. */\ndeclare function isReference(value?: any): value is object | string;\n/** Tests if the specified type *or* expression can be used as a string. Compiles to a constant. */\ndeclare function isString(value?: any): value is string | String;\n/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */\ndeclare function isArray(value?: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */\ndeclare function isArrayLike(value?: any): value is ArrayLike;\n/** Tests if the specified type *or* expression is of a function type. Compiles to a constant. */\ndeclare function isFunction(value?: any): value is (...args: any) => any;\n/** Tests if the specified type *or* expression is of a nullable reference type. Compiles to a constant. */\ndeclare function isNullable(value?: any): bool;\n/** Tests if the specified expression resolves to a defined element. Compiles to a constant. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. Compiles to a constant. */\ndeclare function isConstant(expression: any): bool;\n/** Tests if the specified type *or* expression is of a managed type. Compiles to a constant. */\ndeclare function isManaged(value?: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses an integer string to a 64-bit integer. */\ndeclare function parseI64(str: string, radix?: i32): i64;\n/** Parses a string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Atomic operations. */\ndeclare namespace atomic {\n /** Atomically loads an integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): T;\n /** Atomically stores an integer value to memory. */\n export function store(offset: usize, value: T, immOffset?: usize): void;\n /** Atomically adds an integer value in memory. */\n export function add(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically subtracts an integer value in memory. */\n export function sub(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise AND operation on an integer value in memory. */\n export function and(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise OR operation on an integer value in memory. */\n export function or(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise XOR operation on an integer value in memory. */\n export function xor(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically exchanges an integer value in memory. */\n export function xchg(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically compares and exchanges an integer value in memory if the condition is met. */\n export function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n /** Performs a wait operation on an address in memory suspending this agent if the integer condition is met. */\n export function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n /** Performs a notify operation on an address in memory waking up suspended agents. */\n export function notify(ptr: usize, count: i32): i32;\n}\n\n/** Describes the result of an atomic wait operation. */\ndeclare enum AtomicWaitResult {\n /** Woken by another agent. */\n OK,\n /** Loaded value did not match the expected value. */\n NOT_EQUAL,\n /** Not woken before the timeout expired. */\n TIMED_OUT\n}\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i8;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Loads an 8-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 32-bit integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 32-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 32-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i32;\n /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize): void;\n /** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n /** Atomic 32-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 32-bit integer value in memory. */\n export function add(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts a 32-bit integer value in memory. */\n export function sub(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */\n export function and(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */\n export function or(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */\n export function xor(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 32-bit integer value in memory. */\n export function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 32-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n/** Converts any other numeric value to a 64-bit signed integer. */\ndeclare function i64(value: any): i64;\ndeclare namespace i64 {\n /** Smallest representable value. */\n export const MIN_VALUE: i64;\n /** Largest representable value. */\n export const MAX_VALUE: i64;\n /** Loads an 8-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 64-bit unsigned integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 64-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 64-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i64;\n /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize): void;\n /** Performs a wait operation on a 64-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n /** Atomic 64-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 32-bit values. */\n export namespace rmw32 {\n /** Atomically adds a 32-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 32-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 32-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 32-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 32-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 32-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 32-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 64-bit integer value in memory. */\n export function add(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 64-bit integer value in memory. */\n export function sub(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 64-bit integer value in memory. */\n export function and(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 64-bit integer value in memory. */\n export function or(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 64-bit integer value in memory. */\n export function xor(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 64-bit integer value in memory. */\n export function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 64-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare var isize: typeof i32 | typeof i64;\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): i8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): i8;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): i32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n}\n/** Converts any other numeric value to a 64-bit unsigned integer. */\ndeclare function u64(value: any): i64;\ndeclare namespace u64 {\n /** Smallest representable value. */\n export const MIN_VALUE: u64;\n /** Largest representable value. */\n export const MAX_VALUE: u64;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare var usize: typeof u32 | typeof u64;\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Loads a 32-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n /** Stores a 32-bit float to memory. */\n export function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Loads a 64-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n /** Stores a 64-bit float to memory. */\n export function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function v128(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace v128 {\n /** Creates a 128-bit vector with identical lanes. */\n export function splat(x: T): v128;\n /** Extracts one lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): T;\n /** Replaces one lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: T): v128;\n /** Selects lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n /** Loads a 128-bit vector from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n /** Stores a 128-bit vector to memory. */\n export function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n /** Adds each lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128; // except i64\n /** Divides each lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each lane of a 128-bit vector */\n export function neg(a: v128): v128;\n /** Adds each lane of two 128-bit vectors using saturation. */\n export function add_saturate(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors using saturation. */\n export function sub_saturate(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise right shift on each lane of a 128-bit vector by a scalar. */\n export function shr(a: v128, b: i32): v128;\n /** Performs the bitwise AND operation on each lane of two 128-bit vectors. */\n export function and(a: v128, b: v128): v128;\n /** Performs the bitwise OR operation on each lane of two 128-bit vectors. */\n export function or(a: v128, b: v128): v128;\n /** Performs the bitwise XOR operation on each lane of two 128-bit vectors. */\n export function xor(a: v128, b: v128): v128;\n /** Performs the bitwise NOT operation on each lane of a 128-bit vector. */\n export function not(a: v128): v128;\n /** Selects bits of either 128-bit vector according to the specified mask. */\n export function bitselect(v1: v128, v2: v128, mask: v128): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes the minimum of each lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each lane of a 128-bit vector from integer to floating point. */\n export function convert(a: v128): v128;\n /** Truncates each lane of a 128-bit vector from floating point to integer with saturation. */\n export function trunc(a: v128): v128;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function i8x16(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace i8x16 {\n /** Creates a vector with sixteen identical 8-bit integer lanes. */\n export function splat(x: i8): v128;\n /** Extracts one 8-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i8;\n /** Extracts one 8-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u8;\n /** Replaces one 8-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i8): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 8-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 8-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 8-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 8-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from eight 16-bit integer values. Arguments must be compile-time constants. */\ndeclare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\ndeclare namespace i16x8 {\n /** Creates a vector with eight identical 16-bit integer lanes. */\n export function splat(x: i16): v128;\n /** Extracts one 16-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i16;\n /** Extracts one 16-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u16;\n /** Replaces one 16-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i16): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 16-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 16-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 16-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 16-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit integer values. Arguments must be compile-time constants. */\ndeclare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\ndeclare namespace i32x4 {\n /** Creates a 128-bit vector with four identical 32-bit integer lanes. */\n export function splat(x: i32): v128;\n /** Extracts one 32-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i32;\n /** Replaces one 32-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i32): v128;\n /** Adds each 32-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 32-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 32-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 32-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f32x4_sat(a: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f32x4_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit integer values. Arguments must be compile-time constants. */\ndeclare function i64x2(a: i64, b: i64): v128;\ndeclare namespace i64x2 {\n /** Creates a 128-bit vector with two identical 64-bit integer lanes. */\n export function splat(x: i64): v128;\n /** Extracts one 64-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i64;\n /** Replaces one 64-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i64): v128;\n /** Adds each 64-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 64-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 64-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 64-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Truncates each 64-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f64x2_sat(a: v128): v128;\n /** Truncates each 64-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f64x2_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit float values. Arguments must be compile-time constants. */\ndeclare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\ndeclare namespace f32x4 {\n /** Creates a 128-bit vector with four identical 32-bit float lanes. */\n export function splat(x: f32): v128;\n /** Extracts one 32-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f32;\n /** Replaces one 32-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f32): v128;\n /** Adds each 32-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 32-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 32-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 32-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 32-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 32-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 32-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 32-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i32x4(a: v128): v128;\n /** Converts each 32-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i32x4(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit float values. Arguments must be compile-time constants. */\ndeclare function f64x2(a: f64, b: f64): v128;\ndeclare namespace f64x2 {\n /** Creates a 128-bit vector with two identical 64-bit float lanes. */\n export function splat(x: f64): v128;\n /** Extracts one 64-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f64;\n /** Replaces one 64-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f64): v128;\n /** Adds each 64-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 64-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 64-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 64-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 64-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 64-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 64-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 64-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i64x2(a: v128): v128;\n /** Converts each 64-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i64x2(a: v128): v128;\n}\ndeclare namespace v8x16 {\n /** Selects 8-bit lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8, l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8): v128;\n}\n/** Macro type evaluating to the underlying native WebAssembly type. */\ndeclare type native = T;\n\n/** Pseudo-class representing the backing class of integer types. */\ndeclare class _Integer {\n /** Smallest representable value. */\n static readonly MIN_VALUE: number;\n /** Largest representable value. */\n static readonly MAX_VALUE: number;\n /** Converts a string to an integer of this type. */\n static parseInt(value: string, radix?: number): number;\n /** Converts this integer to a string. */\n toString(): string;\n}\n\n/** Pseudo-class representing the backing class of floating-point types. */\ndeclare class _Float {\n /** Difference between 1 and the smallest representable value greater than 1. */\n static readonly EPSILON: f32 | f64;\n /** Smallest representable value. */\n static readonly MIN_VALUE: f32 | f64;\n /** Largest representable value. */\n static readonly MAX_VALUE: f32 | f64;\n /** Smallest safely representable integer value. */\n static readonly MIN_SAFE_INTEGER: f32 | f64;\n /** Largest safely representable integer value. */\n static readonly MAX_SAFE_INTEGER: f32 | f64;\n /** Value representing positive infinity. */\n static readonly POSITIVE_INFINITY: f32 | f64;\n /** Value representing negative infinity. */\n static readonly NEGATIVE_INFINITY: f32 | f64;\n /** Value representing \'not a number\'. */\n static readonly NaN: f32 | f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n static isNaN(value: f32 | f64): bool;\n /** Returns true if passed value is finite. */\n static isFinite(value: f32 | f64): bool;\n /** Returns true if the value passed is a safe integer. */\n static isSafeInteger(value: f32 | f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n static isInteger(value: f32 | f64): bool;\n /** Converts a string to an integer. */\n static parseInt(value: string, radix?: i32): f32 | f64;\n /** Converts a string to a floating-point number. */\n static parseFloat(value: string): f32 | f64;\n /** Converts this floating-point number to a string. */\n toString(this: f64): string;\n}\n\n/** Backing class of signed 8-bit integers. */\ndeclare const I8: typeof _Integer;\n/** Backing class of signed 16-bit integers. */\ndeclare const I16: typeof _Integer;\n/** Backing class of signed 32-bit integers. */\ndeclare const I32: typeof _Integer;\n/** Backing class of signed 64-bit integers. */\ndeclare const I64: typeof _Integer;\n/** Backing class of signed size integers. */\ndeclare const Isize: typeof _Integer;\n/** Backing class of unsigned 8-bit integers. */\ndeclare const U8: typeof _Integer;\n/** Backing class of unsigned 16-bit integers. */\ndeclare const U16: typeof _Integer;\n/** Backing class of unsigned 32-bit integers. */\ndeclare const U32: typeof _Integer;\n/** Backing class of unsigned 64-bit integers. */\ndeclare const U64: typeof _Integer;\n/** Backing class of unsigned size integers. */\ndeclare const Usize: typeof _Integer;\n/** Backing class of 32-bit floating-point values. */\ndeclare const F32: typeof _Float;\n/** Backing class of 64-bit floating-point values. */\ndeclare const F64: typeof _Float;\n\n// User-defined diagnostic macros\n\n/** Emits a user-defined diagnostic error when encountered. */\ndeclare function ERROR(message?: any): void;\n/** Emits a user-defined diagnostic warning when encountered. */\ndeclare function WARNING(message?: any): void;\n/** Emits a user-defined diagnostic info when encountered. */\ndeclare function INFO(message?: any): void;\n\n// Polyfills\n\n/** Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Whether the memory managed interface is implemented. */\n export const implemented: bool;\n /** Returns the current memory size in units of pages. One page is 64kb. */\n export function size(): i32;\n /** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */\n export function grow(value: i32): i32;\n /** Sets n bytes beginning at the specified destination in memory to the specified byte value. */\n export function fill(dst: usize, value: u8, count: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n export function copy(dst: usize, src: usize, n: usize): void;\n /** Repeats `src` of length `srcLength` `count` times at `dst`. */\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void;\n /** Copies elements from a passive element segment to a table. */\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void;\n /** Prevents further use of a passive element segment. */\n export function drop(segmentIndex: u32): void;\n /** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */\n export function compare(vl: usize, vr: usize, n: usize): i32;\n}\n\n/** Garbage collector operations. */\ndeclare namespace gc {\n /** Whether the garbage collector interface is implemented. */\n export const implemented: bool;\n /** Performs a full garbage collection cycle. */\n export function collect(): void;\n /** Retains a reference, making sure that it doesn\'t become collected. */\n export function retain(ref: usize): void;\n /** Releases a reference, allowing it to become collected. */\n export function release(ref: usize): void;\n}\n\n/** Table operations. */\ndeclare namespace table {\n /** Copies elements from a passive element segment to a table. */\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void;\n /** Prevents further use of a passive element segment. */\n export function drop(elementIndex: u32): void;\n /** Copies elements from one region of a table to another region. */\n export function copy(dest: u32, src: u32, n: u32): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer\'s bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform\'s endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getInt64()` method gets a signed 64-bit integer (long long) at the specified byte offset from the start of the `DataView`. */\n getInt64(byteOffset: i32, littleEndian?: boolean): i64;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `getUint64()` method gets an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the `DataView`. */\n getUint64(byteOffset: i32, littleEndian?: boolean): u64;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setInt64()` method stores a signed 64-bit integer (long long) value at the specified byte offset from the start of the `DataView`. */\n setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** The `setUint64()` method stores an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the `DataView`. */\n setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ninterface ArrayLike {\n length: i32;\n // [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\n/* @internal */\ndeclare abstract class TypedArray implements ArrayBufferView {\n [key: number]: T;\n /** Number of bytes per element. */\n static readonly BYTES_PER_ELEMENT: usize;\n /** Constructs a new typed array. */\n constructor(length: i32);\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n /** The length (in elements). */\n readonly length: i32;\n /** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */\n subarray(begin?: i32, end?: i32): this;\n /** The reduce() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value. This method has the same algorithm as Array.prototype.reduce(). */\n reduce(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The reduceRight() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value, starting from the end of the array. This method has the same algorithm as Array.prototype.reduceRight(). */\n reduceRight(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The some() method tests whether some element in the typed array passes the test implemented by the provided function. This method has the same algorithm as Array.prototype.some().*/\n some(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The map() method creates a new typed array with the results of calling a provided function on every element in this typed array. This method has the same algorithm as Array.prototype.map().*/\n map(callbackfn: (value: T, index: i32, self: this) => T): this;\n /** The sort() method sorts the elements of a typed array numerically in place and returns the typed array. This method has the same algorithm as Array.prototype.sort(), except that sorts the values numerically instead of as strings. TypedArray is one of the typed array types here. */\n sort(callback?: (a: T, b: T) => i32): this;\n /** The fill() method fills all the elements of a typed array from a start index to an end index with a static value. This method has the same algorithm as Array.prototype.fill(). */\n fill(value: T, start?: i32, end?: i32): this;\n /** The findIndex() method returns an index in the typed array, if an element in the typed array satisfies the provided testing function. Otherwise -1 is returned. See also the find() [not implemented] method, which returns the value of a found element in the typed array instead of its index. */\n findIndex(callbackfn: (value: T, index: i32, self: this) => bool): i32;\n /** The every() method tests whether all elements in the typed array pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.every(). */\n every(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The forEach() method executes a provided function once per array element. This method has the same algorithm as Array.prototype.forEach().*/\n forEach(callbackfn: (value: T, index: i32, self: this) => void): void;\n /** The reverse() method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as Array.prototype.reverse(). */\n reverse(): this;\n}\n\n/** An array of twos-complement 8-bit signed integers. */\ndeclare class Int8Array extends TypedArray {}\n/** An array of 8-bit unsigned integers. */\ndeclare class Uint8Array extends TypedArray {}\n/** A clamped array of 8-bit unsigned integers. */\ndeclare class Uint8ClampedArray extends TypedArray {}\n/** An array of twos-complement 16-bit signed integers. */\ndeclare class Int16Array extends TypedArray {}\n/** An array of 16-bit unsigned integers. */\ndeclare class Uint16Array extends TypedArray {}\n/** An array of twos-complement 32-bit signed integers. */\ndeclare class Int32Array extends TypedArray {}\n/** An array of 32-bit unsigned integers. */\ndeclare class Uint32Array extends TypedArray {}\n/** An array of twos-complement 64-bit signed integers. */\ndeclare class Int64Array extends TypedArray {}\n/** An array of 64-bit unsigned integers. */\ndeclare class Uint64Array extends TypedArray {}\n/** An array of 32-bit floating point numbers. */\ndeclare class Float32Array extends TypedArray {}\n/** An array of 64-bit floating point numbers. */\ndeclare class Float64Array extends TypedArray {}\n\n/** Class representing a sequence of values of type `T`. */\ndeclare class Array {\n\n /** Tests if a value is an array. */\n static isArray(value: any): value is Array;\n /** Creates a new array with at least the specified capacity and length zero. */\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. If length is greater than zero and T is a non-nullable reference, use `Array.create` instead.*/\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\n/** Class representing a fixed sequence of values of type `T`. */\ndeclare class FixedArray {\n [key: number]: T;\n readonly length: i32;\n constructor(capacity?: i32);\n}\n\n/** Class representing a sequence of characters. */\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n readonly lengthUTF8: i32;\n\n charAt(index: u32): string;\n charCodeAt(index: u32): u16;\n concat(other: string): string;\n endsWith(other: string): bool;\n indexOf(other: string, fromIndex?: i32): u32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(start: u32, end?: u32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n static fromUTF8(ptr: usize, len: usize): string;\n toUTF8(): usize;\n}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ninterface Boolean {}\ninterface Function {}\ninterface IArguments {}\ninterface Number {}\ninterface Object {}\ninterface RegExp {}\n\ndeclare class Map {\n readonly size: i32;\n has(key: K): bool;\n set(key: K, value: V): void;\n get(key: K): V;\n delete(key: K): bool;\n clear(): void;\n toString(): string;\n}\n\ndeclare class Set {\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\n\ndeclare const Symbol: SymbolConstructor;\n\ninterface IMath {\n /** The base of natural logarithms, e, approximately 2.718. */\n readonly E: T;\n /** The natural logarithm of 2, approximately 0.693. */\n readonly LN2: T;\n /** The natural logarithm of 10, approximately 2.302. */\n readonly LN10: T;\n /** The base 2 logarithm of e, approximately 1.442. */\n readonly LOG2E: T;\n /** The base 10 logarithm of e, approximately 0.434. */\n readonly LOG10E: T;\n /** The ratio of the circumference of a circle to its diameter, approximately 3.14159. */\n readonly PI: T;\n /** The square root of 1/2, approximately 0.707. */\n readonly SQRT1_2: T;\n /** The square root of 2, approximately 1.414. */\n readonly SQRT2: T;\n /** Returns the absolute value of `x`. */\n abs(x: T): T;\n /** Returns the arccosine (in radians) of `x`. */\n acos(x: T): T;\n /** Returns the hyperbolic arc-cosine of `x`. */\n acosh(x: T): T;\n /** Returns the arcsine (in radians) of `x` */\n asin(x: T): T;\n /** Returns the hyperbolic arcsine of `x`. */\n asinh(x: T): T;\n /** Returns the arctangent (in radians) of `x`. */\n atan(x: T): T;\n /** Returns the arctangent of the quotient of its arguments. */\n atan2(y: T, x: T): T;\n /** Returns the hyperbolic arctangent of `x`. */\n atanh(x: T): T;\n /** Returns the cube root of `x`. */\n cbrt(x: T): T;\n /** Returns the smallest integer greater than or equal to `x`. */\n ceil(x: T): T;\n /** Returns the number of leading zero bits in the 32-bit binary representation of `x`. */\n clz32(x: T): T;\n /** Returns the cosine (in radians) of `x`. */\n cos(x: T): T;\n /** Returns the hyperbolic cosine of `x`. */\n cosh(x: T): T;\n /** Returns e to the power of `x`. */\n exp(x: T): T;\n /** Returns e to the power of `x`, minus 1. */\n expm1(x: T): T;\n /** Returns the largest integer less than or equal to `x`. */\n floor(x: T): T;\n /** Returns the nearest 32-bit single precision float representation of `x`. */\n fround(x: T): f32;\n /** Returns the square root of the sum of squares of its arguments. */\n hypot(value1: T, value2: T): T; // TODO: rest\n /** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */\n imul(a: T, b: T): T;\n /** Returns the natural logarithm (base e) of `x`. */\n log(x: T): T;\n /** Returns the base 10 logarithm of `x`. */\n log10(x: T): T;\n /** Returns the natural logarithm (base e) of 1 + `x`. */\n log1p(x: T): T;\n /** Returns the base 2 logarithm of `x`. */\n log2(x: T): T;\n /** Returns the largest-valued number of its arguments. */\n max(value1: T, value2: T): T; // TODO: rest\n /** Returns the lowest-valued number of its arguments. */\n min(value1: T, value2: T): T; // TODO: rest\n /** Returns `base` to the power of `exponent`. */\n pow(base: T, exponent: T): T;\n /** Returns a pseudo-random number in the range from 0.0 inclusive up to but not including 1.0. */\n random(): T;\n /** Returns the value of `x` rounded to the nearest integer. */\n round(x: T): T;\n /** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */\n sign(x: T): T;\n /** Returns whether the sign bit of `x` is set */\n signbit(x: T): bool;\n /** Returns the sine of `x`. */\n sin(x: T): T;\n /** Returns the hyperbolic sine of `x`. */\n sinh(x: T): T;\n /** Returns the square root of `x`. */\n sqrt(x: T): T;\n /** Returns the tangent of `x`. */\n tan(x: T): T;\n /** Returns the hyperbolic tangent of `x`. */\n tanh(x: T): T;\n /** Returns the integer part of `x` by removing any fractional digits. */\n trunc(x: T): T;\n}\n\ninterface INativeMath extends IMath {\n /** Contains sin value produced after Math/Mathf.sincos */\n sincos_sin: T;\n /** Contains cos value produced after Math/Mathf.sincos */\n sincos_cos: T;\n /** Seeds the random number generator. */\n seedRandom(value: i64): void;\n /** Returns the floating-point remainder of `x / y` (rounded towards zero). */\n mod(x: T, y: T): T;\n /** Returns the floating-point remainder of `x / y` (rounded to nearest). */\n rem(x: T, y: T): T;\n /** Returns sin and cos simultaneously for same angle. Results stored to `sincos_s32/64` and `sincos_c32/64` globals */\n sincos(x: T): void;\n}\n\n/** Double precision math imported from JavaScript. */\ndeclare const JSMath: IMath;\n/** Double precision math implemented natively. */\ndeclare const NativeMath: INativeMath;\n/** Single precision math implemented natively. */\ndeclare const NativeMathf: INativeMath;\n/** Alias of {@link NativeMath} or {@link JSMath} respectively. Defaults to `NativeMath`. */\ndeclare const Math: IMath;\n/** Alias of {@link NativeMathf} or {@link JSMath} respectively. Defaults to `NativeMathf`. */\ndeclare const Mathf: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): i64;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): i64;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: i64);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): i64;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: i64): i64;\n}\n\n/** Environmental tracing function for debugging purposes. */\ndeclare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?: f64, a4?: f64): void;\n\n// Decorators\n\ninterface TypedPropertyDescriptor {\n configurable?: boolean;\n enumerable?: boolean;\n writable?: boolean;\n value?: T;\n get?(): T;\n set?(value: T): void;\n}\n\n/** Annotates a method as a binary operator overload for the specified `token`. */\ndeclare function operator(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n) => TypedPropertyDescriptor | void;\n\ndeclare namespace operator {\n /** Annotates a method as a binary operator overload for the specified `token`. */\n export function binary(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n ): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary prefix operator overload for the specified `token`. */\n export function prefix(token: "!" | "~" | "+" | "-" | "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary postfix operator overload for the specified `token`. */\n export function postfix(token: "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n}\n\n/** Annotates an element as a program global. */\ndeclare function global(...args: any[]): any;\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n\n/** Annotates a class as being sealed / non-derivable. */\ndeclare function sealed(constructor: Function): void;\n\n/** Annotates a method, function or constant global as always inlined. */\ndeclare function inline(...args: any[]): any;\n\n/** Annotates a method, function or constant global as unsafe. */\ndeclare function unsafe(...args: any[]): any;\n\n/** Annotates an explicit external name of a function or global. */\ndeclare function external(...args: any[]): any;\n\n/** Annotates a global for lazy compilation. */\ndeclare function lazy(...args: any[]): any;\n\n/** Annotates a function as the explicit start function. */\ndeclare function start(...args: any[]): any;\n',portable:"/**\n * Environment definitions for compiling AssemblyScript to JavaScript using tsc.\n *\n * Note that semantic differences require additional explicit conversions for full compatibility.\n * For example, when casting an i32 to an u8, doing `(someI32 & 0xff)` will yield the same\n * result when compiling to WebAssembly or JS while `someI32` alone does nothing in JS.\n *\n * Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer\n * value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example\n * {@link glue/js/i64} respectively {@link glue/wasm/i64}.\n *\n * @module std/portable\n *//***/\n\n/// \n\n// Types\n\ndeclare type bool = boolean;\ndeclare type i8 = number;\ndeclare type i16 = number;\ndeclare type i32 = number;\ndeclare type isize = number;\ndeclare type u8 = number;\ndeclare type u16 = number;\ndeclare type u32 = number;\ndeclare type usize = number;\ndeclare type f32 = number;\ndeclare type f64 = number;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Type must be `u8`. */\ndeclare function load(ptr: usize, constantOffset?: usize): T;\n/** Stores a value of the specified type to memory. Type must be `u8`. */\ndeclare function store(ptr: usize, value: T, constantOffset?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified value is a valid integer. Can't distinguish an integer from an integral float. */\ndeclare function isInteger(value: any): value is number;\n/** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */\ndeclare function isFloat(value: any): value is number;\n/** Tests if the specified value is of a nullable reference type. */\ndeclare function isNullable(value: any): bool;\n/** Tests if the specified value is of a reference type. */\ndeclare function isReference(value: any): value is object | string;\n/** Tests if the specified value is of a function type */\ndeclare function isFunction(value: any): value is Function;\n/** Tests if the specified value can be used as a string. */\ndeclare function isString(value: any): value is string | String;\n/** Tests if the specified value can be used as an array. */\ndeclare function isArray(value: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. */\ndeclare function isArrayLike(value: any): value is ArrayLike;\n/** Tests if the specified expression resolves to a defined element. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. */\ndeclare function isConstant(expression: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the value. */\ndeclare function assert(isTrueish: T | null, message?: string): T;\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses a floating point string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i16;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare function isize(value: any): isize;\ndeclare namespace isize {\n /** Smallest representable value. */\n export const MIN_VALUE: isize;\n /** Largest representable value. */\n export const MAX_VALUE: isize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): isize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): u8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): u16;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): u32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare function usize(value: any): isize;\ndeclare namespace usize {\n /** Smallest representable value. */\n export const MIN_VALUE: usize;\n /** Largest representable value. */\n export const MAX_VALUE: usize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): usize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f32): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f32): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f32;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f64): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f64;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f64;\n}\n\n// Polyfills\n\n/** [Polyfill] Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** [Polyfill] Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Allocates a chunk of memory of the specified size and returns a pointer to it. */\n function allocate(size: usize): usize;\n /** Disposes a chunk of memory by its pointer. */\n function free(ptr: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n function copy(dst: usize, src: usize, n: usize): void;\n /** Fills size bytes from from the specified destination by same value in memory. */\n function fill(dst: usize, value: u8, size: usize): void;\n /** Resets the allocator to its initial state, if supported. */\n function reset(): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer's bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform's endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ndeclare class Array {\n\n static isArray(value: any): value is Array;\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n length: i32;\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from?: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\ndeclare class Uint8Array extends Array {}\ndeclare class Uint8ClampedArray extends Array {}\ndeclare class Uint16Array extends Array {}\ndeclare class Uint32Array extends Array {}\ndeclare class Int8Array extends Array {}\ndeclare class Int16Array extends Array {}\ndeclare class Int32Array extends Array {}\ndeclare class Float32Array extends Array {}\ndeclare class Float64Array extends Array {}\n\ninterface ArrayLike {\n length: i32;\n [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n\n private constructor();\n\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n concat(other: string): string;\n indexOf(other: string, fromIndex?: i32): i32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n endsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(from: i32, to?: i32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n replace(search: string, replacement: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n}\n\ninterface Boolean {}\n\ndeclare class Number {\n private constructor();\n toString(radix?: i32): string;\n}\n\ninterface Object {}\n\ninterface Function {}\n\ninterface RegExp {}\n\ninterface IArguments {}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ndeclare class Set {\n constructor(entries?: T[]);\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n [Symbol.iterator](): Iterator;\n}\n\ndeclare class Map {\n constructor(entries?: [K, V][]);\n readonly size: i32;\n set(key: K, value: V): void;\n has(key: K): bool;\n get(key: K): V | null;\n clear(): void;\n entries(): Iterable<[K, V]>;\n keys(): Iterable;\n values(): Iterable;\n delete(key: K): bool;\n toString(): string;\n [Symbol.iterator](): Iterator<[K,V]>;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\ndeclare const Symbol: SymbolConstructor;\n\ninterface Iterable {\n [Symbol.iterator](): Iterator;\n}\n\ninterface Iterator {}\n\ninterface IMath {\n readonly E: f64;\n readonly LN2: f64;\n readonly LN10: f64;\n readonly LOG2E: f64;\n readonly LOG10E: f64;\n readonly PI: f64;\n readonly SQRT1_2: f64;\n readonly SQRT2: f64;\n\n sincos_sin: f64;\n sincos_cos: f64;\n\n abs(x: f64): f64;\n acos(x: f64): f64;\n acosh(x: f64): f64;\n asin(x: f64): f64;\n asinh(x: f64): f64;\n atan(x: f64): f64;\n atan2(y: f64, x: f64): f64;\n atanh(x: f64): f64;\n cbrt(x: f64): f64;\n ceil(x: f64): f64;\n clz32(x: f64): i32;\n cos(x: f64): f64;\n cosh(x: f64): f64;\n exp(x: f64): f64;\n expm1(x: f64): f64;\n floor(x: f64): f64;\n fround(x: f64): f32;\n hypot(value1: f64, value2: f64): f64; // TODO: see std/math\n imul(a: f64, b: f64): i32;\n log(x: f64): f64;\n log10(x: f64): f64;\n log1p(x: f64): f64;\n log2(x: f64): f64;\n max(value1: f64, value2: f64): f64; // TODO: see std/math\n min(value1: f64, value2: f64): f64; // TODO: see std/math\n pow(base: f64, exponent: f64): f64;\n random(): f64;\n round(x: f64): f64;\n sign(x: f64): f64;\n signbit(x: f64): bool;\n sin(x: f64): f64;\n sincos(x: f64): f64;\n sinh(x: f64): f64;\n sqrt(x: f64): f64;\n tan(x: f64): f64;\n tanh(x: f64): f64;\n trunc(x: f64): f64;\n}\n\ndeclare const Math: IMath;\ndeclare const Mathf: IMath;\ndeclare const JSMath: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): number;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): number;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: number);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): number;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: number): number;\n}\n\ndeclare namespace console {\n /** @deprecated */\n function log(message: string): void;\n}\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n"}):(()=>{const n=path.join(".","..","std");return{assembly:fs.readFileSync(path.join(n,"assembly","index.d.ts"),"utf8"),portable:fs.readFileSync(path.join(n,"portable","index.d.ts"),"utf8")}})(),exports.compileString=((n,e)=>{"string"==typeof n&&(n={"input.ts":n});const t=Object.create({stdout:createMemoryStream(),stderr:createMemoryStream()});var r=["--binaryFile","binary","--textFile","text"];return Object.keys(e||{}).forEach(n=>{var t=e[n];Array.isArray(t)?t.forEach(e=>r.push("--"+n,String(e))):r.push("--"+n,String(t))}),exports.main(r.concat(Object.keys(n)),{stdout:t.stdout,stderr:t.stderr,readFile:e=>n.hasOwnProperty(e)?n[e]:null,writeFile:(n,e)=>t[n]=e,listFiles:()=>[]}),t}),exports.main=function(n,e,t){"function"==typeof e?(t=e,e={}):e||(e={});const r=e.stdout||process.stdout,i=e.stderr||process.stderr,o=e.readFile||F,a=e.writeFile||z,s=e.listFiles||S,l=e.stats||createStats();if(!r)throw Error("'options.stdout' must be specified");if(!i)throw Error("'options.stderr' must be specified");const u=optionsUtil.parse(n,exports.options),f=u.options;if(n=u.arguments,f.noColors?colorsUtil.stdout.supported=colorsUtil.stderr.supported=!1:(colorsUtil.stdout=colorsUtil.from(r),colorsUtil.stderr=colorsUtil.from(i)),u.unknown.length&&u.unknown.forEach(n=>{i.write(colorsUtil.stderr.yellow("WARN: ")+"Unknown option '"+n+"'"+EOL)}),u.trailing.length&&i.write(colorsUtil.stderr.yellow("WARN: ")+"Unsupported trailing arguments: "+u.trailing.join(" ")+EOL),t||(t=function(n){var e=0;return n&&(i.write(colorsUtil.stderr.red("ERROR: ")+n.stack.replace(/^ERROR: /i,"")+EOL),e=1),e}),f.version)return r.write("Version "+exports.version+(isDev?"-dev":"")+EOL),t(null);if(f.help||!n.length){var c=f.help?r:i,d=f.help?colorsUtil.stdout:colorsUtil.stderr;return c.write([d.white("SYNTAX")," "+d.cyan("asc")+" [entryFile ...] [options]","",d.white("EXAMPLES")," "+d.cyan("asc")+" hello.ts"," "+d.cyan("asc")+" hello.ts -b hello.wasm -t hello.wat"," "+d.cyan("asc")+" hello1.ts hello2.ts -b -O > hello.wasm","",d.white("OPTIONS")].concat(optionsUtil.help(exports.options,24,EOL)).join(EOL)+EOL),t(null)}if(!fs.readFileSync){if(o===F)throw Error("'options.readFile' must be specified");if(a===z)throw Error("'options.writeFile' must be specified");if(s===S)throw Error("'options.listFiles' must be specified")}const p=f.baseDir?path.resolve(f.baseDir):".",h=[];f.transform&&f.transform.forEach(n=>h.push(__webpack_require__(12)(path.isAbsolute(n=n.trim())?n:path.join(process.cwd(),n))));var g=null;Object.keys(exports.libraryFiles).forEach(n=>{n.indexOf("/")>=0||(l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(exports.libraryFiles[n],exports.libraryPrefix+n+".ts",!1,g)}))});const x=[];if(f.lib){let n=f.lib;"string"==typeof n&&(n=n.split(",")),Array.prototype.push.apply(x,n.map(n=>n.trim()));for(let n=0,e=x.length;n{g=assemblyscript.parseFile(a,exports.libraryPrefix+i,!1,g)})}}}function v(){for(var n,e;null!=(n=g.nextFile());){if(n.startsWith(exports.libraryPrefix)){const t=n.substring(exports.libraryPrefix.length),r=n.substring(exports.libraryPrefix.length)+"/index";if(exports.libraryFiles.hasOwnProperty(t))e=exports.libraryFiles[t],n=exports.libraryPrefix+t+".ts";else if(exports.libraryFiles.hasOwnProperty(r))e=exports.libraryFiles[r],n=exports.libraryPrefix+r+".ts";else for(let i=0,a=x.length;i{assemblyscript.parseFile(e,n,!1,g)})}if(checkDiagnostics(g,i))return t(Error("Parse error"))}{let n=String(f.runtime),e=exports.libraryFiles["rt/index-"+n];if(null==e&&null==(e=o(n+".ts",p)))return t(Error("Runtime template '"+n+"' not found."));l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(e,n,!0,g)})}for(let e=0,r=n.length;e{g=assemblyscript.parseFile(a,i,!0,g)})}{let n=v();if(n)return n}!function(n,...e){h.forEach(t=>{"function"==typeof t[n]&&t[n](...e)})}("afterParse",g);{let n=v();if(n)return n}const m=assemblyscript.finishParsing(g);var b=0,y=0;f.optimize&&(b=exports.defaultOptimizeLevel,y=exports.defaultShrinkLevel),"number"==typeof f.optimizeLevel&&(b=f.optimizeLevel),"number"==typeof f.shrinkLevel&&(y=f.shrinkLevel),b=Math.min(Math.max(b,0),3),y=Math.min(Math.max(y,0),2);const _=assemblyscript.createOptions();if(assemblyscript.setTarget(_,0),assemblyscript.setNoAssert(_,f.noAssert),assemblyscript.setImportMemory(_,f.importMemory),assemblyscript.setSharedMemory(_,f.sharedMemory),assemblyscript.setImportTable(_,f.importTable),assemblyscript.setMemoryBase(_,f.memoryBase>>>0),assemblyscript.setSourceMap(_,null!=f.sourceMap),assemblyscript.setOptimizeLevelHints(_,b,y),assemblyscript.setGlobalAlias(_,"Math","NativeMath"),assemblyscript.setGlobalAlias(_,"Mathf","NativeMathf"),assemblyscript.setGlobalAlias(_,"abort","~lib/builtins/abort"),assemblyscript.setGlobalAlias(_,"trace","~lib/builtins/trace"),f.use){let n=f.use;for(let e=0,r=n.length;e{T=assemblyscript.compileProgram(m,_)})}catch(n){return t(n)}if(checkDiagnostics(g,i))return T&&T.dispose(),t(Error("Compile error"));if(f.validate&&(l.validateCount++,l.validateTime+=measure(()=>{if(!T.validate())return T.dispose(),t(Error("Validate error"))})),"clamp"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-clamp"])});else if("js"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-js"])});else if("allow"!==f.trapMode)return T.dispose(),t(Error("Unsupported trap mode"));(b>=3||y>=2)&&(b=4),T.setOptimizeLevel(b),T.setShrinkLevel(y),T.setDebugInfo(f.debug);var A=[];if(f.runPasses&&("string"==typeof f.runPasses&&(f.runPasses=f.runPasses.split(",")),f.runPasses.length&&f.runPasses.forEach(n=>{A.indexOf(n)<0&&A.push(n)})),(b>0||y>0)&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.optimize()})),A.length&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(A.map(n=>n.trim()))})),!f.noEmit){let n=!1,e=!1;if(null!=f.outFile&&(/\.was?t$/.test(f.outFile)&&null==f.textFile?f.textFile=f.outFile:/\.js$/.test(f.outFile)&&null==f.asmjsFile?f.asmjsFile=f.outFile:null==f.binaryFile&&(f.binaryFile=f.outFile)),null!=f.binaryFile){let r,s=null!=f.sourceMap?f.sourceMap.length?f.sourceMap:path.basename(f.binaryFile)+".map":null;if(l.emitCount++,l.emitTime+=measure(()=>{r=T.toBinary(s)}),f.binaryFile.length?a(f.binaryFile,r.output,p):(I(r.output),n=!0),e=!0,null!=r.sourceMap)if(f.binaryFile.length){let n=JSON.parse(r.sourceMap);n.sourceRoot=exports.sourceMapRoot,n.sources.forEach((e,r)=>{let i=null;if(e.startsWith(exports.libraryPrefix)){let n=e.substring(exports.libraryPrefix.length).replace(/\.ts$/,"");if(exports.libraryFiles.hasOwnProperty(n))i=exports.libraryFiles[n];else for(let n=0,t=x.length;n{t=T.toAsmjs()}),a(f.asmjsFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=T.toAsmjs()}),I(t),n=!0),e=!0}if(null!=f.idlFile){let t;f.idlFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),a(f.idlFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),I(t),n=!0),e=!0}if(null!=f.tsdFile){let t;f.tsdFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),a(f.tsdFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),I(t),n=!0),e=!0}if(null!=f.textFile||!e){let e;f.textFile&&f.textFile.length?(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),a(f.textFile,e,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),I(e))}}return T.dispose(),f.measure&&printStats(l,i),t(null);function F(n,e){try{let t;return l.readCount++,l.readTime+=measure(()=>{t=fs.readFileSync(path.join(e,n),{encoding:"utf8"})}),t}catch(n){return null}}function z(n,e,t){try{return l.writeCount++,l.writeTime+=measure(()=>{mkdirp(path.join(t,path.dirname(n))),"string"==typeof e?fs.writeFileSync(path.join(t,n),e,{encoding:"utf8"}):fs.writeFileSync(path.join(t,n),e)}),!0}catch(n){return!1}}function S(n,e){var t;try{return l.readTime+=measure(()=>{t=fs.readdirSync(path.join(e,n)).filter(n=>/^(?!.*\.d\.ts$).*\.ts$/.test(n))}),t}catch(n){return[]}}function I(n){I.used||(l.writeCount++,I.used=!0),l.writeTime+=measure(()=>{"string"==typeof n?r.write(n,{encoding:"utf8"}):r.write(n)})}},exports.checkDiagnostics=checkDiagnostics,exports.createStats=createStats,process.hrtime||(process.hrtime=__webpack_require__(13)),exports.measure=measure,exports.formatTime=formatTime,exports.printStats=printStats;var allocBuffer=void 0!==global&&global.Buffer?global.Buffer.allocUnsafe||function(n){return new global.Buffer(n)}:function(n){return new Uint8Array(n)};function createMemoryStream(n){var e=[];return e.write=function(e){if(n&&n(e),"string"==typeof e){let n=allocBuffer(utf8.length(e));utf8.write(e,n,0),e=n}this.push(e)},e.reset=function(){e.length=0},e.toBuffer=function(){for(var n=0,e=0,t=this.length;e191&&r<224?o[a++]=(31&r)<<6|63&n[e++]:r>239&&r<365?(r=((7&r)<<18|(63&n[e++])<<12|(63&n[e++])<<6|63&n[e++])-65536,o[a++]=55296+(r>>10),o[a++]=56320+(1023&r)):o[a++]=(15&r)<<12|(63&n[e++])<<6|63&n[e++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(n,e,t){for(var r,i,o=t,a=0;a>6|192,e[t++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=n.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&i),++a,e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=63&r|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=63&r|128);return t-o}},function(n,e,t){(function(n){var t=void 0!==n&&n||{},r=t.env&&"CI"in t.env;function i(n,t){var i=t||{};return i.supported=n&&!!n.isTTY||r,i.gray=(n=>i.supported?e.GRAY+n+e.RESET:n),i.red=(n=>i.supported?e.RED+n+e.RESET:n),i.green=(n=>i.supported?e.GREEN+n+e.RESET:n),i.yellow=(n=>i.supported?e.YELLOW+n+e.RESET:n),i.blue=(n=>i.supported?e.BLUE+n+e.RESET:n),i.magenta=(n=>i.supported?e.MAGENTA+n+e.RESET:n),i.cyan=(n=>i.supported?e.CYAN+n+e.RESET:n),i.white=(n=>i.supported?e.WHITE+n+e.RESET:n),i}e.stdout=i(t.stdout,e),e.stderr=i(t.stderr),e.from=i,e.GRAY="",e.RED="",e.GREEN="",e.YELLOW="",e.BLUE="",e.MAGENTA="",e.CYAN="",e.WHITE="",e.RESET=""}).call(this,t(0))},function(n,e){e.parse=function(n,e){var t={},r=[],arguments=[],i=[],o={};Object.keys(e).forEach(n=>{if(!n.startsWith(" ")){var r=e[n];null!=r.alias&&("string"==typeof r.alias?o[r.alias]=n:Array.isArray(r.alias)&&r.alias.forEach(e=>o[e]=n)),null!=r.default&&(t[n]=r.default)}});for(var a=0,s=(n=n.slice()).length;at[n]=s.value[n])}else r.push(i)}for(;a{var a=n[e];if(null!=a.description){for(var s="";s.length{for(let e=0;e 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\r\n * Compiler frontend for node.js\r\n *\r\n * Uses the low-level API exported from src/index.ts so it works with the compiler compiled to\r\n * JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources\r\n * directly through ts-node if distribution files are not present (indicated by a `-dev` version).\r\n *\r\n * Can also be packaged as a bundle suitable for in-browser use with the standard library injected\r\n * in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.\r\n *\r\n * @module cli/asc\r\n */\r\n\r\n// Use \".\" instead of \"/\" as cwd in browsers\r\nif (process.browser) process.cwd = function() { return \".\"; };\r\n\r\nconst fs = require(\"fs\");\r\nconst path = require(\"path\");\r\nconst utf8 = require(\"@protobufjs/utf8\");\r\nconst colorsUtil = require(\"./util/colors\");\r\nconst optionsUtil = require(\"./util/options\");\r\nconst mkdirp = require(\"./util/mkdirp\");\r\nconst EOL = process.platform === \"win32\" ? \"\\r\\n\" : \"\\n\";\r\n\r\n// global.Binaryen = require(\"../lib/binaryen\");\r\n\r\n// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional\r\n// useless code fragment on top of an actual error. suppress this:\r\nif (process.removeAllListeners) process.removeAllListeners(\"uncaughtException\");\r\n\r\n// Use distribution files if present, otherwise run the sources directly\r\nvar assemblyscript, isDev = false;\r\n(() => {\r\n try { // `asc` on the command line\r\n assemblyscript = require(\"../dist/assemblyscript.js\");\r\n } catch (e) {\r\n try { // `asc` on the command line without dist files\r\n require(\"ts-node\").register({ project: path.join(__dirname, \"..\", \"src\", \"tsconfig.json\") });\r\n require(\"../src/glue/js\");\r\n assemblyscript = require(\"../src\");\r\n isDev = true;\r\n } catch (e_ts) {\r\n try { // `require(\"dist/asc.js\")` in explicit browser tests\r\n assemblyscript = eval(\"require('./assemblyscript')\");\r\n } catch (e) {\r\n // combine both errors that lead us here\r\n e.stack = e_ts.stack + \"\\n---\\n\" + e.stack;\r\n throw e;\r\n }\r\n }\r\n }\r\n})();\r\n\r\n/** Whether this is a webpack bundle or not. */\r\nexports.isBundle = typeof BUNDLE_VERSION === \"string\";\r\n\r\n/** Whether asc runs the sources directly or not. */\r\nexports.isDev = isDev;\r\n\r\n/** AssemblyScript version. */\r\nexports.version = exports.isBundle ? BUNDLE_VERSION : require(\"../package.json\").version;\r\n\r\n/** Available CLI options. */\r\nexports.options = require(\"./asc.json\");\r\n\r\n/** Common root used in source maps. */\r\nexports.sourceMapRoot = \"assemblyscript:///\";\r\n\r\n/** Prefix used for library files. */\r\nexports.libraryPrefix = assemblyscript.LIBRARY_PREFIX;\r\n\r\n/** Default Binaryen optimization level. */\r\nexports.defaultOptimizeLevel = 3;\r\n\r\n/** Default Binaryen shrink level. */\r\nexports.defaultShrinkLevel = 1;\r\n\r\n/** Bundled library files. */\r\nexports.libraryFiles = exports.isBundle ? BUNDLE_LIBRARY : (() => { // set up if not a bundle\r\n const libDir = path.join(__dirname, \"..\", \"std\", \"assembly\");\r\n const libFiles = require(\"glob\").sync(\"**/!(*.d).ts\", { cwd: libDir });\r\n const bundled = {};\r\n libFiles.forEach(file => bundled[file.replace(/\\.ts$/, \"\")] = fs.readFileSync(path.join(libDir, file), \"utf8\" ));\r\n return bundled;\r\n})();\r\n\r\n/** Bundled definition files. */\r\nexports.definitionFiles = exports.isBundle ? BUNDLE_DEFINITIONS : (() => { // set up if not a bundle\r\n const stdDir = path.join(__dirname, \"..\", \"std\");\r\n return {\r\n \"assembly\": fs.readFileSync(path.join(stdDir, \"assembly\", \"index.d.ts\"), \"utf8\"),\r\n \"portable\": fs.readFileSync(path.join(stdDir, \"portable\", \"index.d.ts\"), \"utf8\")\r\n };\r\n})();\r\n\r\n/** Convenience function that parses and compiles source strings directly. */\r\nexports.compileString = (sources, options) => {\r\n if (typeof sources === \"string\") sources = { \"input.ts\": sources };\r\n const output = Object.create({\r\n stdout: createMemoryStream(),\r\n stderr: createMemoryStream()\r\n });\r\n var argv = [\r\n \"--binaryFile\", \"binary\",\r\n \"--textFile\", \"text\",\r\n ];\r\n Object.keys(options || {}).forEach(key => {\r\n var val = options[key];\r\n if (Array.isArray(val)) val.forEach(val => argv.push(\"--\" + key, String(val)));\r\n else argv.push(\"--\" + key, String(val));\r\n });\r\n exports.main(argv.concat(Object.keys(sources)), {\r\n stdout: output.stdout,\r\n stderr: output.stderr,\r\n readFile: name => sources.hasOwnProperty(name) ? sources[name] : null,\r\n writeFile: (name, contents) => output[name] = contents,\r\n listFiles: () => []\r\n });\r\n return output;\r\n}\r\n\r\n/** Runs the command line utility using the specified arguments array. */\r\nexports.main = function main(argv, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = {};\r\n } else if (!options) {\r\n options = {};\r\n }\r\n\r\n const stdout = options.stdout || process.stdout;\r\n const stderr = options.stderr || process.stderr;\r\n const readFile = options.readFile || readFileNode;\r\n const writeFile = options.writeFile || writeFileNode;\r\n const listFiles = options.listFiles || listFilesNode;\r\n const stats = options.stats || createStats();\r\n\r\n // Output must be specified if not present in the environment\r\n if (!stdout) throw Error(\"'options.stdout' must be specified\");\r\n if (!stderr) throw Error(\"'options.stderr' must be specified\");\r\n\r\n const opts = optionsUtil.parse(argv, exports.options);\r\n const args = opts.options;\r\n argv = opts.arguments;\r\n if (args.noColors) {\r\n colorsUtil.stdout.supported =\r\n colorsUtil.stderr.supported = false;\r\n } else {\r\n colorsUtil.stdout = colorsUtil.from(stdout);\r\n colorsUtil.stderr = colorsUtil.from(stderr);\r\n }\r\n\r\n // Check for unknown arguments\r\n if (opts.unknown.length) {\r\n opts.unknown.forEach(arg => {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unknown option '\" + arg + \"'\" + EOL);\r\n });\r\n }\r\n\r\n // Check for trailing arguments\r\n if (opts.trailing.length) {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unsupported trailing arguments: \" + opts.trailing.join(\" \") + EOL);\r\n }\r\n\r\n // Use default callback if none is provided\r\n if (!callback) callback = function defaultCallback(err) {\r\n var code = 0;\r\n if (err) {\r\n stderr.write(colorsUtil.stderr.red(\"ERROR: \") + err.stack.replace(/^ERROR: /i, \"\") + EOL);\r\n code = 1;\r\n }\r\n return code;\r\n };\r\n\r\n // Just print the version if requested\r\n if (args.version) {\r\n stdout.write(\"Version \" + exports.version + (isDev ? \"-dev\" : \"\") + EOL);\r\n return callback(null);\r\n }\r\n // Print the help message if requested or no source files are provided\r\n if (args.help || !argv.length) {\r\n var out = args.help ? stdout : stderr;\r\n var color = args.help ? colorsUtil.stdout : colorsUtil.stderr;\r\n out.write([\r\n color.white(\"SYNTAX\"),\r\n \" \" + color.cyan(\"asc\") + \" [entryFile ...] [options]\",\r\n \"\",\r\n color.white(\"EXAMPLES\"),\r\n \" \" + color.cyan(\"asc\") + \" hello.ts\",\r\n \" \" + color.cyan(\"asc\") + \" hello.ts -b hello.wasm -t hello.wat\",\r\n \" \" + color.cyan(\"asc\") + \" hello1.ts hello2.ts -b -O > hello.wasm\",\r\n \"\",\r\n color.white(\"OPTIONS\"),\r\n ].concat(\r\n optionsUtil.help(exports.options, 24, EOL)\r\n ).join(EOL) + EOL);\r\n return callback(null);\r\n }\r\n\r\n // I/O must be specified if not present in the environment\r\n if (!fs.readFileSync) {\r\n if (readFile === readFileNode) throw Error(\"'options.readFile' must be specified\");\r\n if (writeFile === writeFileNode) throw Error(\"'options.writeFile' must be specified\");\r\n if (listFiles === listFilesNode) throw Error(\"'options.listFiles' must be specified\");\r\n }\r\n\r\n // Set up base directory\r\n const baseDir = args.baseDir ? path.resolve(args.baseDir) : \".\";\r\n\r\n // Set up transforms\r\n const transforms = [];\r\n if (args.transform) {\r\n args.transform.forEach(transform =>\r\n transforms.push(\r\n require(\r\n path.isAbsolute(transform = transform.trim())\r\n ? transform\r\n : path.join(process.cwd(), transform)\r\n )\r\n )\r\n );\r\n }\r\n function applyTransform(name, ...args) {\r\n transforms.forEach(transform => {\r\n if (typeof transform[name] === \"function\") transform[name](...args);\r\n });\r\n }\r\n\r\n // Begin parsing\r\n var parser = null;\r\n\r\n // Include library files\r\n Object.keys(exports.libraryFiles).forEach(libPath => {\r\n if (libPath.indexOf(\"/\") >= 0) return; // in sub-directory: imported on demand\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n exports.libraryFiles[libPath],\r\n exports.libraryPrefix + libPath + \".ts\",\r\n false,\r\n parser\r\n );\r\n });\r\n });\r\n const customLibDirs = [];\r\n if (args.lib) {\r\n let lib = args.lib;\r\n if (typeof lib === \"string\") lib = lib.split(\",\");\r\n Array.prototype.push.apply(customLibDirs, lib.map(lib => lib.trim()));\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom\r\n let libDir = customLibDirs[i];\r\n let libFiles;\r\n if (libDir.endsWith(\".ts\")) {\r\n libFiles = [ path.basename(libDir) ];\r\n libDir = path.dirname(libDir);\r\n } else {\r\n libFiles = listFiles(libDir);\r\n }\r\n for (let j = 0, l = libFiles.length; j < l; ++j) {\r\n let libPath = libFiles[j];\r\n let libText = readFile(libPath, libDir);\r\n if (libText === null) return callback(Error(\"Library file '\" + libPath + \"' not found.\"));\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n libText,\r\n exports.libraryPrefix + libPath,\r\n false,\r\n parser\r\n );\r\n });\r\n }\r\n }\r\n }\r\n\r\n // Parses the backlog of imported files after including entry files\r\n function parseBacklog() {\r\n var sourcePath, sourceText;\r\n while ((sourcePath = parser.nextFile()) != null) {\r\n\r\n // Load library file if explicitly requested\r\n if (sourcePath.startsWith(exports.libraryPrefix)) {\r\n const plainName = sourcePath.substring(exports.libraryPrefix.length);\r\n const indexName = sourcePath.substring(exports.libraryPrefix.length) + \"/index\";\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Otherwise try nextFile.ts, nextFile/index.ts, ~lib/nextFile.ts, ~lib/nextFile/index.ts\r\n } else {\r\n const plainName = sourcePath;\r\n const indexName = sourcePath + \"/index\";\r\n sourceText = readFile(plainName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = plainName + \".ts\";\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = indexName + \".ts\";\r\n } else if (!plainName.startsWith(\".\")) {\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n const dir = customLibDirs[i];\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n if (sourceText == null) {\r\n return callback(Error(\"Import file '\" + sourcePath + \".ts' not found.\"));\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n assemblyscript.parseFile(sourceText, sourcePath, false, parser);\r\n });\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n return callback(Error(\"Parse error\"));\r\n }\r\n }\r\n\r\n // Include runtime template before entry files so its setup runs first\r\n {\r\n let templateName = String(args.runtime);\r\n let templateText = exports.libraryFiles[\"rt/index-\" + templateName];\r\n if (templateText == null) {\r\n templateText = readFile(templateName + \".ts\", baseDir);\r\n if (templateText == null) {\r\n return callback(Error(\"Runtime template '\" + templateName + \"' not found.\"));\r\n }\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(templateText, templateName, true, parser);\r\n });\r\n }\r\n\r\n // Include entry files\r\n for (let i = 0, k = argv.length; i < k; ++i) {\r\n const filename = argv[i];\r\n\r\n let sourcePath = String(filename).replace(/\\\\/g, \"/\").replace(/(\\.ts|\\/)$/, \"\");\r\n\r\n // Try entryPath.ts, then entryPath/index.ts\r\n let sourceText = readFile(sourcePath + \".ts\", baseDir);\r\n if (sourceText === null) {\r\n sourceText = readFile(sourcePath + \"/index.ts\", baseDir);\r\n if (sourceText === null) {\r\n return callback(Error(\"Entry file '\" + sourcePath + \".ts' not found.\"));\r\n } else {\r\n sourcePath += \"/index.ts\";\r\n }\r\n } else {\r\n sourcePath += \".ts\";\r\n }\r\n\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);\r\n });\r\n }\r\n\r\n // Parse entry files\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Call afterParse transform hook\r\n applyTransform(\"afterParse\", parser);\r\n\r\n // Parse additional files, if any\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Finish parsing\r\n const program = assemblyscript.finishParsing(parser);\r\n\r\n // Set up optimization levels\r\n var optimizeLevel = 0;\r\n var shrinkLevel = 0;\r\n if (args.optimize) {\r\n optimizeLevel = exports.defaultOptimizeLevel;\r\n shrinkLevel = exports.defaultShrinkLevel;\r\n }\r\n if (typeof args.optimizeLevel === \"number\") {\r\n optimizeLevel = args.optimizeLevel;\r\n }\r\n if (typeof args.shrinkLevel === \"number\") {\r\n shrinkLevel = args.shrinkLevel;\r\n }\r\n optimizeLevel = Math.min(Math.max(optimizeLevel, 0), 3);\r\n shrinkLevel = Math.min(Math.max(shrinkLevel, 0), 2);\r\n\r\n // Begin compilation\r\n const compilerOptions = assemblyscript.createOptions();\r\n assemblyscript.setTarget(compilerOptions, 0);\r\n assemblyscript.setNoAssert(compilerOptions, args.noAssert);\r\n assemblyscript.setImportMemory(compilerOptions, args.importMemory);\r\n assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);\r\n assemblyscript.setImportTable(compilerOptions, args.importTable);\r\n assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);\r\n assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);\r\n assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);\r\n\r\n // Initialize default aliases\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Math\", \"NativeMath\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Mathf\", \"NativeMathf\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"abort\", \"~lib/builtins/abort\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"trace\", \"~lib/builtins/trace\");\r\n\r\n // Add or override aliases if specified\r\n if (args.use) {\r\n let aliases = args.use;\r\n for (let i = 0, k = aliases.length; i < k; ++i) {\r\n let part = aliases[i];\r\n let p = part.indexOf(\"=\");\r\n if (p < 0) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n let name = part.substring(0, p).trim();\r\n let alias = part.substring(p + 1).trim();\r\n if (!name.length) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n assemblyscript.setGlobalAlias(compilerOptions, name, alias);\r\n }\r\n }\r\n\r\n // Enable additional features if specified\r\n var features = args.enable;\r\n if (features != null) {\r\n if (typeof features === \"string\") features = features.split(\",\");\r\n for (let i = 0, k = features.length; i < k; ++i) {\r\n let name = features[i].trim();\r\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\r\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\r\n assemblyscript.enableFeature(compilerOptions, flag);\r\n }\r\n }\r\n\r\n var module;\r\n stats.compileCount++;\r\n try {\r\n stats.compileTime += measure(() => {\r\n module = assemblyscript.compileProgram(program, compilerOptions);\r\n });\r\n } catch (e) {\r\n return callback(e);\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n if (module) module.dispose();\r\n return callback(Error(\"Compile error\"));\r\n }\r\n\r\n // Validate the module if requested\r\n if (args.validate) {\r\n stats.validateCount++;\r\n stats.validateTime += measure(() => {\r\n if (!module.validate()) {\r\n module.dispose();\r\n return callback(Error(\"Validate error\"));\r\n }\r\n });\r\n }\r\n\r\n // Set Binaryen-specific options\r\n if (args.trapMode === \"clamp\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-clamp\" ]);\r\n });\r\n } else if (args.trapMode === \"js\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-js\" ]);\r\n });\r\n } else if (args.trapMode !== \"allow\") {\r\n module.dispose();\r\n return callback(Error(\"Unsupported trap mode\"));\r\n }\r\n\r\n // Implicitly run costly non-LLVM optimizations on -O3 or -Oz\r\n // see: https://github.com/WebAssembly/binaryen/pull/1596\r\n if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;\r\n\r\n module.setOptimizeLevel(optimizeLevel);\r\n module.setShrinkLevel(shrinkLevel);\r\n module.setDebugInfo(args.debug);\r\n\r\n var runPasses = [];\r\n if (args.runPasses) {\r\n if (typeof args.runPasses === \"string\") {\r\n args.runPasses = args.runPasses.split(\",\");\r\n }\r\n if (args.runPasses.length) {\r\n args.runPasses.forEach(pass => {\r\n if (runPasses.indexOf(pass) < 0)\r\n runPasses.push(pass);\r\n });\r\n }\r\n }\r\n\r\n // Optimize the module if requested\r\n if (optimizeLevel > 0 || shrinkLevel > 0) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.optimize();\r\n });\r\n }\r\n\r\n // Run additional passes if requested\r\n if (runPasses.length) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses(runPasses.map(pass => pass.trim()));\r\n });\r\n }\r\n\r\n // Prepare output\r\n if (!args.noEmit) {\r\n let hasStdout = false;\r\n let hasOutput = false;\r\n\r\n if (args.outFile != null) {\r\n if (/\\.was?t$/.test(args.outFile) && args.textFile == null) {\r\n args.textFile = args.outFile;\r\n } else if (/\\.js$/.test(args.outFile) && args.asmjsFile == null) {\r\n args.asmjsFile = args.outFile;\r\n } else if (args.binaryFile == null) {\r\n args.binaryFile = args.outFile;\r\n }\r\n }\r\n\r\n // Write binary\r\n if (args.binaryFile != null) {\r\n let sourceMapURL = args.sourceMap != null\r\n ? args.sourceMap.length\r\n ? args.sourceMap\r\n : path.basename(args.binaryFile) + \".map\"\r\n : null;\r\n\r\n let wasm;\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wasm = module.toBinary(sourceMapURL)\r\n });\r\n\r\n if (args.binaryFile.length) {\r\n writeFile(args.binaryFile, wasm.output, baseDir);\r\n } else {\r\n writeStdout(wasm.output);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n\r\n // Post-process source map\r\n if (wasm.sourceMap != null) {\r\n if (args.binaryFile.length) {\r\n let sourceMap = JSON.parse(wasm.sourceMap);\r\n sourceMap.sourceRoot = exports.sourceMapRoot;\r\n sourceMap.sources.forEach((name, index) => {\r\n let text = null;\r\n if (name.startsWith(exports.libraryPrefix)) {\r\n let stdName = name.substring(exports.libraryPrefix.length).replace(/\\.ts$/, \"\");\r\n if (exports.libraryFiles.hasOwnProperty(stdName)) {\r\n text = exports.libraryFiles[stdName];\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n text = readFile(name.substring(exports.libraryPrefix.length), customLibDirs[i]);\r\n if (text !== null) break;\r\n }\r\n }\r\n } else {\r\n text = readFile(name, baseDir);\r\n }\r\n if (text === null) {\r\n return callback(Error(\"Source file '\" + name + \"' not found.\"));\r\n }\r\n if (!sourceMap.sourceContents) sourceMap.sourceContents = [];\r\n sourceMap.sourceContents[index] = text;\r\n });\r\n writeFile(path.join(\r\n path.dirname(args.binaryFile),\r\n path.basename(sourceMapURL)\r\n ).replace(/^\\.\\//, \"\"), JSON.stringify(sourceMap), baseDir);\r\n } else {\r\n stderr.write(\"Skipped source map (stdout already occupied)\" + EOL);\r\n }\r\n }\r\n }\r\n\r\n // Write asm.js\r\n if (args.asmjsFile != null) {\r\n let asm;\r\n if (args.asmjsFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeFile(args.asmjsFile, asm, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeStdout(asm);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write WebIDL\r\n if (args.idlFile != null) {\r\n let idl;\r\n if (args.idlFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeFile(args.idlFile, idl, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeStdout(idl);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write TypeScript definition\r\n if (args.tsdFile != null) {\r\n let tsd;\r\n if (args.tsdFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeFile(args.tsdFile, tsd, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeStdout(tsd);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write text (must be last)\r\n if (args.textFile != null || !hasOutput) {\r\n let wat;\r\n if (args.textFile && args.textFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText();\r\n });\r\n writeFile(args.textFile, wat, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText()\r\n });\r\n writeStdout(wat);\r\n }\r\n }\r\n }\r\n\r\n module.dispose();\r\n if (args.measure) {\r\n printStats(stats, stderr);\r\n }\r\n return callback(null);\r\n\r\n function readFileNode(filename, baseDir) {\r\n try {\r\n let text;\r\n stats.readCount++;\r\n stats.readTime += measure(() => {\r\n text = fs.readFileSync(path.join(baseDir, filename), { encoding: \"utf8\" });\r\n });\r\n return text;\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n function writeFileNode(filename, contents, baseDir) {\r\n try {\r\n stats.writeCount++;\r\n stats.writeTime += measure(() => {\r\n mkdirp(path.join(baseDir, path.dirname(filename)));\r\n if (typeof contents === \"string\") {\r\n fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: \"utf8\" } );\r\n } else {\r\n fs.writeFileSync(path.join(baseDir, filename), contents);\r\n }\r\n });\r\n return true;\r\n } catch (e) {\r\n return false;\r\n }\r\n }\r\n\r\n function listFilesNode(dirname, baseDir) {\r\n var files;\r\n try {\r\n stats.readTime += measure(() => {\r\n files = fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\\.d\\.ts$).*\\.ts$/.test(file));\r\n });\r\n return files;\r\n } catch (e) {\r\n return [];\r\n }\r\n }\r\n\r\n function writeStdout(contents) {\r\n if (!writeStdout.used) {\r\n stats.writeCount++;\r\n writeStdout.used = true;\r\n }\r\n stats.writeTime += measure(() => {\r\n if (typeof contents === \"string\") {\r\n stdout.write(contents, { encoding: \"utf8\" });\r\n } else {\r\n stdout.write(contents);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Checks diagnostics emitted so far for errors. */\r\nfunction checkDiagnostics(emitter, stderr) {\r\n var diagnostic;\r\n var hasErrors = false;\r\n while ((diagnostic = assemblyscript.nextDiagnostic(emitter)) != null) {\r\n if (stderr) {\r\n stderr.write(\r\n assemblyscript.formatDiagnostic(diagnostic, stderr.isTTY, true) +\r\n EOL + EOL\r\n );\r\n }\r\n if (assemblyscript.isError(diagnostic)) hasErrors = true;\r\n }\r\n return hasErrors;\r\n}\r\n\r\nexports.checkDiagnostics = checkDiagnostics;\r\n\r\n/** Creates an empty set of stats. */\r\nfunction createStats() {\r\n return {\r\n readTime: 0,\r\n readCount: 0,\r\n writeTime: 0,\r\n writeCount: 0,\r\n parseTime: 0,\r\n parseCount: 0,\r\n compileTime: 0,\r\n compileCount: 0,\r\n emitTime: 0,\r\n emitCount: 0,\r\n validateTime: 0,\r\n validateCount: 0,\r\n optimizeTime: 0,\r\n optimizeCount: 0\r\n };\r\n}\r\n\r\nexports.createStats = createStats;\r\n\r\nif (!process.hrtime) process.hrtime = require(\"browser-process-hrtime\");\r\n\r\n/** Measures the execution time of the specified function. */\r\nfunction measure(fn) {\r\n const start = process.hrtime();\r\n fn();\r\n const times = process.hrtime(start);\r\n return times[0] * 1e9 + times[1];\r\n}\r\n\r\nexports.measure = measure;\r\n\r\n/** Formats a high resolution time to a human readable string. */\r\nfunction formatTime(time) {\r\n return time ? (time / 1e6).toFixed(3) + \" ms\" : \"N/A\";\r\n}\r\n\r\nexports.formatTime = formatTime;\r\n\r\n/** Formats and prints out the contents of a set of stats. */\r\nfunction printStats(stats, output) {\r\n function format(time, count) {\r\n return formatTime(time);\r\n }\r\n (output || process.stdout).write([\r\n \"I/O Read : \" + format(stats.readTime, stats.readCount),\r\n \"I/O Write : \" + format(stats.writeTime, stats.writeCount),\r\n \"Parse : \" + format(stats.parseTime, stats.parseCount),\r\n \"Compile : \" + format(stats.compileTime, stats.compileCount),\r\n \"Emit : \" + format(stats.emitTime, stats.emitCount),\r\n \"Validate : \" + format(stats.validateTime, stats.validateCount),\r\n \"Optimize : \" + format(stats.optimizeTime, stats.optimizeCount)\r\n ].join(EOL) + EOL);\r\n}\r\n\r\nexports.printStats = printStats;\r\n\r\nvar allocBuffer = typeof global !== \"undefined\" && global.Buffer\r\n ? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }\r\n : function(len) { return new Uint8Array(len) };\r\n\r\n/** Creates a memory stream that can be used in place of stdout/stderr. */\r\nfunction createMemoryStream(fn) {\r\n var stream = [];\r\n stream.write = function(chunk) {\r\n if (fn) fn(chunk);\r\n if (typeof chunk === \"string\") {\r\n let buffer = allocBuffer(utf8.length(chunk));\r\n utf8.write(chunk, buffer, 0);\r\n chunk = buffer;\r\n }\r\n this.push(chunk);\r\n };\r\n stream.reset = function() {\r\n stream.length = 0;\r\n };\r\n stream.toBuffer = function() {\r\n var offset = 0, i = 0, k = this.length;\r\n while (i < k) offset += this[i++].length;\r\n var buffer = allocBuffer(offset);\r\n offset = i = 0;\r\n while (i < k) {\r\n buffer.set(this[i], offset);\r\n offset += this[i].length;\r\n ++i;\r\n }\r\n return buffer;\r\n };\r\n stream.toString = function() {\r\n var buffer = this.toBuffer();\r\n return utf8.read(buffer, 0, buffer.length);\r\n };\r\n return stream;\r\n}\r\n\r\nexports.createMemoryStream = createMemoryStream;\r\n\r\n/** Compatible TypeScript compiler options for syntax highlighting etc. */\r\nexports.tscOptions = {\r\n alwaysStrict: true,\r\n noImplicitAny: true,\r\n noImplicitReturns: true,\r\n noImplicitThis: true,\r\n noEmitOnError: true,\r\n strictNullChecks: true,\r\n experimentalDecorators: true,\r\n target: \"esnext\",\r\n module: \"commonjs\",\r\n noLib: true,\r\n types: [],\r\n allowJs: false\r\n};\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal UTF8 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar utf8 = exports;\r\n\r\n/**\r\n * Calculates the UTF8 byte length of a string.\r\n * @param {string} string String\r\n * @returns {number} Byte length\r\n */\r\nutf8.length = function utf8_length(string) {\r\n var len = 0,\r\n c = 0;\r\n for (var i = 0; i < string.length; ++i) {\r\n c = string.charCodeAt(i);\r\n if (c < 128)\r\n len += 1;\r\n else if (c < 2048)\r\n len += 2;\r\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\r\n ++i;\r\n len += 4;\r\n } else\r\n len += 3;\r\n }\r\n return len;\r\n};\r\n\r\n/**\r\n * Reads UTF8 bytes as a string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} String read\r\n */\r\nutf8.read = function utf8_read(buffer, start, end) {\r\n var len = end - start;\r\n if (len < 1)\r\n return \"\";\r\n var parts = null,\r\n chunk = [],\r\n i = 0, // char offset\r\n t; // temporary\r\n while (start < end) {\r\n t = buffer[start++];\r\n if (t < 128)\r\n chunk[i++] = t;\r\n else if (t > 191 && t < 224)\r\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\r\n else if (t > 239 && t < 365) {\r\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\r\n chunk[i++] = 0xD800 + (t >> 10);\r\n chunk[i++] = 0xDC00 + (t & 1023);\r\n } else\r\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\n/**\r\n * Writes a string as UTF8 bytes.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Bytes written\r\n */\r\nutf8.write = function utf8_write(string, buffer, offset) {\r\n var start = offset,\r\n c1, // character 1\r\n c2; // character 2\r\n for (var i = 0; i < string.length; ++i) {\r\n c1 = string.charCodeAt(i);\r\n if (c1 < 128) {\r\n buffer[offset++] = c1;\r\n } else if (c1 < 2048) {\r\n buffer[offset++] = c1 >> 6 | 192;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\r\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\r\n ++i;\r\n buffer[offset++] = c1 >> 18 | 240;\r\n buffer[offset++] = c1 >> 12 & 63 | 128;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else {\r\n buffer[offset++] = c1 >> 12 | 224;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n }\r\n }\r\n return offset - start;\r\n};\r\n","var proc = typeof process !== \"undefined\" && process || {};\r\nvar isCI = proc.env && \"CI\" in proc.env; // doesn't work when bundled because 'process' is a mock\r\n\r\nfunction from(stream, base) {\r\n var colors = base || {};\r\n colors.supported = (stream && !!stream.isTTY) || isCI;\r\n colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;\r\n colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;\r\n colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;\r\n colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;\r\n colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;\r\n colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;\r\n colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;\r\n colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;\r\n return colors;\r\n}\r\n\r\nexports.stdout = from(proc.stdout, exports);\r\nexports.stderr = from(proc.stderr);\r\nexports.from = from;\r\n\r\nexports.GRAY = \"\\u001b[90m\";\r\nexports.RED = \"\\u001b[91m\";\r\nexports.GREEN = \"\\u001b[92m\";\r\nexports.YELLOW = \"\\u001b[93m\";\r\nexports.BLUE = \"\\u001b[94m\";\r\nexports.MAGENTA = \"\\u001b[95m\";\r\nexports.CYAN = \"\\u001b[96m\";\r\nexports.WHITE = \"\\u001b[97m\";\r\nexports.RESET = \"\\u001b[0m\";\r\n","// type | meaning\r\n// -----|---------------\r\n// b | boolean\r\n// i | integer\r\n// f | float\r\n// s | string\r\n// I | integer array\r\n// F | float array\r\n// S | string array\r\n\r\n/** Parses the specified command line arguments according to the given configuration. */\r\nfunction parse(argv, config) {\r\n var options = {};\r\n var unknown = [];\r\n var arguments = [];\r\n var trailing = [];\r\n\r\n // make an alias map and initialize defaults\r\n var aliases = {};\r\n Object.keys(config).forEach(key => {\r\n if (key.startsWith(\" \")) return;\r\n var option = config[key];\r\n if (option.alias != null) {\r\n if (typeof option.alias === \"string\") aliases[option.alias] = key;\r\n else if (Array.isArray(option.alias)) option.alias.forEach(alias => aliases[alias] = key);\r\n }\r\n if (option.default != null) options[key] = option.default;\r\n });\r\n\r\n // iterate over argv\r\n for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {\r\n let arg = argv[i];\r\n if (arg == \"--\") { ++i; break; }\r\n let match = /^(?:(\\-\\w)(?:=(.*))?|(\\-\\-\\w{2,})(?:=(.*))?)$/.exec(arg), option, key;\r\n if (match) {\r\n if (config[arg]) option = config[key = arg]; // exact\r\n else if (match[1] != null) { // alias\r\n option = config[key = aliases[match[1].substring(1)]];\r\n if (option && match[2] != null) argv[i--] = match[2];\r\n } else if (match[3] != null) { // full\r\n option = config[key = match[3].substring(2)];\r\n if (option && match[4] != null) argv[i--] = match[4];\r\n }\r\n } else {\r\n if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact\r\n else { arguments.push(arg); continue; } // argument\r\n }\r\n if (option) {\r\n if (option.type == null || option.type === \"b\") options[key] = true; // flag\r\n else {\r\n if (i + 1 < argv.length && argv[i + 1].charCodeAt(0) != 45) { // present\r\n switch (option.type) {\r\n case \"i\": options[key] = parseInt(argv[++i], 10); break;\r\n case \"I\": options[key] = (options[key] || []).concat(parseInt(argv[++i], 10)); break;\r\n case \"f\": options[key] = parseFloat(argv[++i]); break;\r\n case \"F\": options[key] = (options[key] || []).concat(parseFloat(argv[++i])); break;\r\n case \"s\": options[key] = String(argv[++i]); break;\r\n case \"S\": options[key] = (options[key] || []).concat(argv[++i].split(\",\")); break;\r\n default: unknown.push(arg); --i;\r\n }\r\n } else { // omitted\r\n switch (option.type) {\r\n case \"i\":\r\n case \"f\": options[key] = option.default || 0; break;\r\n case \"s\": options[key] = option.default || \"\"; break;\r\n case \"I\":\r\n case \"F\":\r\n case \"S\": options[key] = options.default || []; break;\r\n default: unknown.push(arg);\r\n }\r\n }\r\n }\r\n if (option.value) Object.keys(option.value).forEach(k => options[k] = option.value[k]);\r\n } else unknown.push(arg);\r\n }\r\n while (i < k) trailing.push(argv[i++]); // trailing\r\n\r\n return { options, unknown, arguments, trailing };\r\n}\r\n\r\nexports.parse = parse;\r\n\r\n/** Generates the help text for the specified configuration. */\r\nfunction help(config, options) {\r\n if (!options) options = {};\r\n var indent = options.indent || 2;\r\n var padding = options.padding || 24;\r\n var eol = options.eol || \"\\n\";\r\n var sb = [];\r\n Object.keys(config).forEach(key => {\r\n var option = config[key];\r\n if (option.description == null) return;\r\n var text = \"\";\r\n while (text.length < indent) text += \" \";\r\n text += \"--\" + key;\r\n if (option.alias) text += \", -\" + option.alias;\r\n while (text.length < padding) text += \" \";\r\n if (Array.isArray(option.description)) {\r\n sb.push(text + option.description[0] + option.description.slice(1).map(line => {\r\n for (let i = 0; i < padding; ++i) line = \" \" + line;\r\n return eol + line;\r\n }).join(\"\"));\r\n } else sb.push(text + option.description);\r\n });\r\n return sb.join(eol);\r\n}\r\n\r\nexports.help = help;\r\n","/*\r\nCopyright 2010 James Halliday (mail@substack.net)\r\n\r\nThis project is free software released under the MIT/X11 license:\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n*/\r\n\r\nvar path = require(\"path\");\r\nvar fs = require(\"fs\");\r\nvar _0777 = parseInt(\"0777\", 8);\r\n\r\nmodule.exports = function mkdirp(p, opts, made) {\r\n if (!opts || typeof opts !== \"object\") {\r\n opts = { mode: opts };\r\n }\r\n var mode = opts.mode;\r\n if (mode === undefined) {\r\n mode = _0777 & (~process.umask());\r\n }\r\n if (!made) made = null;\r\n p = path.resolve(p);\r\n try {\r\n fs.mkdirSync(p, mode);\r\n made = made || p;\r\n } catch (err0) {\r\n switch (err0.code) {\r\n case \"ENOENT\":\r\n made = mkdirp(path.dirname(p), opts, made);\r\n mkdirp(p, opts, made);\r\n break;\r\n default:\r\n var stat;\r\n try {\r\n stat = fs.statSync(p);\r\n } catch (err1) {\r\n throw err0;\r\n }\r\n if (!stat.isDirectory()) throw err0;\r\n break;\r\n }\r\n }\r\n return made;\r\n};\r\n","if(typeof __WEBPACK_EXTERNAL_MODULE__10__ === 'undefined') {var e = new Error(\"Cannot find module 'assemblyscript'\"); e.code = 'MODULE_NOT_FOUND'; throw e;}\nmodule.exports = __WEBPACK_EXTERNAL_MODULE__10__;","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 12;","module.exports = process.hrtime || hrtime\n\n// polyfil for window.performance.now\nvar performance = global.performance || {}\nvar performanceNow =\n performance.now ||\n performance.mozNow ||\n performance.msNow ||\n performance.oNow ||\n performance.webkitNow ||\n function(){ return (new Date()).getTime() }\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nfunction hrtime(previousTimestamp){\n var clocktime = performanceNow.call(performance)*1e-3\n var seconds = Math.floor(clocktime)\n var nanoseconds = Math.floor((clocktime%1)*1e9)\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0]\n nanoseconds = nanoseconds - previousTimestamp[1]\n if (nanoseconds<0) {\n seconds--\n nanoseconds += 1e9\n }\n }\n return [seconds,nanoseconds]\n}"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://asc/webpack/universalModuleDefinition","webpack://asc/webpack/bootstrap","webpack://asc/../node_modules/node-libs-browser/mock/process.js","webpack://asc/../node_modules/path-browserify/index.js","webpack://asc/../node_modules/webpack/buildin/global.js","webpack://asc/./asc.js","webpack://asc/../node_modules/@protobufjs/utf8/index.js","webpack://asc/./util/colors.js","webpack://asc/./util/options.js","webpack://asc/./util/mkdirp.js","webpack://asc/external \"assemblyscript\"","webpack://asc/. sync","webpack://asc/../node_modules/browser-process-hrtime/index.js"],"names":["root","factory","exports","module","require","e","define","amd","self","this","__WEBPACK_EXTERNAL_MODULE__10__","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","path","cwd","nextTick","fn","setTimeout","platform","arch","execPath","title","pid","browser","env","argv","binding","Error","chdir","dir","resolve","exit","kill","umask","dlopen","uptime","memoryUsage","uvCounters","features","process","normalizeArray","parts","allowAboveRoot","up","length","last","splice","unshift","splitPathRe","splitPath","filename","exec","slice","filter","xs","f","res","push","resolvedPath","resolvedAbsolute","arguments","TypeError","charAt","split","join","normalize","isAbsolute","trailingSlash","substr","paths","Array","index","relative","from","to","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","concat","sep","delimiter","dirname","result","basename","ext","extname","str","len","g","Function","window","global","fs","utf8","colorsUtil","optionsUtil","mkdirp","EOL","removeAllListeners","assemblyscript","isDev","checkDiagnostics","emitter","stderr","diagnostic","hasErrors","nextDiagnostic","write","formatDiagnostic","isTTY","isError","createStats","readTime","readCount","writeTime","writeCount","parseTime","parseCount","compileTime","compileCount","emitTime","emitCount","validateTime","validateCount","optimizeTime","optimizeCount","measure","hrtime","times","formatTime","time","toFixed","printStats","stats","output","format","count","stdout","code","register","project","e_ts","eval","stack","isBundle","version","options","sourceMapRoot","libraryPrefix","LIBRARY_PREFIX","defaultOptimizeLevel","defaultShrinkLevel","libraryFiles","array","arraybuffer","bindings/Date","bindings/Math","bindings/wasi_unstable","bindings/wasi","builtins","dataview","date","diagnostics","error","fixedarray","heap","iterator","map","math","memory","number","polyfills","regexp","rt","rt/common","rt/index-full","rt/index-half","rt/index-none","rt/index-stub","rt/pure","rt/rtrace","rt/stub","rt/tlsf","set","shared/feature","shared/target","shared/typeinfo","string","symbol","table","typedarray","util/error","util/hash","util/memory","util/number","util/sort","util/string","vector","libDir","libFiles","sync","bundled","forEach","file","replace","readFileSync","definitionFiles","assembly","portable","stdDir","compileString","sources","input.ts","createMemoryStream","keys","val","isArray","String","main","readFile","writeFile","contents","listFiles","callback","readFileNode","writeFileNode","listFilesNode","opts","parse","args","noColors","supported","unknown","arg","yellow","trailing","err","red","help","out","color","white","cyan","baseDir","transforms","transform","parser","libPath","indexOf","parseFile","customLibDirs","lib","apply","k","endsWith","j","libText","parseBacklog","sourcePath","sourceText","nextFile","startsWith","plainName","substring","indexName","templateName","runtime","templateText","applyTransform","program","finishParsing","optimizeLevel","shrinkLevel","optimize","max","compilerOptions","createOptions","setTarget","setNoAssert","noAssert","setImportMemory","importMemory","setSharedMemory","sharedMemory","setImportTable","importTable","setMemoryBase","memoryBase","setSourceMap","sourceMap","setOptimizeLevelHints","setGlobalAlias","use","aliases","part","alias","enable","flag","toUpperCase","enableFeature","compileProgram","dispose","validate","trapMode","runPasses","setOptimizeLevel","setShrinkLevel","setDebugInfo","debug","pass","noEmit","hasStdout","hasOutput","outFile","test","textFile","asmjsFile","binaryFile","wasm","sourceMapURL","toBinary","writeStdout","JSON","sourceRoot","text","stdName","sourceContents","stringify","asm","toAsmjs","idlFile","idl","buildIDL","tsdFile","tsd","buildTSD","wat","toText","encoding","writeFileSync","files","readdirSync","used","allocBuffer","Buffer","allocUnsafe","Uint8Array","stream","chunk","buffer","reset","toBuffer","offset","toString","read","tscOptions","alwaysStrict","noImplicitAny","noImplicitReturns","noImplicitThis","noEmitOnError","strictNullChecks","experimentalDecorators","target","noLib","types","allowJs","charCodeAt","fromCharCode","c1","c2","proc","isCI","base","colors","gray","GRAY","RESET","RED","green","GREEN","YELLOW","blue","BLUE","magenta","MAGENTA","CYAN","WHITE","config","option","default","match","type","parseInt","parseFloat","indent","padding","eol","sb","description","line","_0777","made","undefined","mkdirSync","err0","stat","statSync","err1","isDirectory","webpackEmptyContext","req","id","previousTimestamp","clocktime","performanceNow","performance","seconds","floor","nanoseconds","now","mozNow","msNow","oNow","webkitNow","Date","getTime"],"mappings":"CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAA,WAA0E,IAAM,OAAAG,QAAA,kBAAoC,MAAAC,KAApH,IACA,mBAAAC,eAAAC,IACAD,OAAA,mBAAAL,GACA,iBAAAC,QACAA,QAAA,IAAAD,EAAA,WAA0E,IAAM,OAAAG,QAAA,kBAAoC,MAAAC,KAApH,IAEAL,EAAA,IAAAC,EAAAD,EAAA,gBARA,CASC,oBAAAQ,UAAAC,KAAA,SAAAC,iCACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAX,QAGA,IAAAC,EAAAQ,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAb,QAAA,IAUA,OANAc,EAAAH,GAAAI,KAAAd,EAAAD,QAAAC,IAAAD,QAAAU,GAGAT,EAAAY,GAAA,EAGAZ,EAAAD,QA0DA,OArDAU,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAlB,EAAAmB,EAAAC,GACAV,EAAAW,EAAArB,EAAAmB,IACAG,OAAAC,eAAAvB,EAAAmB,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAA1B,GACA,oBAAA2B,eAAAC,aACAN,OAAAC,eAAAvB,EAAA2B,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAvB,EAAA,cAAiD6B,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAAnB,EAAAmB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFAxB,EAAAgB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAAnB,EAAAQ,EAAAe,EAAAE,EAAA,SAAAA,GAAgH,OAAAN,EAAAM,IAAqBC,KAAA,KAAAD,IACrI,OAAAF,GAIAvB,EAAA2B,EAAA,SAAApC,GACA,IAAAmB,EAAAnB,KAAA+B,WACA,WAA2B,OAAA/B,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAS,EAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAiB,EAAAC,GAAsD,OAAAjB,OAAAkB,UAAAC,eAAA1B,KAAAuB,EAAAC,IAGtD7B,EAAAgC,EAAA,GAIAhC,IAAAiC,EAAA,qBCnEA,IAEAC,EADAC,EAhBA7C,EAAA8C,SAAA,SAAAC,GACAC,WAAAD,EAAA,IAGA/C,EAAAiD,SAAAjD,EAAAkD,KACAlD,EAAAmD,SAAAnD,EAAAoD,MAAA,UACApD,EAAAqD,IAAA,EACArD,EAAAsD,SAAA,EACAtD,EAAAuD,IAAA,GACAvD,EAAAwD,KAAA,GAEAxD,EAAAyD,QAAA,SAAAtC,GACA,UAAAuC,MAAA,8CAIAb,EAAA,IAEA7C,EAAA6C,IAAA,WAA+B,OAAAA,GAC/B7C,EAAA2D,MAAA,SAAAC,GACAhB,MAA0BlC,EAAQ,IAClCmC,EAAAD,EAAAiB,QAAAD,EAAAf,IAIA7C,EAAA8D,KAAA9D,EAAA+D,KACA/D,EAAAgE,MAAAhE,EAAAiE,OACAjE,EAAAkE,OAAAlE,EAAAmE,YACAnE,EAAAoE,WAAA,aACApE,EAAAqE,SAAA,qBC7BA,SAAAC,GAyBA,SAAAC,EAAAC,EAAAC,GAGA,IADA,IAAAC,EAAA,EACA9D,EAAA4D,EAAAG,OAAA,EAAgC/D,GAAA,EAAQA,IAAA,CACxC,IAAAgE,EAAAJ,EAAA5D,GACA,MAAAgE,EACAJ,EAAAK,OAAAjE,EAAA,GACK,OAAAgE,GACLJ,EAAAK,OAAAjE,EAAA,GACA8D,KACKA,IACLF,EAAAK,OAAAjE,EAAA,GACA8D,KAKA,GAAAD,EACA,KAAUC,IAAMA,EAChBF,EAAAM,QAAA,MAIA,OAAAN,EAKA,IAAAO,EACA,gEACAC,EAAA,SAAAC,GACA,OAAAF,EAAAG,KAAAD,GAAAE,MAAA,IAuJA,SAAAC,EAAAC,EAAAC,GACA,GAAAD,EAAAD,OAAA,OAAAC,EAAAD,OAAAE,GAEA,IADA,IAAAC,EAAA,GACA3E,EAAA,EAAmBA,EAAAyE,EAAAV,OAAe/D,IAClC0E,EAAAD,EAAAzE,KAAAyE,IAAAE,EAAAC,KAAAH,EAAAzE,IAEA,OAAA2E,EAxJAvF,EAAA6D,QAAA,WAIA,IAHA,IAAA4B,EAAA,GACAC,GAAA,EAEA9E,EAAA+E,UAAAhB,OAAA,EAAoC/D,IAAA,IAAA8E,EAA8B9E,IAAA,CAClE,IAAAgC,EAAAhC,GAAA,EAAA+E,UAAA/E,GAAA0D,EAAAzB,MAGA,oBAAAD,EACA,UAAAgD,UAAA,6CACKhD,IAIL6C,EAAA7C,EAAA,IAAA6C,EACAC,EAAA,MAAA9C,EAAAiD,OAAA,IAWA,OAAAH,EAAA,SAJAD,EAAAlB,EAAAa,EAAAK,EAAAK,MAAA,cAAApD,GACA,QAAAA,KACGgD,GAAAK,KAAA,OAEH,KAKA/F,EAAAgG,UAAA,SAAApD,GACA,IAAAqD,EAAAjG,EAAAiG,WAAArD,GACAsD,EAAA,MAAAC,EAAAvD,GAAA,GAcA,OAXAA,EAAA2B,EAAAa,EAAAxC,EAAAkD,MAAA,cAAApD,GACA,QAAAA,KACGuD,GAAAF,KAAA,OAEHE,IACArD,EAAA,KAEAA,GAAAsD,IACAtD,GAAA,MAGAqD,EAAA,QAAArD,GAIA5C,EAAAiG,WAAA,SAAArD,GACA,YAAAA,EAAAiD,OAAA,IAIA7F,EAAA+F,KAAA,WACA,IAAAK,EAAAC,MAAA7D,UAAA2C,MAAApE,KAAA4E,UAAA,GACA,OAAA3F,EAAAgG,UAAAZ,EAAAgB,EAAA,SAAA1D,EAAA4D,GACA,oBAAA5D,EACA,UAAAkD,UAAA,0CAEA,OAAAlD,IACGqD,KAAA,OAMH/F,EAAAuG,SAAA,SAAAC,EAAAC,GAIA,SAAAC,EAAAC,GAEA,IADA,IAAAC,EAAA,EACUA,EAAAD,EAAAhC,QACV,KAAAgC,EAAAC,GAD8BA,KAK9B,IADA,IAAAC,EAAAF,EAAAhC,OAAA,EACUkC,GAAA,GACV,KAAAF,EAAAE,GADoBA,KAIpB,OAAAD,EAAAC,EAAA,GACAF,EAAAxB,MAAAyB,EAAAC,EAAAD,EAAA,GAfAJ,EAAAxG,EAAA6D,QAAA2C,GAAAL,OAAA,GACAM,EAAAzG,EAAA6D,QAAA4C,GAAAN,OAAA,GAsBA,IALA,IAAAW,EAAAJ,EAAAF,EAAAV,MAAA,MACAiB,EAAAL,EAAAD,EAAAX,MAAA,MAEAnB,EAAAqC,KAAAC,IAAAH,EAAAnC,OAAAoC,EAAApC,QACAuC,EAAAvC,EACA/D,EAAA,EAAiBA,EAAA+D,EAAY/D,IAC7B,GAAAkG,EAAAlG,KAAAmG,EAAAnG,GAAA,CACAsG,EAAAtG,EACA,MAIA,IAAAuG,EAAA,GACA,IAAAvG,EAAAsG,EAA+BtG,EAAAkG,EAAAnC,OAAsB/D,IACrDuG,EAAA3B,KAAA,MAKA,OAFA2B,IAAAC,OAAAL,EAAA5B,MAAA+B,KAEAnB,KAAA,MAGA/F,EAAAqH,IAAA,IACArH,EAAAsH,UAAA,IAEAtH,EAAAuH,QAAA,SAAA3E,GACA,IAAA4E,EAAAxC,EAAApC,GACA9C,EAAA0H,EAAA,GACA5D,EAAA4D,EAAA,GAEA,OAAA1H,GAAA8D,GAKAA,IAEAA,IAAAuC,OAAA,EAAAvC,EAAAe,OAAA,IAGA7E,EAAA8D,GARA,KAYA5D,EAAAyH,SAAA,SAAA7E,EAAA8E,GACA,IAAApC,EAAAN,EAAApC,GAAA,GAKA,OAHA8E,GAAApC,EAAAa,QAAA,EAAAuB,EAAA/C,UAAA+C,IACApC,IAAAa,OAAA,EAAAb,EAAAX,OAAA+C,EAAA/C,SAEAW,GAIAtF,EAAA2H,QAAA,SAAA/E,GACA,OAAAoC,EAAApC,GAAA,IAaA,IAAAuD,EAAA,WAAAA,QAAA,GACA,SAAAyB,EAAAhB,EAAAiB,GAAkC,OAAAD,EAAAzB,OAAAS,EAAAiB,IAClC,SAAAD,EAAAhB,EAAAiB,GAEA,OADAjB,EAAA,IAAAA,EAAAgB,EAAAjD,OAAAiC,GACAgB,EAAAzB,OAAAS,EAAAiB,qCC7NA,IAAAC,EAGAA,EAAA,WACA,OAAAvH,KADA,GAIA,IAEAuH,KAAA,IAAAC,SAAA,iBACC,MAAA5H,GAED,iBAAA6H,SAAAF,EAAAE,QAOA/H,EAAAD,QAAA8H,iGCnBA,SAAAxD,QAAA2D,QAcA3D,QAAAhB,UAAAgB,QAAAzB,IAAA,WAA+C,YAE/C,MAAAqF,GAAWxH,oBAAQ,GACnBkC,KAAalC,oBAAQ,GACrByH,KAAazH,oBAAQ,GACrB0H,WAAmB1H,oBAAQ,GAC3B2H,YAAoB3H,oBAAQ,GAC5B4H,OAAe5H,oBAAQ,GACvB6H,IAAA,UAAAjE,QAAArB,SAAA,YAMAqB,QAAAkE,oBAAAlE,QAAAkE,mBAAA,qBAGA,IAAAC,eAAAC,OAAA,EAiuBA,SAAAC,iBAAAC,EAAAC,GAGA,IAFA,IAAAC,EACAC,GAAA,EACA,OAAAD,EAAAL,eAAAO,eAAAJ,KACAC,GACAA,EAAAI,MACAR,eAAAS,iBAAAJ,EAAAD,EAAAM,OAAA,GACAZ,SAGAE,eAAAW,QAAAN,KAAAC,GAAA,GAEA,OAAAA,EAMA,SAAAM,cACA,OACAC,SAAA,EACAC,UAAA,EACAC,UAAA,EACAC,WAAA,EACAC,UAAA,EACAC,WAAA,EACAC,YAAA,EACAC,aAAA,EACAC,SAAA,EACAC,UAAA,EACAC,aAAA,EACAC,cAAA,EACAC,aAAA,EACAC,cAAA,GASA,SAAAC,QAAArH,GACA,MAAA6D,EAAAtC,QAAA+F,SACAtH,IACA,MAAAuH,EAAAhG,QAAA+F,OAAAzD,GACA,WAAA0D,EAAA,GAAAA,EAAA,GAMA,SAAAC,WAAAC,GACA,OAAAA,KAAA,KAAAC,QAAA,eAMA,SAAAC,WAAAC,EAAAC,GACA,SAAAC,EAAAL,EAAAM,GACA,OAAAP,WAAAC,IAEAI,GAAAtG,QAAAyG,QAAA9B,MAAA,CACA,eAAA4B,EAAAF,EAAArB,SAAAqB,EAAApB,WACA,eAAAsB,EAAAF,EAAAnB,UAAAmB,EAAAlB,YACA,eAAAoB,EAAAF,EAAAjB,UAAAiB,EAAAhB,YACA,eAAAkB,EAAAF,EAAAf,YAAAe,EAAAd,cACA,eAAAgB,EAAAF,EAAAb,SAAAa,EAAAZ,WACA,eAAAc,EAAAF,EAAAX,aAAAW,EAAAV,eACA,eAAAY,EAAAF,EAAAT,aAAAS,EAAAR,gBACApE,KAAAwC,UAvyBA,MACA,IACAE,eAAqB/H,oBAAQ,IAC1B,MAAAP,GACH,IACMO,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,sCAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAAS8K,SAAA,CAAYC,QAAAtI,KAAAmD,KAAoB,IAAS,8BAC1DrF,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,6CAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IACdsI,eAAuB/H,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,qCAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAC/BuI,OAAA,EACK,MAAAyC,MACL,IACA1C,eAAA2C,KAAA,+BACO,MAAAjL,GAGP,MADAA,EAAAkL,MAAAF,KAAAE,MAAA,UAAAlL,EAAAkL,MACAlL,MAfA,GAsBAH,QAAAsL,UAAmB,EAGnBtL,QAAA0I,YAGA1I,QAAAuL,QAAAvL,QAAAsL,SAAqC,QAAiB5K,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,8CAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAAiBoL,QAG/EvL,QAAAwL,QAAkB9K,oBAAQ,IAG1BV,QAAAyL,cAAA,qBAGAzL,QAAA0L,cAAAjD,eAAAkD,eAGA3L,QAAA4L,qBAAA,EAGA5L,QAAA6L,mBAAA,EAGA7L,QAAA8L,aAAA9L,QAAAsL,SAA0ChK,OAAA,CAAAyK,MAAA,0qxBAAAC,YAAA,6pFAAAC,gBAAA,iVAAAC,gBAAA,q5DAAAC,yBAAA,ko+CAAAC,gBAAA,qCAAAC,SAAA,wk4CAAAC,SAAA,k2OAAAC,KAAA,upBAAAC,YAAA,4RAAAC,MAAA,itBAAAC,WAAA,88EAAAC,KAAA,+EAAAC,SAAA,ukCAAAC,IAAA,yxOAAAC,KAAA,mn6FAAAC,OAAA,q7DAAAC,OAAA,yiPAAAC,UAAA,ilCAAAC,OAAA,2YAAAC,GAAA,umFAAAC,YAAA,qtDAAAC,gBAAA,6IAAAC,gBAAA,4BAAAC,gBAAA,4BAAAC,gBAAA,kHAAAC,UAAA,krRAAAC,YAAA,uPAAAC,UAAA,46DAAAC,UAAA,knpBAAAC,IAAA,0sMAAAC,iBAAA,6wBAAAC,gBAAA,wTAAAC,kBAAA,ghFAAAC,OAAA,46oBAAAC,OAAA,yyGAAAC,MAAA,2aAAAC,WAAA,i1hCAAAC,aAAA,2sBAAAC,YAAA,0qEAAAC,cAAA,y5PAAAC,cAAA,mrpBAAAC,YAAA,8iJAAAC,cAAA,goGAAAC,OAAA,sFAAc,MACxD,MAAAC,EAAAhM,KAAAmD,KAA2B,IAAS,uBACpC8I,EAAmBnO,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,mCAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAAM2O,KAAA,gBAAwBjM,IAAA+L,IACzDG,EAAA,GAEA,OADAF,EAAAG,QAAAC,GAAAF,EAAAE,EAAAC,QAAA,aAAAhH,GAAAiH,aAAAvM,KAAAmD,KAAA6I,EAAAK,GAAA,SACAF,GALwD,GASxD/O,QAAAoP,gBAAApP,QAAAsL,SAA6ChK,OAAA,CAAA+N,SAAA,sssFAAAC,SAAA,0z3BAAkB,MAC/D,MAAAC,EAAA3M,KAAAmD,KAA2B,IAAS,YACpC,OACAsJ,SAAAnH,GAAAiH,aAAAvM,KAAAmD,KAAAwJ,EAAA,iCACAD,SAAApH,GAAAiH,aAAAvM,KAAAmD,KAAAwJ,EAAA,mCAJ+D,GAS/DvP,QAAAwP,cAAA,EAAAC,EAAAjE,KACA,iBAAAiE,MAAA,CAA8CC,WAAAD,IAC9C,MAAA7E,EAAAtJ,OAAAY,OAAA,CACA6I,OAAA4E,qBACA9G,OAAA8G,uBAEA,IAAAnM,EAAA,CACA,wBACA,qBAcA,OAZAlC,OAAAsO,KAAApE,GAAA,IAA2BwD,QAAA7M,IAC3B,IAAA0N,EAAArE,EAAArJ,GACAkE,MAAAyJ,QAAAD,KAAAb,QAAAa,GAAArM,EAAAgC,KAAA,KAAArD,EAAA4N,OAAAF,KACArM,EAAAgC,KAAA,KAAArD,EAAA4N,OAAAF,MAEA7P,QAAAgQ,KAAAxM,EAAA4D,OAAA9F,OAAAsO,KAAAH,IAAA,CACA1E,OAAAH,EAAAG,OACAlC,OAAA+B,EAAA/B,OACAoH,SAAA9O,GAAAsO,EAAAhN,eAAAtB,GAAAsO,EAAAtO,GAAA,KACA+O,UAAA,CAAA/O,EAAAgP,IAAAvF,EAAAzJ,GAAAgP,EACAC,UAAA,SAEAxF,IAIA5K,QAAAgQ,KAAA,SAAAxM,EAAAgI,EAAA6E,GACA,mBAAA7E,GACA6E,EAAA7E,EACAA,EAAA,IACGA,IACHA,EAAA,IAGA,MAAAT,EAAAS,EAAAT,QAAAzG,QAAAyG,OACAlC,EAAA2C,EAAA3C,QAAAvE,QAAAuE,OACAoH,EAAAzE,EAAAyE,UAAAK,EACAJ,EAAA1E,EAAA0E,WAAAK,EACAH,EAAA5E,EAAA4E,WAAAI,EACA7F,EAAAa,EAAAb,OAAAtB,cAGA,IAAA0B,EAAA,MAAArH,MAAA,sCACA,IAAAmF,EAAA,MAAAnF,MAAA,sCAEA,MAAA+M,EAAApI,YAAAqI,MAAAlN,EAAAxD,QAAAwL,SACAmF,EAAAF,EAAAjF,QAiCA,GAhCAhI,EAAAiN,EAAA9K,UACAgL,EAAAC,SACAxI,WAAA2C,OAAA8F,UACAzI,WAAAS,OAAAgI,WAAA,GAEAzI,WAAA2C,OAAA3C,WAAA5B,KAAAuE,GACA3C,WAAAS,OAAAT,WAAA5B,KAAAqC,IAIA4H,EAAAK,QAAAnM,QACA8L,EAAAK,QAAA9B,QAAA+B,IACAlI,EAAAI,MAAAb,WAAAS,OAAAmI,OAAA,6BAAAD,EAAA,IAAAxI,OAKAkI,EAAAQ,SAAAtM,QACAkE,EAAAI,MAAAb,WAAAS,OAAAmI,OAAA,6CAAAP,EAAAQ,SAAAlL,KAAA,KAAAwC,KAIA8H,MAAA,SAAAa,GACA,IAAAlG,EAAA,EAKA,OAJAkG,IACArI,EAAAI,MAAAb,WAAAS,OAAAsI,IAAA,WAAAD,EAAA7F,MAAA6D,QAAA,gBAAA3G,KACAyC,EAAA,GAEAA,IAIA2F,EAAApF,QAEA,OADAR,EAAA9B,MAAA,WAAAjJ,QAAAuL,SAAA7C,MAAA,WAAAH,KACA8H,EAAA,MAGA,GAAAM,EAAAS,OAAA5N,EAAAmB,OAAA,CACA,IAAA0M,EAAAV,EAAAS,KAAArG,EAAAlC,EACAyI,EAAAX,EAAAS,KAAAhJ,WAAA2C,OAAA3C,WAAAS,OAcA,OAbAwI,EAAApI,MAAA,CACAqI,EAAAC,MAAA,UACA,KAAAD,EAAAE,KAAA,oCACA,GACAF,EAAAC,MAAA,YACA,KAAAD,EAAAE,KAAA,mBACA,KAAAF,EAAAE,KAAA,8CACA,KAAAF,EAAAE,KAAA,iDACA,GACAF,EAAAC,MAAA,YACAnK,OACAiB,YAAA+I,KAAApR,QAAAwL,QAAA,GAAAjD,MACAxC,KAAAwC,UACA8H,EAAA,MAIA,IAAAnI,GAAAiH,aAAA,CACA,GAAAc,IAAAK,EAAA,MAAA5M,MAAA,wCACA,GAAAwM,IAAAK,EAAA,MAAA7M,MAAA,yCACA,GAAA0M,IAAAI,EAAA,MAAA9M,MAAA,yCAIA,MAAA+N,EAAAd,EAAAc,QAAA7O,KAAAiB,QAAA8M,EAAAc,SAAA,IAGAC,EAAA,GACAf,EAAAgB,WACAhB,EAAAgB,UAAA3C,QAAA2C,GACAD,EAAAlM,KACQ9E,oBAAA,GAAAA,CACEkC,KAAAqD,WAAA0L,IAAAjL,QACViL,EACA/O,KAAAmD,KAAAzB,QAAAzB,MAAA8O,MAYA,IAAAC,EAAA,KAGAtQ,OAAAsO,KAAA5P,QAAA8L,cAAAkD,QAAA6C,IACAA,EAAAC,QAAA,UACAnH,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UACA/R,QAAA8L,aAAA+F,GACA7R,QAAA0L,cAAAmG,EAAA,OACA,EACAD,QAIA,MAAAI,EAAA,GACA,GAAArB,EAAAsB,IAAA,CACA,IAAAA,EAAAtB,EAAAsB,IACA,iBAAAA,QAAAnM,MAAA,MACAO,MAAA7D,UAAAgD,KAAA0M,MAAAF,EAAAC,EAAApF,IAAAoF,KAAAvL,SACA,QAAA9F,EAAA,EAAAuR,EAAAH,EAAArN,OAA6C/D,EAAAuR,IAAOvR,EAAA,CACpD,IACAiO,EADAD,EAAAoD,EAAApR,GAEAgO,EAAAwD,SAAA,QACAvD,EAAA,CAAAjM,KAAA6E,SAAAmH,IACAA,EAAAhM,KAAA2E,QAAAqH,IAEAC,EAAAuB,EAAAxB,GAEA,QAAAyD,EAAA,EAAAxR,EAAAgO,EAAAlK,OAA0C0N,EAAAxR,IAAOwR,EAAA,CACjD,IAAAR,EAAAhD,EAAAwD,GACAC,EAAArC,EAAA4B,EAAAjD,GACA,UAAA0D,EAAA,OAAAjC,EAAA3M,MAAA,iBAAAmO,EAAA,iBACAlH,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UACAO,EACAtS,QAAA0L,cAAAmG,GACA,EACAD,OAQA,SAAAW,IAEA,IADA,IAAAC,EAAAC,EACA,OAAAD,EAAAZ,EAAAc,aAAA,CAGA,GAAAF,EAAAG,WAAA3S,QAAA0L,eAAA,CACA,MAAAkH,EAAAJ,EAAAK,UAAA7S,QAAA0L,cAAA/G,QACAmO,EAAAN,EAAAK,UAAA7S,QAAA0L,cAAA/G,QAAA,SACA,GAAA3E,QAAA8L,aAAArJ,eAAAmQ,GACAH,EAAAzS,QAAA8L,aAAA8G,GACAJ,EAAAxS,QAAA0L,cAAAkH,EAAA,WACS,GAAA5S,QAAA8L,aAAArJ,eAAAqQ,GACTL,EAAAzS,QAAA8L,aAAAgH,GACAN,EAAAxS,QAAA0L,cAAAoH,EAAA,WAEA,QAAAlS,EAAA,EAAAuR,EAAAH,EAAArN,OAAmD/D,EAAAuR,IAAOvR,EAAA,CAE1D,WADA6R,EAAAxC,EAAA2C,EAAA,MAAAZ,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAkH,EAAA,MACA,MAGA,WADAH,EAAAxC,EAAA6C,EAAA,MAAAd,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAoH,EAAA,MACA,YAOO,CACP,MAAAF,EAAAJ,EACAM,EAAAN,EAAA,SAEA,WADAC,EAAAxC,EAAA2C,EAAA,MAAAnB,IAEAe,EAAAI,EAAA,WAGA,WADAH,EAAAxC,EAAA6C,EAAA,MAAArB,IAEAe,EAAAM,EAAA,WACW,IAAAF,EAAAD,WAAA,KACX,GAAA3S,QAAA8L,aAAArJ,eAAAmQ,GACAH,EAAAzS,QAAA8L,aAAA8G,GACAJ,EAAAxS,QAAA0L,cAAAkH,EAAA,WACa,GAAA5S,QAAA8L,aAAArJ,eAAAqQ,GACbL,EAAAzS,QAAA8L,aAAAgH,GACAN,EAAAxS,QAAA0L,cAAAoH,EAAA,WAEA,QAAAlS,EAAA,EAAAuR,EAAAH,EAAArN,OAAuD/D,EAAAuR,IAAOvR,EAAA,CAC9DoR,EAAApR,GAEA,WADA6R,EAAAxC,EAAA2C,EAAA,MAAAZ,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAkH,EAAA,MACA,MAGA,WADAH,EAAAxC,EAAA6C,EAAA,MAAAd,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAoH,EAAA,MACA,QAQA,SAAAL,EACA,OAAApC,EAAA3M,MAAA,gBAAA8O,EAAA,oBAEA7H,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACA3B,eAAAsJ,UAAAU,EAAAD,GAAA,EAAAZ,KAGA,GAAAjJ,iBAAAiJ,EAAA/I,GACA,OAAAwH,EAAA3M,MAAA,gBAKA,CACA,IAAAqP,EAAAhD,OAAAY,EAAAqC,SACAC,EAAAjT,QAAA8L,aAAA,YAAAiH,GACA,SAAAE,GAEA,OADAA,EAAAhD,EAAA8C,EAAA,MAAAtB,IAEA,OAAApB,EAAA3M,MAAA,qBAAAqP,EAAA,iBAGApI,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UAAAkB,EAAAF,GAAA,EAAAnB,KAKA,QAAAhR,EAAA,EAAAuR,EAAA3O,EAAAmB,OAAkC/D,EAAAuR,IAAOvR,EAAA,CACzC,MAAAqE,EAAAzB,EAAA5C,GAEA,IAAA4R,EAAAzC,OAAA9K,GAAAiK,QAAA,WAAAA,QAAA,iBAGAuD,EAAAxC,EAAAuC,EAAA,MAAAf,GACA,UAAAgB,EAAA,CAEA,WADAA,EAAAxC,EAAAuC,EAAA,YAAAf,IAEA,OAAApB,EAAA3M,MAAA,eAAA8O,EAAA,oBAEAA,GAAA,iBAGAA,GAAA,MAGA7H,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UAAAU,EAAAD,GAAA,EAAAZ,KAKA,CACA,IAAA5G,EAAAuH,IACA,GAAAvH,EAAA,OAAAA,GAlLA,SAAA7J,KAAAwP,GACAe,EAAA1C,QAAA2C,IACA,mBAAAA,EAAAxQ,IAAAwQ,EAAAxQ,MAAAwP,KAoLAuC,CAAA,aAAAtB,GAGA,CACA,IAAA5G,EAAAuH,IACA,GAAAvH,EAAA,OAAAA,EAIA,MAAAmI,EAAA1K,eAAA2K,cAAAxB,GAGA,IAAAyB,EAAA,EACAC,EAAA,EACA3C,EAAA4C,WACAF,EAAArT,QAAA4L,qBACA0H,EAAAtT,QAAA6L,oBAEA,iBAAA8E,EAAA0C,gBACAA,EAAA1C,EAAA0C,eAEA,iBAAA1C,EAAA2C,cACAA,EAAA3C,EAAA2C,aAEAD,EAAArM,KAAAC,IAAAD,KAAAwM,IAAAH,EAAA,MACAC,EAAAtM,KAAAC,IAAAD,KAAAwM,IAAAF,EAAA,MAGA,MAAAG,EAAAhL,eAAAiL,gBAiBA,GAhBAjL,eAAAkL,UAAAF,EAAA,GACAhL,eAAAmL,YAAAH,EAAA9C,EAAAkD,UACApL,eAAAqL,gBAAAL,EAAA9C,EAAAoD,cACAtL,eAAAuL,gBAAAP,EAAA9C,EAAAsD,cACAxL,eAAAyL,eAAAT,EAAA9C,EAAAwD,aACA1L,eAAA2L,cAAAX,EAAA9C,EAAA0D,aAAA,GACA5L,eAAA6L,aAAAb,EAAA,MAAA9C,EAAA4D,WACA9L,eAAA+L,sBAAAf,EAAAJ,EAAAC,GAGA7K,eAAAgM,eAAAhB,EAAA,qBACAhL,eAAAgM,eAAAhB,EAAA,uBACAhL,eAAAgM,eAAAhB,EAAA,+BACAhL,eAAAgM,eAAAhB,EAAA,+BAGA9C,EAAA+D,IAAA,CACA,IAAAC,EAAAhE,EAAA+D,IACA,QAAA9T,EAAA,EAAAuR,EAAAwC,EAAAhQ,OAAuC/D,EAAAuR,IAAOvR,EAAA,CAC9C,IAAAgU,EAAAD,EAAA/T,GACA8B,EAAAkS,EAAA9C,QAAA,KACA,GAAApP,EAAA,SAAA2N,EAAA3M,MAAA,iBAAAkR,EAAA,kBACA,IAAAzT,EAAAyT,EAAA/B,UAAA,EAAAnQ,GAAAgE,OACAmO,EAAAD,EAAA/B,UAAAnQ,EAAA,GAAAgE,OACA,IAAAvF,EAAAwD,OAAA,OAAA0L,EAAA3M,MAAA,iBAAAkR,EAAA,kBACAnM,eAAAgM,eAAAhB,EAAAtS,EAAA0T,IAKA,IAWA5U,EAXAoE,EAAAsM,EAAAmE,OACA,SAAAzQ,EAAA,CACA,iBAAAA,QAAAyB,MAAA,MACA,QAAAlF,EAAA,EAAAuR,EAAA9N,EAAAM,OAAwC/D,EAAAuR,IAAOvR,EAAA,CAC/C,IAAAO,EAAAkD,EAAAzD,GAAA8F,OACAqO,EAAAtM,eAAA,WAAAtH,EAAA+N,QAAA,WAAA8F,eACA,IAAAD,EAAA,OAAA1E,EAAA3M,MAAA,YAAAvC,EAAA,kBACAsH,eAAAwM,cAAAxB,EAAAsB,IAKApK,EAAAd,eACA,IACAc,EAAAf,aAAAQ,QAAA,KACAnK,EAAAwI,eAAAyM,eAAA/B,EAAAM,KAEG,MAAAtT,GACH,OAAAkQ,EAAAlQ,GAEA,GAAAwI,iBAAAiJ,EAAA/I,GAEA,OADA5I,KAAAkV,UACA9E,EAAA3M,MAAA,kBAeA,GAXAiN,EAAAyE,WACAzK,EAAAV,gBACAU,EAAAX,cAAAI,QAAA,KACA,IAAAnK,EAAAmV,WAEA,OADAnV,EAAAkV,UACA9E,EAAA3M,MAAA,sBAMA,UAAAiN,EAAA0E,SACA1K,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAqV,UAAA,4BAEG,UAAA3E,EAAA0E,SACH1K,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAqV,UAAA,yBAEG,aAAA3E,EAAA0E,SAEH,OADApV,EAAAkV,UACA9E,EAAA3M,MAAA,2BAKA2P,GAAA,GAAAC,GAAA,KAAAD,EAAA,GAEApT,EAAAsV,iBAAAlC,GACApT,EAAAuV,eAAAlC,GACArT,EAAAwV,aAAA9E,EAAA+E,OAEA,IAAAJ,EAAA,GA8BA,GA7BA3E,EAAA2E,YACA,iBAAA3E,EAAA2E,YACA3E,EAAA2E,UAAA3E,EAAA2E,UAAAxP,MAAA,MAEA6K,EAAA2E,UAAA3Q,QACAgM,EAAA2E,UAAAtG,QAAA2G,IACAL,EAAAxD,QAAA6D,GAAA,GACAL,EAAA9P,KAAAmQ,OAMAtC,EAAA,GAAAC,EAAA,KACA3I,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAsT,cAKA+B,EAAA3Q,SACAgG,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAqV,YAAAzI,IAAA8I,KAAAjP,aAKAiK,EAAAiF,OAAA,CACA,IAAAC,GAAA,EACAC,GAAA,EAaA,GAXA,MAAAnF,EAAAoF,UACA,WAAAC,KAAArF,EAAAoF,UAAA,MAAApF,EAAAsF,SACAtF,EAAAsF,SAAAtF,EAAAoF,QACO,QAAAC,KAAArF,EAAAoF,UAAA,MAAApF,EAAAuF,UACPvF,EAAAuF,UAAAvF,EAAAoF,QACO,MAAApF,EAAAwF,aACPxF,EAAAwF,WAAAxF,EAAAoF,UAKA,MAAApF,EAAAwF,WAAA,CACA,IAMAC,EANAC,EAAA,MAAA1F,EAAA4D,UACA5D,EAAA4D,UAAA5P,OACAgM,EAAA4D,UACA3R,KAAA6E,SAAAkJ,EAAAwF,YAAA,OACA,KAiBA,GAdAxL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAgM,EAAAnW,EAAAqW,SAAAD,KAGA1F,EAAAwF,WAAAxR,OACAuL,EAAAS,EAAAwF,WAAAC,EAAAxL,OAAA6G,IAEA8E,EAAAH,EAAAxL,QACAiL,GAAA,GAEAC,GAAA,EAGA,MAAAM,EAAA7B,UACA,GAAA5D,EAAAwF,WAAAxR,OAAA,CACA,IAAA4P,EAAAiC,KAAA9F,MAAA0F,EAAA7B,WACAA,EAAAkC,WAAAzW,QAAAyL,cACA8I,EAAA9E,QAAAT,QAAA,CAAA7N,EAAAmF,KACA,IAAAoQ,EAAA,KACA,GAAAvV,EAAAwR,WAAA3S,QAAA0L,eAAA,CACA,IAAAiL,EAAAxV,EAAA0R,UAAA7S,QAAA0L,cAAA/G,QAAAuK,QAAA,YACA,GAAAlP,QAAA8L,aAAArJ,eAAAkU,GACAD,EAAA1W,QAAA8L,aAAA6K,QAEA,QAAA/V,EAAA,EAAAuR,EAAAH,EAAArN,OAAyD/D,EAAAuR,GAEzD,QADAuE,EAAAzG,EAAA9O,EAAA0R,UAAA7S,QAAA0L,cAAA/G,QAAAqN,EAAApR,OADgEA,SAMhE8V,EAAAzG,EAAA9O,EAAAsQ,GAEA,UAAAiF,EACA,OAAArG,EAAA3M,MAAA,gBAAAvC,EAAA,iBAEAoT,EAAAqC,iBAAArC,EAAAqC,eAAA,IACArC,EAAAqC,eAAAtQ,GAAAoQ,IAEAxG,EAAAtN,KAAAmD,KACAnD,KAAA2E,QAAAoJ,EAAAwF,YACAvT,KAAA6E,SAAA4O,IACAnH,QAAA,YAAAsH,KAAAK,UAAAtC,GAAA9C,QAEA5I,EAAAI,MAAA,+CAAAV,KAMA,SAAAoI,EAAAuF,UAAA,CACA,IAAAY,EACAnG,EAAAuF,UAAAvR,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA0M,EAAA7W,EAAA8W,YAEA7G,EAAAS,EAAAuF,UAAAY,EAAArF,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA0M,EAAA7W,EAAA8W,YAEAR,EAAAO,GACAjB,GAAA,GAEAC,GAAA,EAIA,SAAAnF,EAAAqG,QAAA,CACA,IAAAC,EACAtG,EAAAqG,QAAArS,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA6M,EAAAxO,eAAAyO,SAAA/D,KAEAjD,EAAAS,EAAAqG,QAAAC,EAAAxF,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA6M,EAAAxO,eAAAyO,SAAA/D,KAEAoD,EAAAU,GACApB,GAAA,GAEAC,GAAA,EAIA,SAAAnF,EAAAwG,QAAA,CACA,IAAAC,EACAzG,EAAAwG,QAAAxS,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAgN,EAAA3O,eAAA4O,SAAAlE,KAEAjD,EAAAS,EAAAwG,QAAAC,EAAA3F,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAgN,EAAA3O,eAAA4O,SAAAlE,KAEAoD,EAAAa,GACAvB,GAAA,GAEAC,GAAA,EAIA,SAAAnF,EAAAsF,WAAAH,EAAA,CACA,IAAAwB,EACA3G,EAAAsF,UAAAtF,EAAAsF,SAAAtR,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAkN,EAAArX,EAAAsX,WAEArH,EAAAS,EAAAsF,SAAAqB,EAAA7F,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAkN,EAAArX,EAAAsX,WAEAhB,EAAAe,KASA,OAJArX,EAAAkV,UACAxE,EAAAvG,SACAM,WAAAC,EAAA9B,GAEAwH,EAAA,MAEA,SAAAC,EAAArL,EAAAwM,GACA,IACA,IAAAiF,EAKA,OAJA/L,EAAApB,YACAoB,EAAArB,UAAAc,QAAA,KACAsM,EAAAxO,GAAAiH,aAAAvM,KAAAmD,KAAA0L,EAAAxM,GAAA,CAA8DuS,SAAA,WAE9Dd,EACK,MAAAvW,GACL,aAIA,SAAAoQ,EAAAtL,EAAAkL,EAAAsB,GACA,IAUA,OATA9G,EAAAlB,aACAkB,EAAAnB,WAAAY,QAAA,KACA9B,OAAA1F,KAAAmD,KAAA0L,EAAA7O,KAAA2E,QAAAtC,KACA,iBAAAkL,EACAjI,GAAAuP,cAAA7U,KAAAmD,KAAA0L,EAAAxM,GAAAkL,EAAA,CAAoEqH,SAAA,SAEpEtP,GAAAuP,cAAA7U,KAAAmD,KAAA0L,EAAAxM,GAAAkL,MAGA,EACK,MAAAhQ,GACL,UAIA,SAAAqQ,EAAAjJ,EAAAkK,GACA,IAAAiG,EACA,IAIA,OAHA/M,EAAArB,UAAAc,QAAA,KACAsN,EAAAxP,GAAAyP,YAAA/U,KAAAmD,KAAA0L,EAAAlK,IAAAnC,OAAA6J,GAAA,yBAAA+G,KAAA/G,MAEAyI,EACK,MAAAvX,GACL,UAIA,SAAAoW,EAAApG,GACAoG,EAAAqB,OACAjN,EAAAlB,aACA8M,EAAAqB,MAAA,GAEAjN,EAAAnB,WAAAY,QAAA,KACA,iBAAA+F,EACApF,EAAA9B,MAAAkH,EAAA,CAAgCqH,SAAA,SAEhCzM,EAAA9B,MAAAkH,OAsBAnQ,QAAA2I,kCAsBA3I,QAAAqJ,wBAEA/E,QAAA+F,SAAA/F,QAAA+F,OAAsC3J,oBAAQ,KAU9CV,QAAAoK,gBAOApK,QAAAuK,sBAkBAvK,QAAA0K,sBAEA,IAAAmN,iBAAA,IAAA5P,eAAA6P,OACA7P,OAAA6P,OAAAC,aAAA,SAAAlQ,GAAgD,WAAAI,OAAA6P,OAAAjQ,IAChD,SAAAA,GAAmB,WAAAmQ,WAAAnQ,IAGnB,SAAA8H,mBAAA5M,GACA,IAAAkV,EAAA,GA6BA,OA5BAA,EAAAhP,MAAA,SAAAiP,GAEA,GADAnV,KAAAmV,GACA,iBAAAA,EAAA,CACA,IAAAC,EAAAN,YAAA1P,KAAAxD,OAAAuT,IACA/P,KAAAc,MAAAiP,EAAAC,EAAA,GACAD,EAAAC,EAEA5X,KAAAiF,KAAA0S,IAEAD,EAAAG,MAAA,WACAH,EAAAtT,OAAA,GAEAsT,EAAAI,SAAA,WAEA,IADA,IAAAC,EAAA,EAAA1X,EAAA,EAAAuR,EAAA5R,KAAAoE,OACA/D,EAAAuR,GAAAmG,GAAA/X,KAAAK,KAAA+D,OACA,IAAAwT,EAAAN,YAAAS,GAEA,IADAA,EAAA1X,EAAA,EACAA,EAAAuR,GACAgG,EAAAtK,IAAAtN,KAAAK,GAAA0X,GACAA,GAAA/X,KAAAK,GAAA+D,SACA/D,EAEA,OAAAuX,GAEAF,EAAAM,SAAA,WACA,IAAAJ,EAAA5X,KAAA8X,WACA,OAAAlQ,KAAAqQ,KAAAL,EAAA,EAAAA,EAAAxT,SAEAsT,EAGAjY,QAAA2P,sCAGA3P,QAAAyY,WAAA,CACAC,cAAA,EACAC,eAAA,EACAC,mBAAA,EACAC,gBAAA,EACAC,eAAA,EACAC,kBAAA,EACAC,wBAAA,EACAC,OAAA,SACAhZ,OAAA,WACAiZ,OAAA,EACAC,MAAA,GACAC,SAAA,4FC13BA,IAAAjR,EAAAnI,EAOAmI,EAAAxD,OAAA,SAAAsJ,GAGA,IAFA,IAAApG,EAAA,EACA5G,EAAA,EACAL,EAAA,EAAmBA,EAAAqN,EAAAtJ,SAAmB/D,GACtCK,EAAAgN,EAAAoL,WAAAzY,IACA,IACAiH,GAAA,EACA5G,EAAA,KACA4G,GAAA,EACA,cAAA5G,IAAA,cAAAgN,EAAAoL,WAAAzY,EAAA,OACAA,EACAiH,GAAA,GAEAA,GAAA,EAEA,OAAAA,GAUAM,EAAAqQ,KAAA,SAAAL,EAAAvR,EAAAC,GAEA,GADAA,EAAAD,EACA,EACA,SAKA,IAJA,IAGA9E,EAHA0C,EAAA,KACA0T,EAAA,GACAtX,EAAA,EAEAgG,EAAAC,IACA/E,EAAAqW,EAAAvR,MACA,IACAsR,EAAAtX,KAAAkB,EACAA,EAAA,KAAAA,EAAA,IACAoW,EAAAtX,MAAA,GAAAkB,IAAA,KAAAqW,EAAAvR,KACA9E,EAAA,KAAAA,EAAA,KACAA,IAAA,EAAAA,IAAA,OAAAqW,EAAAvR,OAAA,OAAAuR,EAAAvR,OAAA,KAAAuR,EAAAvR,MAAA,MACAsR,EAAAtX,KAAA,OAAAkB,GAAA,IACAoW,EAAAtX,KAAA,YAAAkB,IAEAoW,EAAAtX,MAAA,GAAAkB,IAAA,OAAAqW,EAAAvR,OAAA,KAAAuR,EAAAvR,KACAhG,EAAA,QACA4D,MAAA,KAAAgB,KAAAuK,OAAAuJ,aAAApH,MAAAnC,OAAAmI,IACAtX,EAAA,GAGA,OAAA4D,GACA5D,GACA4D,EAAAgB,KAAAuK,OAAAuJ,aAAApH,MAAAnC,OAAAmI,EAAA/S,MAAA,EAAAvE,KACA4D,EAAAuB,KAAA,KAEAgK,OAAAuJ,aAAApH,MAAAnC,OAAAmI,EAAA/S,MAAA,EAAAvE,KAUAuH,EAAAc,MAAA,SAAAgF,EAAAkK,EAAAG,GAIA,IAHA,IACAiB,EACAC,EAFA5S,EAAA0R,EAGA1X,EAAA,EAAmBA,EAAAqN,EAAAtJ,SAAmB/D,GACtC2Y,EAAAtL,EAAAoL,WAAAzY,IACA,IACAuX,EAAAG,KAAAiB,EACSA,EAAA,MACTpB,EAAAG,KAAAiB,GAAA,MACApB,EAAAG,KAAA,GAAAiB,EAAA,KACS,cAAAA,IAAA,eAAAC,EAAAvL,EAAAoL,WAAAzY,EAAA,MACT2Y,EAAA,aAAAA,IAAA,UAAAC,KACA5Y,EACAuX,EAAAG,KAAAiB,GAAA,OACApB,EAAAG,KAAAiB,GAAA,UACApB,EAAAG,KAAAiB,GAAA,SACApB,EAAAG,KAAA,GAAAiB,EAAA,MAEApB,EAAAG,KAAAiB,GAAA,OACApB,EAAAG,KAAAiB,GAAA,SACApB,EAAAG,KAAA,GAAAiB,EAAA,KAGA,OAAAjB,EAAA1R,qBCvGA,SAAAtC,GAAA,IAAAmV,OAAA,IAAAnV,MAAA,GACAoV,EAAAD,EAAAlW,KAAA,OAAAkW,EAAAlW,IAEA,SAAAiD,EAAAyR,EAAA0B,GACA,IAAAC,EAAAD,GAAA,GAUA,OATAC,EAAA/I,UAAAoH,OAAA9O,OAAAuQ,EACAE,EAAAC,KAAAnD,IAAAkD,EAAA/I,UAAA7Q,EAAA8Z,KAAApD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAzI,IAAAuF,IAAAkD,EAAA/I,UAAA7Q,EAAAga,IAAAtD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAK,MAAAvD,IAAAkD,EAAA/I,UAAA7Q,EAAAka,MAAAxD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAA5I,OAAA0F,IAAAkD,EAAA/I,UAAA7Q,EAAAma,OAAAzD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAQ,KAAA1D,IAAAkD,EAAA/I,UAAA7Q,EAAAqa,KAAA3D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAU,QAAA5D,IAAAkD,EAAA/I,UAAA7Q,EAAAua,QAAA7D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAApI,KAAAkF,IAAAkD,EAAA/I,UAAA7Q,EAAAwa,KAAA9D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAArI,MAAAmF,IAAAkD,EAAA/I,UAAA7Q,EAAAya,MAAA/D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAGA5Z,EAAA+K,OAAAvE,EAAAiT,EAAA1O,OAAA/K,GACAA,EAAA6I,OAAArC,EAAAiT,EAAA5Q,QACA7I,EAAAwG,OAEAxG,EAAA8Z,KAAA,QACA9Z,EAAAga,IAAA,QACAha,EAAAka,MAAA,QACAla,EAAAma,OAAA,QACAna,EAAAqa,KAAA,QACAra,EAAAua,QAAA,QACAva,EAAAwa,KAAA,QACAxa,EAAAya,MAAA,QACAza,EAAA+Z,MAAA,wCCmDA/Z,EAAA0Q,MArEA,SAAAlN,EAAAkX,GACA,IAAAlP,EAAA,GACAsF,EAAA,GACAnL,UAAA,GACAsL,EAAA,GAGA0D,EAAA,GACArT,OAAAsO,KAAA8K,GAAA1L,QAAA7M,IACA,IAAAA,EAAAwQ,WAAA,MACA,IAAAgI,EAAAD,EAAAvY,GACA,MAAAwY,EAAA9F,QACA,iBAAA8F,EAAA9F,MAAAF,EAAAgG,EAAA9F,OAAA1S,EACAkE,MAAAyJ,QAAA6K,EAAA9F,QAAA8F,EAAA9F,MAAA7F,QAAA6F,GAAAF,EAAAE,GAAA1S,IAEA,MAAAwY,EAAAC,UAAApP,EAAArJ,GAAAwY,EAAAC,YAIA,QAAAha,EAAA,EAAAuR,GAAA3O,IAAA2B,SAAAR,OAAmD/D,EAAAuR,IAAOvR,EAAA,CAC1D,IAAAmQ,EAAAvN,EAAA5C,GACA,SAAAmQ,EAAA,GAAsBnQ,EAAK,MAC3B,IAAiD+Z,EAAAxY,EAAjD0Y,EAAA,gDAAiD3V,KAAA6L,GACjD,GAAA8J,EACAH,EAAA3J,GAAA4J,EAAAD,EAAAvY,EAAA4O,GACA,MAAA8J,EAAA,IACAF,EAAAD,EAAAvY,EAAAwS,EAAAkG,EAAA,GAAAhI,UAAA,OACA,MAAAgI,EAAA,KAAArX,EAAA5C,KAAAia,EAAA,IACO,MAAAA,EAAA,KACPF,EAAAD,EAAAvY,EAAA0Y,EAAA,GAAAhI,UAAA,MACA,MAAAgI,EAAA,KAAArX,EAAA5C,KAAAia,EAAA,QAEK,CACL,OAAA9J,EAAAsI,WAAA,GACA,CAAY1T,UAAAH,KAAAuL,GAAqB,SADjC4J,EAAAD,EAAAvY,EAAA4O,GAGA,GAAA4J,EAAA,CACA,SAAAA,EAAAG,MAAA,MAAAH,EAAAG,KAAAtP,EAAArJ,IAAA,OAEA,GAAAvB,EAAA,EAAA4C,EAAAmB,QAAA,IAAAnB,EAAA5C,EAAA,GAAAyY,WAAA,GACA,OAAAsB,EAAAG,MACA,QAAAtP,EAAArJ,GAAA4Y,SAAAvX,IAAA5C,GAAA,IAA6D,MAC7D,QAAA4K,EAAArJ,IAAAqJ,EAAArJ,IAAA,IAAAiF,OAAA2T,SAAAvX,IAAA5C,GAAA,KAA0F,MAC1F,QAAA4K,EAAArJ,GAAA6Y,WAAAxX,IAAA5C,IAA2D,MAC3D,QAAA4K,EAAArJ,IAAAqJ,EAAArJ,IAAA,IAAAiF,OAAA4T,WAAAxX,IAAA5C,KAAwF,MACxF,QAAA4K,EAAArJ,GAAA4N,OAAAvM,IAAA5C,IAAuD,MACvD,QAAA4K,EAAArJ,IAAAqJ,EAAArJ,IAAA,IAAAiF,OAAA5D,IAAA5C,GAAAkF,MAAA,MAAuF,MACvF,QAAAgL,EAAAtL,KAAAuL,KAAuCnQ,OAGvC,OAAA+Z,EAAAG,MACA,QACA,QAAAtP,EAAArJ,GAAAwY,EAAAC,SAAA,EAAyD,MACzD,QAAApP,EAAArJ,GAAAwY,EAAAC,SAAA,GAA0D,MAC1D,QACA,QACA,QAAApP,EAAArJ,GAAAqJ,EAAAoP,SAAA,GAA2D,MAC3D,QAAA9J,EAAAtL,KAAAuL,GAIA4J,EAAA9Y,OAAAP,OAAAsO,KAAA+K,EAAA9Y,OAAAmN,QAAAmD,GAAA3G,EAAA2G,GAAAwI,EAAA9Y,MAAAsQ,SACKrB,EAAAtL,KAAAuL,GAEL,KAAAnQ,EAAAuR,GAAAlB,EAAAzL,KAAAhC,EAAA5C,MAEA,OAAU4K,UAAAsF,UAAAnL,oBAAAsL,aA8BVjR,EAAAoR,KAxBA,SAAAsJ,EAAAlP,GACAA,MAAA,IACA,IAAAyP,EAAAzP,EAAAyP,QAAA,EACAC,EAAA1P,EAAA0P,SAAA,GACAC,EAAA3P,EAAA2P,KAAA,KACAC,EAAA,GAgBA,OAfA9Z,OAAAsO,KAAA8K,GAAA1L,QAAA7M,IACA,IAAAwY,EAAAD,EAAAvY,GACA,SAAAwY,EAAAU,YAAA,CAEA,IADA,IAAA3E,EAAA,GACAA,EAAA/R,OAAAsW,GAAAvE,GAAA,IAGA,IAFAA,GAAA,KAAAvU,EACAwY,EAAA9F,QAAA6B,GAAA,MAAAiE,EAAA9F,OACA6B,EAAA/R,OAAAuW,GAAAxE,GAAA,IACArQ,MAAAyJ,QAAA6K,EAAAU,aACAD,EAAA5V,KAAAkR,EAAAiE,EAAAU,YAAA,GAAAV,EAAAU,YAAAlW,MAAA,GAAA0H,IAAAyO,IACA,QAAA1a,EAAA,EAAuBA,EAAAsa,IAAata,EAAA0a,EAAA,IAAAA,EACpC,OAAAH,EAAAG,IACOvV,KAAA,KACFqV,EAAA5V,KAAAkR,EAAAiE,EAAAU,gBAELD,EAAArV,KAAAoV,sBCxGA,SAAA7W,GAwBA,IAAA1B,EAAWlC,EAAQ,GACnBwH,EAASxH,EAAQ,GACjB6a,EAAAR,SAAA,UAEA9a,EAAAD,QAAA,SAAAsI,EAAA5F,EAAA+N,EAAA+K,GACA/K,GAAA,iBAAAA,IACAA,EAAA,CAAY1O,KAAA0O,IAEZ,IAAA1O,EAAA0O,EAAA1O,UACA0Z,IAAA1Z,IACAA,EAAAwZ,GAAAjX,EAAAN,SAEAwX,MAAA,MACA9Y,EAAAE,EAAAiB,QAAAnB,GACA,IACAwF,EAAAwT,UAAAhZ,EAAAX,GACAyZ,KAAA9Y,EACG,MAAAiZ,GACH,OAAAA,EAAA3Q,MACA,aACAwQ,EAAAlT,EAAA1F,EAAA2E,QAAA7E,GAAA+N,EAAA+K,GACAlT,EAAA5F,EAAA+N,EAAA+K,GACA,MACA,QACA,IAAAI,EACA,IACAA,EAAA1T,EAAA2T,SAAAnZ,GACS,MAAAoZ,GACT,MAAAH,EAEA,IAAAC,EAAAG,cAAA,MAAAJ,GAIA,OAAAH,oCC1DA,YAAAhb,gCAAA,CAA4D,IAAAL,EAAA,IAAAuD,MAAA,uCAAsF,MAA7BvD,EAAA6K,KAAA,mBAA6B7K,EAClJF,EAAAD,QAAAQ,myJCDA,SAAAwb,EAAAC,GACA,IAAA9b,EAAA,IAAAuD,MAAA,uBAAAuY,EAAA,KAEA,MADA9b,EAAA6K,KAAA,mBACA7K,EAEA6b,EAAApM,KAAA,WAAuC,UACvCoM,EAAAnY,QAAAmY,EACA/b,EAAAD,QAAAgc,EACAA,EAAAE,GAAA,qBCRA,SAAA5X,EAAA2D,GAAAhI,EAAAD,QAAAsE,EAAA+F,QAcA,SAAA8R,GACA,IAAAC,EAAA,KAAAC,EAAAtb,KAAAub,GACAC,EAAAvV,KAAAwV,MAAAJ,GACAK,EAAAzV,KAAAwV,MAAAJ,EAAA,OACAD,IACAI,GAAAJ,EAAA,IACAM,GAAAN,EAAA,IACA,IACAI,IACAE,GAAA,MAGA,OAAAF,EAAAE,IAvBA,IAAAH,EAAArU,EAAAqU,aAAA,GACAD,EACAC,EAAAI,KACAJ,EAAAK,QACAL,EAAAM,OACAN,EAAAO,MACAP,EAAAQ,WACA,WAAa,WAAAC,MAAAC","file":"asc.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory((function webpackLoadOptionalExternalModule() { try { return require(\"assemblyscript\"); } catch(e) {} }()));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"assemblyscript\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"asc\"] = factory((function webpackLoadOptionalExternalModule() { try { return require(\"assemblyscript\"); } catch(e) {} }()));\n\telse\n\t\troot[\"asc\"] = factory(root[\"assemblyscript\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE__10__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","exports.nextTick = function nextTick(fn) {\n\tsetTimeout(fn, 0);\n};\n\nexports.platform = exports.arch = \nexports.execPath = exports.title = 'browser';\nexports.pid = 1;\nexports.browser = true;\nexports.env = {};\nexports.argv = [];\n\nexports.binding = function (name) {\n\tthrow new Error('No such module. (Possibly not yet loaded)')\n};\n\n(function () {\n var cwd = '/';\n var path;\n exports.cwd = function () { return cwd };\n exports.chdir = function (dir) {\n if (!path) path = require('path');\n cwd = path.resolve(dir, cwd);\n };\n})();\n\nexports.exit = exports.kill = \nexports.umask = exports.dlopen = \nexports.uptime = exports.memoryUsage = \nexports.uvCounters = function() {};\nexports.features = {};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\r\n * Compiler frontend for node.js\r\n *\r\n * Uses the low-level API exported from src/index.ts so it works with the compiler compiled to\r\n * JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources\r\n * directly through ts-node if distribution files are not present (indicated by a `-dev` version).\r\n *\r\n * Can also be packaged as a bundle suitable for in-browser use with the standard library injected\r\n * in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.\r\n *\r\n * @module cli/asc\r\n */\r\n\r\n// Use \".\" instead of \"/\" as cwd in browsers\r\nif (process.browser) process.cwd = function() { return \".\"; };\r\n\r\nconst fs = require(\"fs\");\r\nconst path = require(\"path\");\r\nconst utf8 = require(\"@protobufjs/utf8\");\r\nconst colorsUtil = require(\"./util/colors\");\r\nconst optionsUtil = require(\"./util/options\");\r\nconst mkdirp = require(\"./util/mkdirp\");\r\nconst EOL = process.platform === \"win32\" ? \"\\r\\n\" : \"\\n\";\r\n\r\n// global.Binaryen = require(\"../lib/binaryen\");\r\n\r\n// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional\r\n// useless code fragment on top of an actual error. suppress this:\r\nif (process.removeAllListeners) process.removeAllListeners(\"uncaughtException\");\r\n\r\n// Use distribution files if present, otherwise run the sources directly\r\nvar assemblyscript, isDev = false;\r\n(() => {\r\n try { // `asc` on the command line\r\n assemblyscript = require(\"../dist/assemblyscript.js\");\r\n } catch (e) {\r\n try { // `asc` on the command line without dist files\r\n require(\"ts-node\").register({ project: path.join(__dirname, \"..\", \"src\", \"tsconfig.json\") });\r\n require(\"../src/glue/js\");\r\n assemblyscript = require(\"../src\");\r\n isDev = true;\r\n } catch (e_ts) {\r\n try { // `require(\"dist/asc.js\")` in explicit browser tests\r\n assemblyscript = eval(\"require('./assemblyscript')\");\r\n } catch (e) {\r\n // combine both errors that lead us here\r\n e.stack = e_ts.stack + \"\\n---\\n\" + e.stack;\r\n throw e;\r\n }\r\n }\r\n }\r\n})();\r\n\r\n/** Whether this is a webpack bundle or not. */\r\nexports.isBundle = typeof BUNDLE_VERSION === \"string\";\r\n\r\n/** Whether asc runs the sources directly or not. */\r\nexports.isDev = isDev;\r\n\r\n/** AssemblyScript version. */\r\nexports.version = exports.isBundle ? BUNDLE_VERSION : require(\"../package.json\").version;\r\n\r\n/** Available CLI options. */\r\nexports.options = require(\"./asc.json\");\r\n\r\n/** Common root used in source maps. */\r\nexports.sourceMapRoot = \"assemblyscript:///\";\r\n\r\n/** Prefix used for library files. */\r\nexports.libraryPrefix = assemblyscript.LIBRARY_PREFIX;\r\n\r\n/** Default Binaryen optimization level. */\r\nexports.defaultOptimizeLevel = 3;\r\n\r\n/** Default Binaryen shrink level. */\r\nexports.defaultShrinkLevel = 1;\r\n\r\n/** Bundled library files. */\r\nexports.libraryFiles = exports.isBundle ? BUNDLE_LIBRARY : (() => { // set up if not a bundle\r\n const libDir = path.join(__dirname, \"..\", \"std\", \"assembly\");\r\n const libFiles = require(\"glob\").sync(\"**/!(*.d).ts\", { cwd: libDir });\r\n const bundled = {};\r\n libFiles.forEach(file => bundled[file.replace(/\\.ts$/, \"\")] = fs.readFileSync(path.join(libDir, file), \"utf8\" ));\r\n return bundled;\r\n})();\r\n\r\n/** Bundled definition files. */\r\nexports.definitionFiles = exports.isBundle ? BUNDLE_DEFINITIONS : (() => { // set up if not a bundle\r\n const stdDir = path.join(__dirname, \"..\", \"std\");\r\n return {\r\n \"assembly\": fs.readFileSync(path.join(stdDir, \"assembly\", \"index.d.ts\"), \"utf8\"),\r\n \"portable\": fs.readFileSync(path.join(stdDir, \"portable\", \"index.d.ts\"), \"utf8\")\r\n };\r\n})();\r\n\r\n/** Convenience function that parses and compiles source strings directly. */\r\nexports.compileString = (sources, options) => {\r\n if (typeof sources === \"string\") sources = { \"input.ts\": sources };\r\n const output = Object.create({\r\n stdout: createMemoryStream(),\r\n stderr: createMemoryStream()\r\n });\r\n var argv = [\r\n \"--binaryFile\", \"binary\",\r\n \"--textFile\", \"text\",\r\n ];\r\n Object.keys(options || {}).forEach(key => {\r\n var val = options[key];\r\n if (Array.isArray(val)) val.forEach(val => argv.push(\"--\" + key, String(val)));\r\n else argv.push(\"--\" + key, String(val));\r\n });\r\n exports.main(argv.concat(Object.keys(sources)), {\r\n stdout: output.stdout,\r\n stderr: output.stderr,\r\n readFile: name => sources.hasOwnProperty(name) ? sources[name] : null,\r\n writeFile: (name, contents) => output[name] = contents,\r\n listFiles: () => []\r\n });\r\n return output;\r\n}\r\n\r\n/** Runs the command line utility using the specified arguments array. */\r\nexports.main = function main(argv, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = {};\r\n } else if (!options) {\r\n options = {};\r\n }\r\n\r\n const stdout = options.stdout || process.stdout;\r\n const stderr = options.stderr || process.stderr;\r\n const readFile = options.readFile || readFileNode;\r\n const writeFile = options.writeFile || writeFileNode;\r\n const listFiles = options.listFiles || listFilesNode;\r\n const stats = options.stats || createStats();\r\n\r\n // Output must be specified if not present in the environment\r\n if (!stdout) throw Error(\"'options.stdout' must be specified\");\r\n if (!stderr) throw Error(\"'options.stderr' must be specified\");\r\n\r\n const opts = optionsUtil.parse(argv, exports.options);\r\n const args = opts.options;\r\n argv = opts.arguments;\r\n if (args.noColors) {\r\n colorsUtil.stdout.supported =\r\n colorsUtil.stderr.supported = false;\r\n } else {\r\n colorsUtil.stdout = colorsUtil.from(stdout);\r\n colorsUtil.stderr = colorsUtil.from(stderr);\r\n }\r\n\r\n // Check for unknown arguments\r\n if (opts.unknown.length) {\r\n opts.unknown.forEach(arg => {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unknown option '\" + arg + \"'\" + EOL);\r\n });\r\n }\r\n\r\n // Check for trailing arguments\r\n if (opts.trailing.length) {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unsupported trailing arguments: \" + opts.trailing.join(\" \") + EOL);\r\n }\r\n\r\n // Use default callback if none is provided\r\n if (!callback) callback = function defaultCallback(err) {\r\n var code = 0;\r\n if (err) {\r\n stderr.write(colorsUtil.stderr.red(\"ERROR: \") + err.stack.replace(/^ERROR: /i, \"\") + EOL);\r\n code = 1;\r\n }\r\n return code;\r\n };\r\n\r\n // Just print the version if requested\r\n if (args.version) {\r\n stdout.write(\"Version \" + exports.version + (isDev ? \"-dev\" : \"\") + EOL);\r\n return callback(null);\r\n }\r\n // Print the help message if requested or no source files are provided\r\n if (args.help || !argv.length) {\r\n var out = args.help ? stdout : stderr;\r\n var color = args.help ? colorsUtil.stdout : colorsUtil.stderr;\r\n out.write([\r\n color.white(\"SYNTAX\"),\r\n \" \" + color.cyan(\"asc\") + \" [entryFile ...] [options]\",\r\n \"\",\r\n color.white(\"EXAMPLES\"),\r\n \" \" + color.cyan(\"asc\") + \" hello.ts\",\r\n \" \" + color.cyan(\"asc\") + \" hello.ts -b hello.wasm -t hello.wat\",\r\n \" \" + color.cyan(\"asc\") + \" hello1.ts hello2.ts -b -O > hello.wasm\",\r\n \"\",\r\n color.white(\"OPTIONS\"),\r\n ].concat(\r\n optionsUtil.help(exports.options, 24, EOL)\r\n ).join(EOL) + EOL);\r\n return callback(null);\r\n }\r\n\r\n // I/O must be specified if not present in the environment\r\n if (!fs.readFileSync) {\r\n if (readFile === readFileNode) throw Error(\"'options.readFile' must be specified\");\r\n if (writeFile === writeFileNode) throw Error(\"'options.writeFile' must be specified\");\r\n if (listFiles === listFilesNode) throw Error(\"'options.listFiles' must be specified\");\r\n }\r\n\r\n // Set up base directory\r\n const baseDir = args.baseDir ? path.resolve(args.baseDir) : \".\";\r\n\r\n // Set up transforms\r\n const transforms = [];\r\n if (args.transform) {\r\n args.transform.forEach(transform =>\r\n transforms.push(\r\n require(\r\n path.isAbsolute(transform = transform.trim())\r\n ? transform\r\n : path.join(process.cwd(), transform)\r\n )\r\n )\r\n );\r\n }\r\n function applyTransform(name, ...args) {\r\n transforms.forEach(transform => {\r\n if (typeof transform[name] === \"function\") transform[name](...args);\r\n });\r\n }\r\n\r\n // Begin parsing\r\n var parser = null;\r\n\r\n // Include library files\r\n Object.keys(exports.libraryFiles).forEach(libPath => {\r\n if (libPath.indexOf(\"/\") >= 0) return; // in sub-directory: imported on demand\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n exports.libraryFiles[libPath],\r\n exports.libraryPrefix + libPath + \".ts\",\r\n false,\r\n parser\r\n );\r\n });\r\n });\r\n const customLibDirs = [];\r\n if (args.lib) {\r\n let lib = args.lib;\r\n if (typeof lib === \"string\") lib = lib.split(\",\");\r\n Array.prototype.push.apply(customLibDirs, lib.map(lib => lib.trim()));\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom\r\n let libDir = customLibDirs[i];\r\n let libFiles;\r\n if (libDir.endsWith(\".ts\")) {\r\n libFiles = [ path.basename(libDir) ];\r\n libDir = path.dirname(libDir);\r\n } else {\r\n libFiles = listFiles(libDir);\r\n }\r\n for (let j = 0, l = libFiles.length; j < l; ++j) {\r\n let libPath = libFiles[j];\r\n let libText = readFile(libPath, libDir);\r\n if (libText === null) return callback(Error(\"Library file '\" + libPath + \"' not found.\"));\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n libText,\r\n exports.libraryPrefix + libPath,\r\n false,\r\n parser\r\n );\r\n });\r\n }\r\n }\r\n }\r\n\r\n // Parses the backlog of imported files after including entry files\r\n function parseBacklog() {\r\n var sourcePath, sourceText;\r\n while ((sourcePath = parser.nextFile()) != null) {\r\n\r\n // Load library file if explicitly requested\r\n if (sourcePath.startsWith(exports.libraryPrefix)) {\r\n const plainName = sourcePath.substring(exports.libraryPrefix.length);\r\n const indexName = sourcePath.substring(exports.libraryPrefix.length) + \"/index\";\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Otherwise try nextFile.ts, nextFile/index.ts, ~lib/nextFile.ts, ~lib/nextFile/index.ts\r\n } else {\r\n const plainName = sourcePath;\r\n const indexName = sourcePath + \"/index\";\r\n sourceText = readFile(plainName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = plainName + \".ts\";\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = indexName + \".ts\";\r\n } else if (!plainName.startsWith(\".\")) {\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n const dir = customLibDirs[i];\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n if (sourceText == null) {\r\n return callback(Error(\"Import file '\" + sourcePath + \".ts' not found.\"));\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n assemblyscript.parseFile(sourceText, sourcePath, false, parser);\r\n });\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n return callback(Error(\"Parse error\"));\r\n }\r\n }\r\n\r\n // Include runtime template before entry files so its setup runs first\r\n {\r\n let templateName = String(args.runtime);\r\n let templateText = exports.libraryFiles[\"rt/index-\" + templateName];\r\n if (templateText == null) {\r\n templateText = readFile(templateName + \".ts\", baseDir);\r\n if (templateText == null) {\r\n return callback(Error(\"Runtime template '\" + templateName + \"' not found.\"));\r\n }\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(templateText, templateName, true, parser);\r\n });\r\n }\r\n\r\n // Include entry files\r\n for (let i = 0, k = argv.length; i < k; ++i) {\r\n const filename = argv[i];\r\n\r\n let sourcePath = String(filename).replace(/\\\\/g, \"/\").replace(/(\\.ts|\\/)$/, \"\");\r\n\r\n // Try entryPath.ts, then entryPath/index.ts\r\n let sourceText = readFile(sourcePath + \".ts\", baseDir);\r\n if (sourceText === null) {\r\n sourceText = readFile(sourcePath + \"/index.ts\", baseDir);\r\n if (sourceText === null) {\r\n return callback(Error(\"Entry file '\" + sourcePath + \".ts' not found.\"));\r\n } else {\r\n sourcePath += \"/index.ts\";\r\n }\r\n } else {\r\n sourcePath += \".ts\";\r\n }\r\n\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);\r\n });\r\n }\r\n\r\n // Parse entry files\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Call afterParse transform hook\r\n applyTransform(\"afterParse\", parser);\r\n\r\n // Parse additional files, if any\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Finish parsing\r\n const program = assemblyscript.finishParsing(parser);\r\n\r\n // Set up optimization levels\r\n var optimizeLevel = 0;\r\n var shrinkLevel = 0;\r\n if (args.optimize) {\r\n optimizeLevel = exports.defaultOptimizeLevel;\r\n shrinkLevel = exports.defaultShrinkLevel;\r\n }\r\n if (typeof args.optimizeLevel === \"number\") {\r\n optimizeLevel = args.optimizeLevel;\r\n }\r\n if (typeof args.shrinkLevel === \"number\") {\r\n shrinkLevel = args.shrinkLevel;\r\n }\r\n optimizeLevel = Math.min(Math.max(optimizeLevel, 0), 3);\r\n shrinkLevel = Math.min(Math.max(shrinkLevel, 0), 2);\r\n\r\n // Begin compilation\r\n const compilerOptions = assemblyscript.createOptions();\r\n assemblyscript.setTarget(compilerOptions, 0);\r\n assemblyscript.setNoAssert(compilerOptions, args.noAssert);\r\n assemblyscript.setImportMemory(compilerOptions, args.importMemory);\r\n assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);\r\n assemblyscript.setImportTable(compilerOptions, args.importTable);\r\n assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);\r\n assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);\r\n assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);\r\n\r\n // Initialize default aliases\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Math\", \"NativeMath\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Mathf\", \"NativeMathf\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"abort\", \"~lib/builtins/abort\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"trace\", \"~lib/builtins/trace\");\r\n\r\n // Add or override aliases if specified\r\n if (args.use) {\r\n let aliases = args.use;\r\n for (let i = 0, k = aliases.length; i < k; ++i) {\r\n let part = aliases[i];\r\n let p = part.indexOf(\"=\");\r\n if (p < 0) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n let name = part.substring(0, p).trim();\r\n let alias = part.substring(p + 1).trim();\r\n if (!name.length) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n assemblyscript.setGlobalAlias(compilerOptions, name, alias);\r\n }\r\n }\r\n\r\n // Enable additional features if specified\r\n var features = args.enable;\r\n if (features != null) {\r\n if (typeof features === \"string\") features = features.split(\",\");\r\n for (let i = 0, k = features.length; i < k; ++i) {\r\n let name = features[i].trim();\r\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\r\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\r\n assemblyscript.enableFeature(compilerOptions, flag);\r\n }\r\n }\r\n\r\n var module;\r\n stats.compileCount++;\r\n try {\r\n stats.compileTime += measure(() => {\r\n module = assemblyscript.compileProgram(program, compilerOptions);\r\n });\r\n } catch (e) {\r\n return callback(e);\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n if (module) module.dispose();\r\n return callback(Error(\"Compile error\"));\r\n }\r\n\r\n // Validate the module if requested\r\n if (args.validate) {\r\n stats.validateCount++;\r\n stats.validateTime += measure(() => {\r\n if (!module.validate()) {\r\n module.dispose();\r\n return callback(Error(\"Validate error\"));\r\n }\r\n });\r\n }\r\n\r\n // Set Binaryen-specific options\r\n if (args.trapMode === \"clamp\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-clamp\" ]);\r\n });\r\n } else if (args.trapMode === \"js\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-js\" ]);\r\n });\r\n } else if (args.trapMode !== \"allow\") {\r\n module.dispose();\r\n return callback(Error(\"Unsupported trap mode\"));\r\n }\r\n\r\n // Implicitly run costly non-LLVM optimizations on -O3 or -Oz\r\n // see: https://github.com/WebAssembly/binaryen/pull/1596\r\n if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;\r\n\r\n module.setOptimizeLevel(optimizeLevel);\r\n module.setShrinkLevel(shrinkLevel);\r\n module.setDebugInfo(args.debug);\r\n\r\n var runPasses = [];\r\n if (args.runPasses) {\r\n if (typeof args.runPasses === \"string\") {\r\n args.runPasses = args.runPasses.split(\",\");\r\n }\r\n if (args.runPasses.length) {\r\n args.runPasses.forEach(pass => {\r\n if (runPasses.indexOf(pass) < 0)\r\n runPasses.push(pass);\r\n });\r\n }\r\n }\r\n\r\n // Optimize the module if requested\r\n if (optimizeLevel > 0 || shrinkLevel > 0) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.optimize();\r\n });\r\n }\r\n\r\n // Run additional passes if requested\r\n if (runPasses.length) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses(runPasses.map(pass => pass.trim()));\r\n });\r\n }\r\n\r\n // Prepare output\r\n if (!args.noEmit) {\r\n let hasStdout = false;\r\n let hasOutput = false;\r\n\r\n if (args.outFile != null) {\r\n if (/\\.was?t$/.test(args.outFile) && args.textFile == null) {\r\n args.textFile = args.outFile;\r\n } else if (/\\.js$/.test(args.outFile) && args.asmjsFile == null) {\r\n args.asmjsFile = args.outFile;\r\n } else if (args.binaryFile == null) {\r\n args.binaryFile = args.outFile;\r\n }\r\n }\r\n\r\n // Write binary\r\n if (args.binaryFile != null) {\r\n let sourceMapURL = args.sourceMap != null\r\n ? args.sourceMap.length\r\n ? args.sourceMap\r\n : path.basename(args.binaryFile) + \".map\"\r\n : null;\r\n\r\n let wasm;\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wasm = module.toBinary(sourceMapURL)\r\n });\r\n\r\n if (args.binaryFile.length) {\r\n writeFile(args.binaryFile, wasm.output, baseDir);\r\n } else {\r\n writeStdout(wasm.output);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n\r\n // Post-process source map\r\n if (wasm.sourceMap != null) {\r\n if (args.binaryFile.length) {\r\n let sourceMap = JSON.parse(wasm.sourceMap);\r\n sourceMap.sourceRoot = exports.sourceMapRoot;\r\n sourceMap.sources.forEach((name, index) => {\r\n let text = null;\r\n if (name.startsWith(exports.libraryPrefix)) {\r\n let stdName = name.substring(exports.libraryPrefix.length).replace(/\\.ts$/, \"\");\r\n if (exports.libraryFiles.hasOwnProperty(stdName)) {\r\n text = exports.libraryFiles[stdName];\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n text = readFile(name.substring(exports.libraryPrefix.length), customLibDirs[i]);\r\n if (text !== null) break;\r\n }\r\n }\r\n } else {\r\n text = readFile(name, baseDir);\r\n }\r\n if (text === null) {\r\n return callback(Error(\"Source file '\" + name + \"' not found.\"));\r\n }\r\n if (!sourceMap.sourceContents) sourceMap.sourceContents = [];\r\n sourceMap.sourceContents[index] = text;\r\n });\r\n writeFile(path.join(\r\n path.dirname(args.binaryFile),\r\n path.basename(sourceMapURL)\r\n ).replace(/^\\.\\//, \"\"), JSON.stringify(sourceMap), baseDir);\r\n } else {\r\n stderr.write(\"Skipped source map (stdout already occupied)\" + EOL);\r\n }\r\n }\r\n }\r\n\r\n // Write asm.js\r\n if (args.asmjsFile != null) {\r\n let asm;\r\n if (args.asmjsFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeFile(args.asmjsFile, asm, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeStdout(asm);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write WebIDL\r\n if (args.idlFile != null) {\r\n let idl;\r\n if (args.idlFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeFile(args.idlFile, idl, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeStdout(idl);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write TypeScript definition\r\n if (args.tsdFile != null) {\r\n let tsd;\r\n if (args.tsdFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeFile(args.tsdFile, tsd, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeStdout(tsd);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write text (must be last)\r\n if (args.textFile != null || !hasOutput) {\r\n let wat;\r\n if (args.textFile && args.textFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText();\r\n });\r\n writeFile(args.textFile, wat, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText()\r\n });\r\n writeStdout(wat);\r\n }\r\n }\r\n }\r\n\r\n module.dispose();\r\n if (args.measure) {\r\n printStats(stats, stderr);\r\n }\r\n return callback(null);\r\n\r\n function readFileNode(filename, baseDir) {\r\n try {\r\n let text;\r\n stats.readCount++;\r\n stats.readTime += measure(() => {\r\n text = fs.readFileSync(path.join(baseDir, filename), { encoding: \"utf8\" });\r\n });\r\n return text;\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n function writeFileNode(filename, contents, baseDir) {\r\n try {\r\n stats.writeCount++;\r\n stats.writeTime += measure(() => {\r\n mkdirp(path.join(baseDir, path.dirname(filename)));\r\n if (typeof contents === \"string\") {\r\n fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: \"utf8\" } );\r\n } else {\r\n fs.writeFileSync(path.join(baseDir, filename), contents);\r\n }\r\n });\r\n return true;\r\n } catch (e) {\r\n return false;\r\n }\r\n }\r\n\r\n function listFilesNode(dirname, baseDir) {\r\n var files;\r\n try {\r\n stats.readTime += measure(() => {\r\n files = fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\\.d\\.ts$).*\\.ts$/.test(file));\r\n });\r\n return files;\r\n } catch (e) {\r\n return [];\r\n }\r\n }\r\n\r\n function writeStdout(contents) {\r\n if (!writeStdout.used) {\r\n stats.writeCount++;\r\n writeStdout.used = true;\r\n }\r\n stats.writeTime += measure(() => {\r\n if (typeof contents === \"string\") {\r\n stdout.write(contents, { encoding: \"utf8\" });\r\n } else {\r\n stdout.write(contents);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Checks diagnostics emitted so far for errors. */\r\nfunction checkDiagnostics(emitter, stderr) {\r\n var diagnostic;\r\n var hasErrors = false;\r\n while ((diagnostic = assemblyscript.nextDiagnostic(emitter)) != null) {\r\n if (stderr) {\r\n stderr.write(\r\n assemblyscript.formatDiagnostic(diagnostic, stderr.isTTY, true) +\r\n EOL + EOL\r\n );\r\n }\r\n if (assemblyscript.isError(diagnostic)) hasErrors = true;\r\n }\r\n return hasErrors;\r\n}\r\n\r\nexports.checkDiagnostics = checkDiagnostics;\r\n\r\n/** Creates an empty set of stats. */\r\nfunction createStats() {\r\n return {\r\n readTime: 0,\r\n readCount: 0,\r\n writeTime: 0,\r\n writeCount: 0,\r\n parseTime: 0,\r\n parseCount: 0,\r\n compileTime: 0,\r\n compileCount: 0,\r\n emitTime: 0,\r\n emitCount: 0,\r\n validateTime: 0,\r\n validateCount: 0,\r\n optimizeTime: 0,\r\n optimizeCount: 0\r\n };\r\n}\r\n\r\nexports.createStats = createStats;\r\n\r\nif (!process.hrtime) process.hrtime = require(\"browser-process-hrtime\");\r\n\r\n/** Measures the execution time of the specified function. */\r\nfunction measure(fn) {\r\n const start = process.hrtime();\r\n fn();\r\n const times = process.hrtime(start);\r\n return times[0] * 1e9 + times[1];\r\n}\r\n\r\nexports.measure = measure;\r\n\r\n/** Formats a high resolution time to a human readable string. */\r\nfunction formatTime(time) {\r\n return time ? (time / 1e6).toFixed(3) + \" ms\" : \"N/A\";\r\n}\r\n\r\nexports.formatTime = formatTime;\r\n\r\n/** Formats and prints out the contents of a set of stats. */\r\nfunction printStats(stats, output) {\r\n function format(time, count) {\r\n return formatTime(time);\r\n }\r\n (output || process.stdout).write([\r\n \"I/O Read : \" + format(stats.readTime, stats.readCount),\r\n \"I/O Write : \" + format(stats.writeTime, stats.writeCount),\r\n \"Parse : \" + format(stats.parseTime, stats.parseCount),\r\n \"Compile : \" + format(stats.compileTime, stats.compileCount),\r\n \"Emit : \" + format(stats.emitTime, stats.emitCount),\r\n \"Validate : \" + format(stats.validateTime, stats.validateCount),\r\n \"Optimize : \" + format(stats.optimizeTime, stats.optimizeCount)\r\n ].join(EOL) + EOL);\r\n}\r\n\r\nexports.printStats = printStats;\r\n\r\nvar allocBuffer = typeof global !== \"undefined\" && global.Buffer\r\n ? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }\r\n : function(len) { return new Uint8Array(len) };\r\n\r\n/** Creates a memory stream that can be used in place of stdout/stderr. */\r\nfunction createMemoryStream(fn) {\r\n var stream = [];\r\n stream.write = function(chunk) {\r\n if (fn) fn(chunk);\r\n if (typeof chunk === \"string\") {\r\n let buffer = allocBuffer(utf8.length(chunk));\r\n utf8.write(chunk, buffer, 0);\r\n chunk = buffer;\r\n }\r\n this.push(chunk);\r\n };\r\n stream.reset = function() {\r\n stream.length = 0;\r\n };\r\n stream.toBuffer = function() {\r\n var offset = 0, i = 0, k = this.length;\r\n while (i < k) offset += this[i++].length;\r\n var buffer = allocBuffer(offset);\r\n offset = i = 0;\r\n while (i < k) {\r\n buffer.set(this[i], offset);\r\n offset += this[i].length;\r\n ++i;\r\n }\r\n return buffer;\r\n };\r\n stream.toString = function() {\r\n var buffer = this.toBuffer();\r\n return utf8.read(buffer, 0, buffer.length);\r\n };\r\n return stream;\r\n}\r\n\r\nexports.createMemoryStream = createMemoryStream;\r\n\r\n/** Compatible TypeScript compiler options for syntax highlighting etc. */\r\nexports.tscOptions = {\r\n alwaysStrict: true,\r\n noImplicitAny: true,\r\n noImplicitReturns: true,\r\n noImplicitThis: true,\r\n noEmitOnError: true,\r\n strictNullChecks: true,\r\n experimentalDecorators: true,\r\n target: \"esnext\",\r\n module: \"commonjs\",\r\n noLib: true,\r\n types: [],\r\n allowJs: false\r\n};\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal UTF8 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar utf8 = exports;\r\n\r\n/**\r\n * Calculates the UTF8 byte length of a string.\r\n * @param {string} string String\r\n * @returns {number} Byte length\r\n */\r\nutf8.length = function utf8_length(string) {\r\n var len = 0,\r\n c = 0;\r\n for (var i = 0; i < string.length; ++i) {\r\n c = string.charCodeAt(i);\r\n if (c < 128)\r\n len += 1;\r\n else if (c < 2048)\r\n len += 2;\r\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\r\n ++i;\r\n len += 4;\r\n } else\r\n len += 3;\r\n }\r\n return len;\r\n};\r\n\r\n/**\r\n * Reads UTF8 bytes as a string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} String read\r\n */\r\nutf8.read = function utf8_read(buffer, start, end) {\r\n var len = end - start;\r\n if (len < 1)\r\n return \"\";\r\n var parts = null,\r\n chunk = [],\r\n i = 0, // char offset\r\n t; // temporary\r\n while (start < end) {\r\n t = buffer[start++];\r\n if (t < 128)\r\n chunk[i++] = t;\r\n else if (t > 191 && t < 224)\r\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\r\n else if (t > 239 && t < 365) {\r\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\r\n chunk[i++] = 0xD800 + (t >> 10);\r\n chunk[i++] = 0xDC00 + (t & 1023);\r\n } else\r\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\n/**\r\n * Writes a string as UTF8 bytes.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Bytes written\r\n */\r\nutf8.write = function utf8_write(string, buffer, offset) {\r\n var start = offset,\r\n c1, // character 1\r\n c2; // character 2\r\n for (var i = 0; i < string.length; ++i) {\r\n c1 = string.charCodeAt(i);\r\n if (c1 < 128) {\r\n buffer[offset++] = c1;\r\n } else if (c1 < 2048) {\r\n buffer[offset++] = c1 >> 6 | 192;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\r\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\r\n ++i;\r\n buffer[offset++] = c1 >> 18 | 240;\r\n buffer[offset++] = c1 >> 12 & 63 | 128;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else {\r\n buffer[offset++] = c1 >> 12 | 224;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n }\r\n }\r\n return offset - start;\r\n};\r\n","var proc = typeof process !== \"undefined\" && process || {};\r\nvar isCI = proc.env && \"CI\" in proc.env; // doesn't work when bundled because 'process' is a mock\r\n\r\nfunction from(stream, base) {\r\n var colors = base || {};\r\n colors.supported = (stream && !!stream.isTTY) || isCI;\r\n colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;\r\n colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;\r\n colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;\r\n colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;\r\n colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;\r\n colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;\r\n colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;\r\n colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;\r\n return colors;\r\n}\r\n\r\nexports.stdout = from(proc.stdout, exports);\r\nexports.stderr = from(proc.stderr);\r\nexports.from = from;\r\n\r\nexports.GRAY = \"\\u001b[90m\";\r\nexports.RED = \"\\u001b[91m\";\r\nexports.GREEN = \"\\u001b[92m\";\r\nexports.YELLOW = \"\\u001b[93m\";\r\nexports.BLUE = \"\\u001b[94m\";\r\nexports.MAGENTA = \"\\u001b[95m\";\r\nexports.CYAN = \"\\u001b[96m\";\r\nexports.WHITE = \"\\u001b[97m\";\r\nexports.RESET = \"\\u001b[0m\";\r\n","// type | meaning\r\n// -----|---------------\r\n// b | boolean\r\n// i | integer\r\n// f | float\r\n// s | string\r\n// I | integer array\r\n// F | float array\r\n// S | string array\r\n\r\n/** Parses the specified command line arguments according to the given configuration. */\r\nfunction parse(argv, config) {\r\n var options = {};\r\n var unknown = [];\r\n var arguments = [];\r\n var trailing = [];\r\n\r\n // make an alias map and initialize defaults\r\n var aliases = {};\r\n Object.keys(config).forEach(key => {\r\n if (key.startsWith(\" \")) return;\r\n var option = config[key];\r\n if (option.alias != null) {\r\n if (typeof option.alias === \"string\") aliases[option.alias] = key;\r\n else if (Array.isArray(option.alias)) option.alias.forEach(alias => aliases[alias] = key);\r\n }\r\n if (option.default != null) options[key] = option.default;\r\n });\r\n\r\n // iterate over argv\r\n for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {\r\n let arg = argv[i];\r\n if (arg == \"--\") { ++i; break; }\r\n let match = /^(?:(\\-\\w)(?:=(.*))?|(\\-\\-\\w{2,})(?:=(.*))?)$/.exec(arg), option, key;\r\n if (match) {\r\n if (config[arg]) option = config[key = arg]; // exact\r\n else if (match[1] != null) { // alias\r\n option = config[key = aliases[match[1].substring(1)]];\r\n if (option && match[2] != null) argv[i--] = match[2];\r\n } else if (match[3] != null) { // full\r\n option = config[key = match[3].substring(2)];\r\n if (option && match[4] != null) argv[i--] = match[4];\r\n }\r\n } else {\r\n if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact\r\n else { arguments.push(arg); continue; } // argument\r\n }\r\n if (option) {\r\n if (option.type == null || option.type === \"b\") options[key] = true; // flag\r\n else {\r\n if (i + 1 < argv.length && argv[i + 1].charCodeAt(0) != 45) { // present\r\n switch (option.type) {\r\n case \"i\": options[key] = parseInt(argv[++i], 10); break;\r\n case \"I\": options[key] = (options[key] || []).concat(parseInt(argv[++i], 10)); break;\r\n case \"f\": options[key] = parseFloat(argv[++i]); break;\r\n case \"F\": options[key] = (options[key] || []).concat(parseFloat(argv[++i])); break;\r\n case \"s\": options[key] = String(argv[++i]); break;\r\n case \"S\": options[key] = (options[key] || []).concat(argv[++i].split(\",\")); break;\r\n default: unknown.push(arg); --i;\r\n }\r\n } else { // omitted\r\n switch (option.type) {\r\n case \"i\":\r\n case \"f\": options[key] = option.default || 0; break;\r\n case \"s\": options[key] = option.default || \"\"; break;\r\n case \"I\":\r\n case \"F\":\r\n case \"S\": options[key] = options.default || []; break;\r\n default: unknown.push(arg);\r\n }\r\n }\r\n }\r\n if (option.value) Object.keys(option.value).forEach(k => options[k] = option.value[k]);\r\n } else unknown.push(arg);\r\n }\r\n while (i < k) trailing.push(argv[i++]); // trailing\r\n\r\n return { options, unknown, arguments, trailing };\r\n}\r\n\r\nexports.parse = parse;\r\n\r\n/** Generates the help text for the specified configuration. */\r\nfunction help(config, options) {\r\n if (!options) options = {};\r\n var indent = options.indent || 2;\r\n var padding = options.padding || 24;\r\n var eol = options.eol || \"\\n\";\r\n var sb = [];\r\n Object.keys(config).forEach(key => {\r\n var option = config[key];\r\n if (option.description == null) return;\r\n var text = \"\";\r\n while (text.length < indent) text += \" \";\r\n text += \"--\" + key;\r\n if (option.alias) text += \", -\" + option.alias;\r\n while (text.length < padding) text += \" \";\r\n if (Array.isArray(option.description)) {\r\n sb.push(text + option.description[0] + option.description.slice(1).map(line => {\r\n for (let i = 0; i < padding; ++i) line = \" \" + line;\r\n return eol + line;\r\n }).join(\"\"));\r\n } else sb.push(text + option.description);\r\n });\r\n return sb.join(eol);\r\n}\r\n\r\nexports.help = help;\r\n","/*\r\nCopyright 2010 James Halliday (mail@substack.net)\r\n\r\nThis project is free software released under the MIT/X11 license:\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n*/\r\n\r\nvar path = require(\"path\");\r\nvar fs = require(\"fs\");\r\nvar _0777 = parseInt(\"0777\", 8);\r\n\r\nmodule.exports = function mkdirp(p, opts, made) {\r\n if (!opts || typeof opts !== \"object\") {\r\n opts = { mode: opts };\r\n }\r\n var mode = opts.mode;\r\n if (mode === undefined) {\r\n mode = _0777 & (~process.umask());\r\n }\r\n if (!made) made = null;\r\n p = path.resolve(p);\r\n try {\r\n fs.mkdirSync(p, mode);\r\n made = made || p;\r\n } catch (err0) {\r\n switch (err0.code) {\r\n case \"ENOENT\":\r\n made = mkdirp(path.dirname(p), opts, made);\r\n mkdirp(p, opts, made);\r\n break;\r\n default:\r\n var stat;\r\n try {\r\n stat = fs.statSync(p);\r\n } catch (err1) {\r\n throw err0;\r\n }\r\n if (!stat.isDirectory()) throw err0;\r\n break;\r\n }\r\n }\r\n return made;\r\n};\r\n","if(typeof __WEBPACK_EXTERNAL_MODULE__10__ === 'undefined') {var e = new Error(\"Cannot find module 'assemblyscript'\"); e.code = 'MODULE_NOT_FOUND'; throw e;}\nmodule.exports = __WEBPACK_EXTERNAL_MODULE__10__;","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 12;","module.exports = process.hrtime || hrtime\n\n// polyfil for window.performance.now\nvar performance = global.performance || {}\nvar performanceNow =\n performance.now ||\n performance.mozNow ||\n performance.msNow ||\n performance.oNow ||\n performance.webkitNow ||\n function(){ return (new Date()).getTime() }\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nfunction hrtime(previousTimestamp){\n var clocktime = performanceNow.call(performance)*1e-3\n var seconds = Math.floor(clocktime)\n var nanoseconds = Math.floor((clocktime%1)*1e9)\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0]\n nanoseconds = nanoseconds - previousTimestamp[1]\n if (nanoseconds<0) {\n seconds--\n nanoseconds += 1e9\n }\n }\n return [seconds,nanoseconds]\n}"],"sourceRoot":""} \ No newline at end of file